]> git.lizzy.rs Git - rust.git/commitdiff
Merge pull request #20674 from jbcrail/fix-misspelled-comments
authorbors <bors@rust-lang.org>
Wed, 7 Jan 2015 15:35:30 +0000 (15:35 +0000)
committerbors <bors@rust-lang.org>
Wed, 7 Jan 2015 15:35:30 +0000 (15:35 +0000)
Fix misspelled comments.

Reviewed-by: steveklabnik
742 files changed:
AUTHORS.txt
RELEASES.md
src/compiletest/common.rs
src/compiletest/compiletest.rs
src/compiletest/errors.rs
src/compiletest/runtest.rs
src/doc/guide-error-handling.md
src/doc/guide-macros.md
src/doc/guide-pointers.md
src/doc/guide-unsafe.md
src/doc/guide.md
src/doc/intro.md
src/doc/reference.md
src/etc/gdb_rust_pretty_printing.py [changed mode: 0644->0755]
src/etc/kate/rust.xml
src/etc/lldb_rust_formatters.py
src/etc/zsh/_rust
src/liballoc/arc.rs
src/liballoc/boxed.rs
src/liballoc/lib.rs
src/liballoc/rc.rs
src/libcollections/bit.rs
src/libcollections/btree/map.rs
src/libcollections/btree/node.rs
src/libcollections/btree/set.rs
src/libcollections/dlist.rs
src/libcollections/enum_set.rs
src/libcollections/lib.rs
src/libcollections/macros.rs
src/libcollections/ring_buf.rs
src/libcollections/slice.rs
src/libcollections/str.rs
src/libcollections/string.rs
src/libcollections/vec.rs
src/libcollections/vec_map.rs
src/libcore/any.rs
src/libcore/array.rs
src/libcore/atomic.rs
src/libcore/borrow.rs
src/libcore/cell.rs
src/libcore/clone.rs
src/libcore/cmp.rs
src/libcore/fmt/float.rs
src/libcore/fmt/mod.rs
src/libcore/fmt/num.rs
src/libcore/intrinsics.rs
src/libcore/iter.rs
src/libcore/kinds.rs [deleted file]
src/libcore/lib.rs
src/libcore/macros.rs
src/libcore/marker.rs [new file with mode: 0644]
src/libcore/mem.rs
src/libcore/num/mod.rs
src/libcore/ops.rs
src/libcore/option.rs
src/libcore/prelude.rs
src/libcore/ptr.rs
src/libcore/raw.rs
src/libcore/result.rs
src/libcore/simd.rs
src/libcore/slice.rs
src/libcore/str/mod.rs
src/libcore/ty.rs
src/libcoretest/any.rs
src/libcoretest/cell.rs
src/libcoretest/char.rs
src/libcoretest/fmt/num.rs
src/libcoretest/hash/mod.rs
src/libcoretest/iter.rs
src/libcoretest/num/mod.rs
src/libcoretest/option.rs
src/libcoretest/result.rs
src/libcoretest/slice.rs
src/libcoretest/tuple.rs
src/libflate/lib.rs
src/libfmt_macros/lib.rs
src/libgetopts/lib.rs
src/libgraphviz/lib.rs
src/liblibc/lib.rs
src/liblog/directive.rs
src/liblog/lib.rs
src/librand/distributions/range.rs
src/librand/lib.rs
src/librbml/io.rs
src/librbml/lib.rs
src/libregex/compile.rs
src/libregex/lib.rs
src/libregex/parse.rs
src/libregex/re.rs
src/libregex/test/mod.rs
src/libregex/test/tests.rs
src/libregex/vm.rs
src/librustc/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/decoder.rs
src/librustc/metadata/encoder.rs
src/librustc/metadata/loader.rs
src/librustc/metadata/tydecode.rs
src/librustc/metadata/tyencode.rs
src/librustc/middle/astconv_util.rs
src/librustc/middle/astencode.rs
src/librustc/middle/cfg/construct.rs
src/librustc/middle/cfg/graphviz.rs
src/librustc/middle/check_const.rs
src/librustc/middle/check_loop.rs
src/librustc/middle/check_match.rs
src/librustc/middle/check_rvalues.rs
src/librustc/middle/check_static.rs
src/librustc/middle/check_static_recursion.rs
src/librustc/middle/const_eval.rs
src/librustc/middle/dataflow.rs
src/librustc/middle/dependency_format.rs
src/librustc/middle/expr_use_visitor.rs
src/librustc/middle/graph.rs
src/librustc/middle/infer/coercion.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/mod.rs
src/librustc/middle/infer/region_inference/graphviz.rs
src/librustc/middle/infer/region_inference/mod.rs
src/librustc/middle/infer/resolve.rs
src/librustc/middle/infer/type_variable.rs
src/librustc/middle/infer/unify.rs
src/librustc/middle/intrinsicck.rs
src/librustc/middle/lang_items.rs
src/librustc/middle/liveness.rs
src/librustc/middle/mem_categorization.rs
src/librustc/middle/privacy.rs
src/librustc/middle/reachable.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/coherence.rs
src/librustc/middle/traits/error_reporting.rs
src/librustc/middle/traits/fulfill.rs
src/librustc/middle/traits/mod.rs
src/librustc/middle/traits/object_safety.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_fold.rs
src/librustc/middle/ty_walk.rs
src/librustc/plugin/load.rs
src/librustc/session/config.rs
src/librustc/session/mod.rs
src/librustc/util/common.rs
src/librustc/util/lev_distance.rs
src/librustc/util/ppaux.rs
src/librustc/util/snapshot_vec.rs
src/librustc_back/archive.rs
src/librustc_back/lib.rs
src/librustc_back/rpath.rs
src/librustc_back/sha2.rs
src/librustc_back/svh.rs
src/librustc_back/target/mod.rs
src/librustc_borrowck/borrowck/check_loans.rs
src/librustc_borrowck/borrowck/doc.rs
src/librustc_borrowck/borrowck/fragments.rs
src/librustc_borrowck/borrowck/gather_loans/gather_moves.rs
src/librustc_borrowck/borrowck/gather_loans/mod.rs
src/librustc_borrowck/borrowck/gather_loans/move_error.rs
src/librustc_borrowck/borrowck/mod.rs
src/librustc_borrowck/borrowck/move_data.rs
src/librustc_borrowck/graphviz.rs
src/librustc_borrowck/lib.rs
src/librustc_driver/driver.rs
src/librustc_driver/lib.rs
src/librustc_driver/pretty.rs
src/librustc_driver/test.rs
src/librustc_llvm/lib.rs
src/librustc_resolve/build_reduced_graph.rs
src/librustc_resolve/check_unused.rs
src/librustc_resolve/lib.rs
src/librustc_resolve/record_exports.rs
src/librustc_trans/back/link.rs
src/librustc_trans/back/lto.rs
src/librustc_trans/back/write.rs
src/librustc_trans/lib.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/builder.rs
src/librustc_trans/trans/cabi.rs
src/librustc_trans/trans/cabi_x86_64.rs
src/librustc_trans/trans/callee.rs
src/librustc_trans/trans/cleanup.rs
src/librustc_trans/trans/closure.rs
src/librustc_trans/trans/common.rs
src/librustc_trans/trans/consts.rs
src/librustc_trans/trans/context.rs
src/librustc_trans/trans/controlflow.rs
src/librustc_trans/trans/datum.rs
src/librustc_trans/trans/debuginfo.rs
src/librustc_trans/trans/expr.rs
src/librustc_trans/trans/foreign.rs
src/librustc_trans/trans/glue.rs
src/librustc_trans/trans/intrinsic.rs
src/librustc_trans/trans/meth.rs
src/librustc_trans/trans/mod.rs
src/librustc_trans/trans/monomorphize.rs
src/librustc_trans/trans/type_.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/closure.rs
src/librustc_typeck/check/method/confirm.rs
src/librustc_typeck/check/method/mod.rs
src/librustc_typeck/check/method/probe.rs
src/librustc_typeck/check/mod.rs
src/librustc_typeck/check/regionck.rs
src/librustc_typeck/check/regionmanip.rs
src/librustc_typeck/check/upvar.rs
src/librustc_typeck/check/vtable.rs
src/librustc_typeck/check/wf.rs
src/librustc_typeck/check/writeback.rs
src/librustc_typeck/coherence/mod.rs
src/librustc_typeck/collect.rs
src/librustc_typeck/lib.rs
src/librustc_typeck/variance.rs
src/librustdoc/clean/inline.rs
src/librustdoc/clean/mod.rs
src/librustdoc/core.rs
src/librustdoc/html/escape.rs
src/librustdoc/html/format.rs
src/librustdoc/html/highlight.rs
src/librustdoc/html/item_type.rs
src/librustdoc/html/layout.rs
src/librustdoc/html/markdown.rs
src/librustdoc/html/render.rs
src/librustdoc/html/toc.rs
src/librustdoc/lib.rs
src/librustdoc/test.rs
src/librustdoc/visit_ast.rs
src/libserialize/base64.rs
src/libserialize/collection_impls.rs
src/libserialize/collection_impls_stage0.rs [deleted file]
src/libserialize/hex.rs
src/libserialize/json.rs
src/libserialize/json_stage0.rs [deleted file]
src/libserialize/lib.rs
src/libserialize/serialize.rs
src/libserialize/serialize_stage0.rs [deleted file]
src/libstd/bitflags.rs
src/libstd/collections/hash/map.rs
src/libstd/collections/hash/set.rs
src/libstd/collections/hash/table.rs
src/libstd/collections/mod.rs
src/libstd/error.rs
src/libstd/failure.rs
src/libstd/fmt.rs
src/libstd/hash.rs
src/libstd/io/buffered.rs
src/libstd/io/comm_adapters.rs
src/libstd/io/fs.rs
src/libstd/io/mem.rs
src/libstd/io/mod.rs
src/libstd/io/net/addrinfo.rs
src/libstd/io/net/ip.rs
src/libstd/io/net/pipe.rs
src/libstd/io/net/tcp.rs
src/libstd/io/process.rs
src/libstd/io/stdio.rs
src/libstd/io/timer.rs
src/libstd/io/util.rs
src/libstd/lib.rs
src/libstd/macros.rs
src/libstd/macros_stage0.rs [deleted file]
src/libstd/num/mod.rs
src/libstd/os.rs
src/libstd/path/mod.rs
src/libstd/path/posix.rs
src/libstd/path/windows.rs
src/libstd/prelude/v1.rs
src/libstd/rand/mod.rs
src/libstd/rand/os.rs
src/libstd/rand/reader.rs
src/libstd/rt/macros.rs
src/libstd/rt/mod.rs
src/libstd/rt/unwind.rs
src/libstd/rt/util.rs
src/libstd/sync/barrier.rs
src/libstd/sync/condvar.rs
src/libstd/sync/future.rs
src/libstd/sync/mpsc/blocking.rs
src/libstd/sync/mpsc/mod.rs
src/libstd/sync/mpsc/mpsc_queue.rs
src/libstd/sync/mpsc/select.rs
src/libstd/sync/mpsc/sync.rs
src/libstd/sync/mutex.rs
src/libstd/sync/once.rs
src/libstd/sync/rwlock.rs
src/libstd/sync/semaphore.rs
src/libstd/sync/task_pool.rs
src/libstd/sys/common/backtrace.rs
src/libstd/sys/common/helper_thread.rs
src/libstd/sys/common/mutex.rs
src/libstd/sys/common/net.rs
src/libstd/sys/unix/backtrace.rs
src/libstd/sys/unix/c.rs
src/libstd/sys/unix/fs.rs
src/libstd/sys/unix/mutex.rs
src/libstd/sys/unix/process.rs
src/libstd/sys/unix/thread_local.rs
src/libstd/sys/windows/backtrace.rs
src/libstd/sys/windows/c.rs
src/libstd/sys/windows/os.rs
src/libstd/sys/windows/pipe.rs
src/libstd/sys/windows/process.rs
src/libstd/sys/windows/thread.rs
src/libstd/sys/windows/tty.rs
src/libstd/thread.rs
src/libstd/thread_local/mod.rs
src/libstd/thread_local/scoped.rs
src/libstd/thunk.rs
src/libstd/time/duration.rs
src/libsyntax/abi.rs
src/libsyntax/ast.rs
src/libsyntax/ast_map/mod.rs
src/libsyntax/ast_util.rs
src/libsyntax/attr.rs
src/libsyntax/codemap.rs
src/libsyntax/diagnostic.rs
src/libsyntax/diagnostics/plugin.rs
src/libsyntax/ext/asm.rs
src/libsyntax/ext/base.rs
src/libsyntax/ext/build.rs
src/libsyntax/ext/concat.rs
src/libsyntax/ext/concat_idents.rs
src/libsyntax/ext/deriving/bounds.rs
src/libsyntax/ext/deriving/clone.rs
src/libsyntax/ext/deriving/decodable.rs
src/libsyntax/ext/deriving/encodable.rs
src/libsyntax/ext/deriving/generic/mod.rs
src/libsyntax/ext/deriving/mod.rs
src/libsyntax/ext/deriving/show.rs
src/libsyntax/ext/env.rs
src/libsyntax/ext/expand.rs
src/libsyntax/ext/format.rs
src/libsyntax/ext/mtwt.rs
src/libsyntax/ext/quote.rs
src/libsyntax/ext/source_util.rs
src/libsyntax/ext/tt/macro_parser.rs
src/libsyntax/ext/tt/macro_rules.rs
src/libsyntax/ext/tt/transcribe.rs
src/libsyntax/feature_gate.rs
src/libsyntax/lib.rs
src/libsyntax/owned_slice.rs
src/libsyntax/parse/attr.rs
src/libsyntax/parse/lexer/comments.rs
src/libsyntax/parse/lexer/mod.rs
src/libsyntax/parse/mod.rs
src/libsyntax/parse/obsolete.rs
src/libsyntax/parse/parser.rs
src/libsyntax/parse/token.rs
src/libsyntax/print/pp.rs
src/libsyntax/print/pprust.rs
src/libsyntax/ptr.rs
src/libsyntax/std_inject.rs
src/libsyntax/test.rs
src/libsyntax/util/interner.rs
src/libterm/lib.rs
src/libterm/terminfo/mod.rs
src/libterm/terminfo/parm.rs
src/libterm/terminfo/parser/compiled.rs
src/libterm/terminfo/searcher.rs
src/libtest/lib.rs
src/libtest/stats.rs
src/libunicode/lib.rs
src/libunicode/tables.rs
src/llvm
src/rust-installer
src/snapshots.txt
src/test/auxiliary/cci_capture_clause.rs
src/test/auxiliary/cci_class_cast.rs
src/test/auxiliary/nested_item.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-meteor.rs
src/test/bench/shootout-pfib.rs
src/test/bench/shootout-reverse-complement.rs
src/test/bench/shootout-spectralnorm.rs
src/test/bench/shootout-threadring.rs
src/test/bench/task-perf-alloc-unwind.rs
src/test/bench/task-perf-jargon-metal-smoke.rs
src/test/bench/task-perf-spawnalot.rs
src/test/compile-fail/array-not-vector.rs
src/test/compile-fail/associated-types-eq-3.rs
src/test/compile-fail/associated-types-invalid-trait-ref-issue-18865.rs
src/test/compile-fail/associated-types-path-2.rs
src/test/compile-fail/associated-types-unsized.rs
src/test/compile-fail/autoderef-full-lval.rs
src/test/compile-fail/bad-const-type.rs
src/test/compile-fail/bad-method-typaram-kind.rs
src/test/compile-fail/bad-sized.rs
src/test/compile-fail/binop-logic-int.rs
src/test/compile-fail/borrowck-loan-vec-content.rs
src/test/compile-fail/borrowck-move-out-of-static-item.rs
src/test/compile-fail/borrowck-move-out-of-vec-tail.rs
src/test/compile-fail/borrowck-struct-update-with-dtor.rs
src/test/compile-fail/builtin-superkinds-double-superkind.rs
src/test/compile-fail/builtin-superkinds-in-metadata.rs
src/test/compile-fail/builtin-superkinds-typaram-not-send.rs
src/test/compile-fail/check-static-values-constraints.rs
src/test/compile-fail/closure-bounds-cant-promote-superkind-in-struct.rs
src/test/compile-fail/closure-bounds-subtype.rs
src/test/compile-fail/coercion-slice.rs
src/test/compile-fail/coherence-all-remote.rs
src/test/compile-fail/comm-not-freeze-receiver.rs
src/test/compile-fail/comm-not-freeze.rs
src/test/compile-fail/copy-a-resource.rs
src/test/compile-fail/dst-bad-assign-2.rs
src/test/compile-fail/dst-bad-assign.rs
src/test/compile-fail/dst-bad-coerce1.rs
src/test/compile-fail/dst-bad-coerce4.rs
src/test/compile-fail/dst-bad-deep.rs
src/test/compile-fail/dst-object-from-unsized-type.rs
src/test/compile-fail/dst-sized-trait-param.rs
src/test/compile-fail/error-should-say-copy-not-pod.rs
src/test/compile-fail/fn-trait-formatting.rs
src/test/compile-fail/fully-qualified-type-name1.rs
src/test/compile-fail/fully-qualified-type-name4.rs
src/test/compile-fail/generic-type-params-name-repr.rs
src/test/compile-fail/hrtb-just-for-static.rs
src/test/compile-fail/hrtb-perfect-forwarding.rs
src/test/compile-fail/hrtb-type-outlives.rs
src/test/compile-fail/if-branch-types.rs
src/test/compile-fail/ifmt-bad-arg.rs
src/test/compile-fail/impl-unused-tps-inherent.rs [new file with mode: 0644]
src/test/compile-fail/impl-unused-tps.rs [new file with mode: 0644]
src/test/compile-fail/indexing-requires-a-uint.rs
src/test/compile-fail/integral-indexing.rs
src/test/compile-fail/issue-10176.rs
src/test/compile-fail/issue-10991.rs
src/test/compile-fail/issue-12028.rs
src/test/compile-fail/issue-12997-2.rs
src/test/compile-fail/issue-13058.rs
src/test/compile-fail/issue-13359.rs
src/test/compile-fail/issue-13466.rs
src/test/compile-fail/issue-13853-5.rs
src/test/compile-fail/issue-14366.rs
src/test/compile-fail/issue-14853.rs
src/test/compile-fail/issue-14915.rs
src/test/compile-fail/issue-15094.rs
src/test/compile-fail/issue-15756.rs
src/test/compile-fail/issue-16250.rs
src/test/compile-fail/issue-16538.rs
src/test/compile-fail/issue-16562.rs
src/test/compile-fail/issue-16709.rs [deleted file]
src/test/compile-fail/issue-17441.rs
src/test/compile-fail/issue-17444.rs
src/test/compile-fail/issue-17651.rs
src/test/compile-fail/issue-17718-static-move.rs
src/test/compile-fail/issue-17718-static-sync.rs
src/test/compile-fail/issue-17728.rs
src/test/compile-fail/issue-17905.rs
src/test/compile-fail/issue-18107.rs
src/test/compile-fail/issue-18611.rs
src/test/compile-fail/issue-19883.rs
src/test/compile-fail/issue-20005.rs
src/test/compile-fail/issue-3907-2.rs
src/test/compile-fail/issue-4517.rs
src/test/compile-fail/issue-4968.rs
src/test/compile-fail/issue-5035-2.rs
src/test/compile-fail/issue-5062.rs
src/test/compile-fail/issue-5239-1.rs
src/test/compile-fail/issue-5543.rs
src/test/compile-fail/issue-5883.rs
src/test/compile-fail/issue-6458-2.rs
src/test/compile-fail/issue-6596-1.rs [new file with mode: 0644]
src/test/compile-fail/issue-6596-2.rs [new file with mode: 0644]
src/test/compile-fail/issue-6596.rs [deleted file]
src/test/compile-fail/issue-7013.rs
src/test/compile-fail/issue-7364.rs
src/test/compile-fail/issue-7575.rs
src/test/compile-fail/issue-7867.rs
src/test/compile-fail/issue-8761.rs
src/test/compile-fail/issue-9575.rs
src/test/compile-fail/kindck-copy.rs
src/test/compile-fail/kindck-impl-type-params-2.rs
src/test/compile-fail/kindck-impl-type-params.rs
src/test/compile-fail/kindck-inherited-copy-bound.rs
src/test/compile-fail/kindck-nonsendable-1.rs
src/test/compile-fail/kindck-send-object.rs
src/test/compile-fail/kindck-send-object1.rs
src/test/compile-fail/kindck-send-object2.rs
src/test/compile-fail/kindck-send-unsafe.rs
src/test/compile-fail/linkage3.rs
src/test/compile-fail/lint-dead-code-4.rs
src/test/compile-fail/lint-uppercase-variables.rs
src/test/compile-fail/liveness-use-after-send.rs
src/test/compile-fail/macro-input-future-proofing.rs [new file with mode: 0644]
src/test/compile-fail/map-types.rs
src/test/compile-fail/marker-no-copy.rs
src/test/compile-fail/marker-no-send.rs
src/test/compile-fail/marker-no-share.rs
src/test/compile-fail/method-self-arg-1.rs
src/test/compile-fail/mut-not-freeze.rs
src/test/compile-fail/mut-pattern-mismatched.rs
src/test/compile-fail/mutable-enum-indirect.rs
src/test/compile-fail/no-send-res-ports.rs
src/test/compile-fail/no_send-enum.rs
src/test/compile-fail/no_send-rc.rs
src/test/compile-fail/no_send-struct.rs
src/test/compile-fail/no_share-enum.rs
src/test/compile-fail/no_share-rc.rs
src/test/compile-fail/no_share-struct.rs
src/test/compile-fail/noexporttypeexe.rs
src/test/compile-fail/noncopyable-class.rs
src/test/compile-fail/opt-out-copy-bad.rs
src/test/compile-fail/packed-struct-generic-transmute.rs
src/test/compile-fail/packed-struct-transmute.rs
src/test/compile-fail/pptypedef.rs
src/test/compile-fail/range-1.rs
src/test/compile-fail/regions-infer-contravariance-due-to-decl.rs
src/test/compile-fail/regions-infer-covariance-due-to-decl.rs
src/test/compile-fail/regions-infer-invariance-due-to-decl.rs
src/test/compile-fail/regions-infer-paramd-indirect.rs
src/test/compile-fail/repeat-to-run-dtor-twice.rs
src/test/compile-fail/repeat_count.rs
src/test/compile-fail/slice-1.rs
src/test/compile-fail/slice-2.rs
src/test/compile-fail/slice-borrow.rs
src/test/compile-fail/slice-mut-2.rs
src/test/compile-fail/slice-mut.rs
src/test/compile-fail/static-items-cant-move.rs
src/test/compile-fail/static-reference-to-fn-2.rs
src/test/compile-fail/str-idx.rs
src/test/compile-fail/structure-constructor-type-mismatch.rs
src/test/compile-fail/syntax-trait-polarity-feature-gate.rs
src/test/compile-fail/syntax-trait-polarity.rs
src/test/compile-fail/task-rng-isnt-sendable.rs
src/test/compile-fail/trait-bounds-impl-comparison-1.rs
src/test/compile-fail/trait-bounds-not-on-bare-trait.rs
src/test/compile-fail/trait-coercion-generic-bad.rs
src/test/compile-fail/trait-impl-1.rs
src/test/compile-fail/tuple-arity-mismatch.rs
src/test/compile-fail/tuple-index-out-of-bounds.rs
src/test/compile-fail/tutorial-suffix-inference-test.rs
src/test/compile-fail/type-mismatch-multiple.rs
src/test/compile-fail/typeck-unsafe-always-share.rs
src/test/compile-fail/typeck_type_placeholder_mismatch.rs
src/test/compile-fail/unboxed-closure-sugar-region.rs
src/test/compile-fail/unique-pinned-nocopy.rs
src/test/compile-fail/unique-unique-kind.rs
src/test/compile-fail/unique-vec-res.rs
src/test/compile-fail/unsendable-class.rs
src/test/compile-fail/unsized-bare-typaram.rs
src/test/compile-fail/unsized-enum.rs
src/test/compile-fail/unsized-struct.rs
src/test/compile-fail/unsized-trait-impl-trait-arg.rs
src/test/compile-fail/unsized3.rs
src/test/compile-fail/unsized5.rs
src/test/compile-fail/unsized6.rs
src/test/compile-fail/unsized7.rs
src/test/compile-fail/use-after-move-implicity-coerced-object.rs
src/test/compile-fail/variadic-ffi.rs
src/test/compile-fail/vec-res-add.rs
src/test/compile-fail/warn-foreign-int-types.rs
src/test/compile-fail/where-clause-constraints-are-local-for-inherent-impl.rs
src/test/compile-fail/where-clause-constraints-are-local-for-trait-impl.rs
src/test/compile-fail/where-clauses-not-parameter.rs
src/test/debuginfo/basic-types-globals-metadata.rs
src/test/debuginfo/basic-types-metadata.rs
src/test/debuginfo/gdb-pretty-struct-and-enums.rs
src/test/debuginfo/generic-struct.rs
src/test/debuginfo/option-like-enum.rs
src/test/debuginfo/type-names.rs
src/test/debuginfo/vec-slices.rs
src/test/pretty/issue-4264.pp
src/test/pretty/issue-4264.rs
src/test/run-fail/assert-as-macro.rs
src/test/run-fail/assert-eq-macro-panic.rs
src/test/run-fail/panic-task-name-none.rs
src/test/run-fail/panic-task-name-owned.rs
src/test/run-fail/panic.rs
src/test/run-fail/task-spawn-barefn.rs
src/test/run-make/graphviz-flowgraph/f01.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f03.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f04.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f05.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f07.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f08.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f09.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f09.rs
src/test/run-make/graphviz-flowgraph/f10.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f11.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f12.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f14.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f15.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f16.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f17.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f20.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f21.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f22.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f23.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot
src/test/run-make/graphviz-flowgraph/f25.dot-expected.dot
src/test/run-make/static-unwinding/main.rs
src/test/run-pass-fulldeps/issue-18763-quote-token-tree.rs
src/test/run-pass-fulldeps/plugin-args-1.rs [new file with mode: 0644]
src/test/run-pass-fulldeps/plugin-args-2.rs [new file with mode: 0644]
src/test/run-pass-fulldeps/plugin-args-3.rs [new file with mode: 0644]
src/test/run-pass-fulldeps/plugin-args-4.rs [new file with mode: 0644]
src/test/run-pass/associated-types-impl-redirect.rs
src/test/run-pass/associated-types-where-clause-impl-ambiguity.rs
src/test/run-pass/auto-encode.rs
src/test/run-pass/borrowck-mut-uniq.rs
src/test/run-pass/class-separate-impl.rs
src/test/run-pass/cleanup-rvalue-temp-during-incomplete-alloc.rs
src/test/run-pass/conditional-debug-macro-off.rs
src/test/run-pass/conditional-debug-macro-on.rs
src/test/run-pass/const-block.rs
src/test/run-pass/const-polymorphic-paths.rs
src/test/run-pass/core-run-destroy.rs
src/test/run-pass/deriving-encodable-decodable.rs
src/test/run-pass/deriving-in-fn.rs
src/test/run-pass/deriving-show-2.rs
src/test/run-pass/deriving-show.rs
src/test/run-pass/dst-index.rs
src/test/run-pass/enum-discrim-width-stuff.rs
src/test/run-pass/foreign-call-no-runtime.rs
src/test/run-pass/fsu-moves-and-copies.rs
src/test/run-pass/functional-struct-upd.rs
src/test/run-pass/hashmap-memory.rs
src/test/run-pass/hrtb-opt-in-copy.rs
src/test/run-pass/html-literals.rs
src/test/run-pass/ifmt.rs
src/test/run-pass/issue-10396.rs
src/test/run-pass/issue-10626.rs
src/test/run-pass/issue-11267.rs
src/test/run-pass/issue-12684.rs
src/test/run-pass/issue-12744.rs
src/test/run-pass/issue-13434.rs
src/test/run-pass/issue-13494.rs
src/test/run-pass/issue-15730.rs
src/test/run-pass/issue-16560.rs
src/test/run-pass/issue-16671.rs
src/test/run-pass/issue-1696.rs
src/test/run-pass/issue-17503.rs
src/test/run-pass/issue-17718-static-unsafe-interior.rs
src/test/run-pass/issue-19135.rs
src/test/run-pass/issue-19358.rs
src/test/run-pass/issue-20644.rs [new file with mode: 0644]
src/test/run-pass/issue-2190-1.rs
src/test/run-pass/issue-2718.rs
src/test/run-pass/issue-3109.rs
src/test/run-pass/issue-3556.rs
src/test/run-pass/issue-3559.rs
src/test/run-pass/issue-3563-3.rs
src/test/run-pass/issue-3743.rs
src/test/run-pass/issue-3794.rs
src/test/run-pass/issue-3888-2.rs
src/test/run-pass/issue-4252.rs
src/test/run-pass/issue-4446.rs
src/test/run-pass/issue-4448.rs
src/test/run-pass/issue-4464.rs
src/test/run-pass/issue-7563.rs
src/test/run-pass/issue-8460.rs
src/test/run-pass/issue-8827.rs
src/test/run-pass/issue-8898.rs
src/test/run-pass/log-knows-the-names-of-variants-in-std.rs
src/test/run-pass/log-knows-the-names-of-variants.rs
src/test/run-pass/log-poly.rs
src/test/run-pass/logging-only-prints-once.rs
src/test/run-pass/macro-with-braces-in-expr-position.rs
src/test/run-pass/method-recursive-blanket-impl.rs
src/test/run-pass/new-impl-syntax.rs
src/test/run-pass/no-landing-pads.rs
src/test/run-pass/nullable-pointer-iotareduction.rs
src/test/run-pass/out-of-stack-new-thread-no-split.rs
src/test/run-pass/overloaded-index-assoc-list.rs
src/test/run-pass/panic-in-dtor-drops-fields.rs
src/test/run-pass/plugin-args-1.rs [deleted file]
src/test/run-pass/plugin-args-2.rs [deleted file]
src/test/run-pass/plugin-args-3.rs [deleted file]
src/test/run-pass/plugin-args-4.rs [deleted file]
src/test/run-pass/rec-align-u32.rs
src/test/run-pass/rec-align-u64.rs
src/test/run-pass/regions-infer-bivariance.rs
src/test/run-pass/repeated-vector-syntax.rs
src/test/run-pass/resource-assign-is-not-copy.rs
src/test/run-pass/running-with-no-runtime.rs
src/test/run-pass/sendfn-spawn-with-fn-arg.rs
src/test/run-pass/sepcomp-unwind.rs
src/test/run-pass/show-boxed-slice.rs
src/test/run-pass/slice-2.rs
src/test/run-pass/slice-panic-1.rs
src/test/run-pass/slice-panic-2.rs
src/test/run-pass/slice.rs
src/test/run-pass/small-enums-with-fields.rs
src/test/run-pass/spawn-types.rs
src/test/run-pass/spawn.rs
src/test/run-pass/spawn2.rs
src/test/run-pass/spawning-with-debug.rs
src/test/run-pass/supported-cast.rs
src/test/run-pass/syntax-trait-polarity.rs
src/test/run-pass/tag-align-shape.rs
src/test/run-pass/tag-disr-val-shape.rs
src/test/run-pass/task-comm-1.rs
src/test/run-pass/task-comm-12.rs
src/test/run-pass/task-comm-13.rs
src/test/run-pass/task-comm-14.rs
src/test/run-pass/task-comm-17.rs
src/test/run-pass/task-comm-3.rs
src/test/run-pass/task-comm-9.rs
src/test/run-pass/task-stderr.rs
src/test/run-pass/tcp-accept-stress.rs
src/test/run-pass/tcp-stress.rs
src/test/run-pass/tempfile.rs
src/test/run-pass/terminate-in-initializer.rs
src/test/run-pass/threads.rs
src/test/run-pass/trivial-message.rs
src/test/run-pass/tuple-struct-construct.rs
src/test/run-pass/tydesc-name.rs
src/test/run-pass/unique-send-2.rs
src/test/run-pass/unit-like-struct-drop-run.rs
src/test/run-pass/vector-sort-panic-safe.rs
src/test/run-pass/where-clauses-not-parameter.rs [deleted file]
src/test/run-pass/yield.rs
src/test/run-pass/yield1.rs

index 9aa09ac1763561e527850a0781c2bb4852fb6b06..bc8dbc878baa3a0f59f3a5276866d2e726ecd990 100644 (file)
@@ -1,17 +1,25 @@
 Rust was written by these fine people:
 
+A.J. Gardner <mrhota@users.noreply.github.com>
+Aaron Friel <mayreply@aaronfriel.com>
 Aaron Laursen <aaronlaursen@gmail.com>
+Aaron Liblong <liblonga@physics.utoronto.ca>
 Aaron Raimist <aaron@aaronraimist.com>
 Aaron Todd <github@opprobrio.us>
 Aaron Turon <aturon@mozilla.com>
+Aaron Weiss <aaronweiss74@gmail.com>
 Adam Bozanich <adam.boz@gmail.com>
+Adam Szkoda <adaszko@gmail.com>
 Adolfo Ochagavía <aochagavia92@gmail.com>
 Adrien Brault <adrien.brault@gmail.com>
 Adrien Tétar <adri-from-59@hotmail.fr>
 Ahmed Charles <ahmedcharles@gmail.com>
+Aidan Cully <github@aidan.users.panix.com>
+Akos Kiss <akiss@inf.u-szeged.hu>
 Alan Andrade <alan.andradec@gmail.com>
 Alan Williams <mralert@gmail.com>
 Aleksander Balicki <balicki.aleksander@gmail.com>
+Aleksandr Koshlo <sash7ko@gmail.com>
 Alex Crichton <alex@alexcrichton.com>
 Alex Gaynor <alex.gaynor@gmail.com>
 Alex Lyon <arcterus@mail.com>
@@ -30,55 +38,62 @@ Aljaž "g5pw" Srebrnič <a2piratesoft@gmail.com>
 Amy Unger <amy.e.unger@gmail.com>
 Anders Kaseorg <andersk@mit.edu>
 Andre Arko <andre@arko.net>
+Andrea Canciani <ranma42@gmail.com>
 Andreas Gal <gal@mozilla.com>
 Andreas Martens <andreasm@fastmail.fm>
 Andreas Neuhaus <zargony@zargony.com>
 Andreas Ots <andreasots@gmail.com>
 Andreas Tolfsen <ato@mozilla.com>
 Andrei Formiga <archimedes_siracusa@hotmail.com>
+Andrew Cann <shum@canndrew.org>
 Andrew Chin <achin@eminence32.net>
 Andrew Dunham <andrew@du.nham.ca>
 Andrew Gallant <jamslam@gmail.com>
 Andrew Paseltiner <apaseltiner@gmail.com>
 Andrew Poelstra <asp11@sfu.ca>
+Andrew Wagner <drewm1980@gmail.com>
 Angus Lees <gus@inodes.org>
 Anthony Juckel <ajuckel@gmail.com>
-Anton Lofgren <alofgren@op5.com>
 Anton Löfgren <anton.lofgren@gmail.com>
 Arcterus <Arcterus@mail.com>
-Ariel Ben-Yehuda <arielb1@mail.tau.ac.il>
+Ariel Ben-Yehuda <ariel.byd@gmail.com>
 Arjan Topolovec <arjan.top@gmail.com>
 Arkaitz Jimenez <arkaitzj@gmail.com>
 Armin Ronacher <armin.ronacher@active-4.com>
 Arpad Borsos <arpad.borsos@googlemail.com>
+Artem <artemciy@gmail.com>
+Arthur Liao <arthurtw8@gmail.com>
 Ashok Gautham <ScriptDevil@gmail.com>
 Austin Bonander <austin.bonander@gmail.com>
 Austin King <shout@ozten.com>
 Austin Seipp <mad.one@gmail.com>
 Axel Viala <axel.viala@darnuria.eu>
 Aydin Kim <ladinjin@hanmail.net>
+Barosl Lee <vcs@barosl.com>
 Ben Alpert <ben@benalpert.com>
 Ben Blum <bblum@andrew.cmu.edu>
+Ben Foppa <benjamin.foppa@gmail.com>
 Ben Gamari <bgamari.foss@gmail.com>
 Ben Harris <mail@bharr.is>
 Ben Kelly <ben@wanderview.com>
 Ben Noordhuis <info@bnoordhuis.nl>
+Ben S <ogham@bsago.me>
 Ben Striegel <ben.striegel@gmail.com>
 Benjamin Adamson <adamson.benjamin@gmail.com>
 Benjamin Herr <ben@0x539.de>
 Benjamin Jackman <ben@jackman.biz>
 Benjamin Kircher <benjamin.kircher@gmail.com>
 Benjamin Peterson <benjamin@python.org>
-Bheesham Persaud <bheesham.persaud@live.ca>
+Bheesham Persaud <bheesham123@hotmail.com>
 Bilal Husain <bilal@bilalhusain.com>
 Bill Fallon <bill.fallon@robos.li>
 Bill Myers <bill_myers@outlook.com>
 Bill Wendling <wendling@apple.com>
 Birunthan Mohanathas <birunthan@mohanathas.com>
 Björn Steinbrink <bsteinbr@gmail.com>
-Boris Egorov <jightuse@gmail.com>
+Boris Egorov <egorov@linux.com>
 Bouke van der Bijl <boukevanderbijl@gmail.com>
-Brandon Sanderson <singingboyo@hotmail.com>
+Brandon Sanderson <singingboyo@gmail.com>
 Brandon Waskiewicz <brandon.waskiewicz@gmail.com>
 Branimir <branimir@volomp.com>
 Brendan Cully <brendan@kublai.com>
@@ -88,6 +103,7 @@ Brendan Zabarauskas <bjzaba@yahoo.com.au>
 Brett Cannon <brett@python.org>
 Brian Anderson <banderson@mozilla.com>
 Brian Dawn <brian.t.dawn@gmail.com>
+Brian J Brennan <brianloveswords@gmail.com>
 Brian J. Burg <burg@cs.washington.edu>
 Brian Koropoff <bkoropoff@gmail.com>
 Brian Leibig <brian.leibig@gmail.com>
@@ -99,9 +115,10 @@ Caitlin Potter <snowball@defpixel.com>
 Cameron Zwarich <zwarich@mozilla.com>
 Carl-Anton Ingmarsson <mail@carlanton.se>
 Carlos <toqueteos@gmail.com>
-Carol Nichols <carol.nichols@gmail.com>
+Carol Nichols <cnichols@thinkthroughmath.com>
 Carol Willing <carolcode@willingconsulting.com>
 Carter Tazio Schonwald <carter.schonwald@gmail.com>
+Chase Southwood <chase.southwood@gmail.com>
 Chris Double <chris.double@double.co.nz>
 Chris Morgan <me@chrismorgan.info>
 Chris Nixon <chris.nixon@sigma.me.uk>
@@ -116,6 +133,7 @@ Christopher Kendell <ckendell@outlook.com>
 Chuck Ries <chuck.ries@gmail.com>
 Clark Gaebel <cg.wowus.cg@gmail.com>
 Clinton Ryan <clint.ryan3@gmail.com>
+Cody P Schafer <dev@codyps.com>
 Cody Schroeder <codys@cs.washington.edu>
 Cole Mickens <cole.mickens@gmail.com>
 Colin Davidson <colrdavidson@gmail.com>
@@ -124,6 +142,7 @@ Conrad Kleinespel <conradk@conradk.com>
 Corey Farwell <coreyf+rust@rwell.org>
 Corey Ford <corey@coreyford.name>
 Corey Richardson <corey@octayn.net>
+Cristi Burcă <scribu@gmail.com>
 DJUrsus <colinvh@divitu.com>
 Damian Gryski <damian@gryski.com>
 Damien Grassart <damien@grassart.com>
@@ -159,9 +178,11 @@ Derecho <derecho@sector5d.org>
 Derek Chiang <derekchiang93@gmail.com>
 Derek Guenther <dguenther9@gmail.com>
 Derek Harland <derek.harland@finq.co.nz>
+Diego Giagio <diego@giagio.com>
 Diego Ongaro <ongaro@cs.stanford.edu>
 Diggory Hardy <diggory.hardy@gmail.com>
 Dimitri Krassovski <labria@startika.com>
+Dirk Gadsden <dirk@esherido.com>
 Dirk Leifeld <leifeld@posteo.de>
 Dirkjan Bussink <d.bussink@gmail.com>
 Div Shekhar <div@pagerduty.com>
@@ -174,6 +195,7 @@ Douglas Young <rcxdude@gmail.com>
 Drew Willcoxon <adw@mozilla.com>
 Dylan Braithwaite <dylanbraithwaite1@gmail.com>
 Dzmitry Malyshau <kvarkus@gmail.com>
+Earl St Sauver <estsauver@gmail.com>
 Eduard Bopp <eduard.bopp@aepsil0n.de>
 Eduard Burtescu <edy.burt@gmail.com>
 Eduardo Bautista <me@eduardobautista.com>
@@ -183,15 +205,18 @@ Ehsanul Hoque <ehsanul@ehsanul.com>
 Elliott Slaughter <elliottslaughter@gmail.com>
 Elly Fong-Jones <elly@leptoquark.net>
 Emanuel Rylke <ema-fox@web.de>
+Eric Allen <ericpallen@gmail.com>
 Eric Biggers <ebiggers3@gmail.com>
 Eric Holk <eric.holk@gmail.com>
 Eric Holmes <eric@ejholmes.net>
+Eric Kidd <git@randomhacks.net>
 Eric Martin <e.a.martin1337@gmail.com>
 Eric Reed <ecreed@cs.washington.edu>
 Erick Tryzelaar <erick.tryzelaar@gmail.com>
 Erik Lyon <elyon001@local.fake>
 Erik Price <erik.price16@gmail.com>
 Erik Rose <erik@mozilla.com>
+Erwan <erwan.ricq@gmail.com>
 Etienne Millon <me@emillon.org>
 Eunchong Yu <kroisse@gmail.com>
 Evan Klitzke <evan@eklitzke.org>
@@ -199,6 +224,7 @@ Evan McClanahan <evan@evanmcc.com>
 Evgeny Sologubov
 Fabian Deutsch <fabian.deutsch@gmx.de>
 Fabrice Desré <fabrice@desre.org>
+FakeKane <andrewyli@gmail.com>
 Falco Hirschenberger <falco.hirschenberger@gmail.com>
 Fedor Indutny <fedor.indutny@gmail.com>
 Felix Crux <felixc@felixcrux.com>
@@ -209,6 +235,7 @@ Flavio Percoco <flaper87@gmail.com>
 Florian Gilcher <florian.gilcher@asquera.de>
 Florian Hahn <flo@fhahn.com>
 Florian Hartwig <florian.j.hartwig@gmail.com>
+Florian Wilkens <floya@live.de>
 Florian Zeitz <florob@babelmonkeys.de>
 Francisco Souza <f@souza.cc>
 Franklin Chen <franklinchen@franklinchen.com>
@@ -221,10 +248,12 @@ Geoff Hill <geoff@geoffhill.org>
 Geoffroy Couprie <geo.couprie@gmail.com>
 George Papanikolaou <g3orge.app@gmail.com>
 Georges Dubus <georges.dubus@gmail.com>
+Gil Cottle <rc@redtown.org>
 Gioele Barabucci <gioele@svario.it>
+Gleb Kozyrev <gleb@gkoz.com>
 Glenn Willen <gwillen@nerdnet.org>
 Gonçalo Cabrita <_@gmcabrita.com>
-Graham Fawcett <fawcett@uwindsor.ca>
+Graham Fawcett <graham.fawcett@gmail.com>
 Grahame Bowland <grahame@angrygoats.net>
 Graydon Hoare <graydon@mozilla.com>
 Grigoriy <ohaistarlight@gmail.com>
@@ -242,6 +271,7 @@ Hong Chulju <ang0123dev@gmail.com>
 Honza Strnad <hanny.strnad@gmail.com>
 Hugo Jobling <hello@thisishugo.com>
 Huon Wilson <dbau.pp+github@gmail.com>
+Ian Connolly <iconnolly@mozilla.com>
 Ian D. Bollinger <ian.bollinger@gmail.com>
 Ian Daniher <it.daniher@gmail.com>
 Igor Bukanov <igor@mir2.org>
@@ -251,31 +281,39 @@ Isaac Aggrey <isaac.aggrey@gmail.com>
 Isaac Dupree <antispam@idupree.com>
 Ivan Enderlin <ivan.enderlin@hoa-project.net>
 Ivan Petkov <ivanppetkov@gmail.com>
+Ivan Ukhov <ivan.ukhov@gmail.com>
 Ivano Coppola <rgbfirefox@gmail.com>
 J. J. Weber <jjweber@gmail.com>
 J.C. Moyer <jmoyer1992@gmail.com>
+JONNALAGADDA Srinivas <js@ojuslabs.com>
 Jack Heizer <jack.heizer@gmail.com>
 Jack Moffitt <jack@metajack.im>
+Jacob Edelman <edelman.jd@gmail.com>
 Jacob Harris Cryer Kragh <jhckragh@gmail.com>
 Jacob Hegna <jacobhegna@gmail.com>
 Jacob Parker <j3parker@csclub.uwaterloo.ca>
 Jaemin Moon <jaemin.moon@samsung.com>
 Jag Talon <talon.jag@gmail.com>
+Jake Goulding <jake.goulding@gmail.com>
 Jake Kaufman <theevocater@gmail.com>
 Jake Kerr <kodafox@gmail.com>
 Jake Scott <jake.net@gmail.com>
+Jakub Bukaj <jakub@jakub.cc>
 Jakub Wieczorek <jakubw@jakubw.net>
 James Deng <cnjamesdeng@gmail.com>
 James Hurst <jamesrhurst@users.noreply.github.com>
 James Lal <james@lightsofapollo.com>
 James Laverack <james@jameslaverack.com>
-James Miller <bladeon@gmail.com>
+James Miller <james@aatch.net>
 James Rowe <jroweboy@gmail.com>
 James Sanders <sanderjd@gmail.com>
 James Tranovich <james@openhorizonlabs.com>
 Jan Kobler <eng1@koblersystems.de>
 Jan Niklas Hasse <jhasse@gmail.com>
 Jannis Harder <jix@jixco.de>
+Jared Roesch <roeschinc@gmail.com>
+Jarod Liu <liuyuanzhi@gmail.com>
+Jashank Jeremy <jashank@rulingia.com>
 Jason Fager <jfager@gmail.com>
 Jason Orendorff <jorendorff@mozilla.com>
 Jason Thompson <jason@jthompson.ca>
@@ -287,7 +325,9 @@ Jed Estep <aje@jhu.edu>
 Jeff Balogh <jbalogh@mozilla.com>
 Jeff Muizelaar <jmuizelaar@mozilla.com>
 Jeff Olson <olson.jeffery@gmail.com>
+Jeff Parsons <jeffdougson@gmail.com>
 Jeffrey Yasskin <jyasskin@gmail.com>
+Jelte Fennema <github-tech@jeltef.nl>
 Jens Nockert <jens@nockert.se>
 Jeong YunWon <jeong@youknowone.org>
 Jeremy Letang <letang.jeremy@gmail.com>
@@ -296,6 +336,7 @@ Jesse Luehrs <doy@tozt.net>
 Jesse Ray <jesse@localhost.localdomain>
 Jesse Ruderman <jruderman@gmail.com>
 Jihyun Yu <jihyun@nclab.kaist.ac.kr>
+Jim Apple <jbapple+rust@google.com>
 Jim Blandy <jimb@red-bean.com>
 Jim Radford <radford@blackbean.org>
 Jimmie Elvenmark <flugsio@gmail.com>
@@ -303,16 +344,20 @@ Jimmy Lu <jimmy.lu.2011@gmail.com>
 Jimmy Zelinskie <jimmyzelinskie@gmail.com>
 Joe Pletcher <joepletcher@gmail.com>
 Joe Schafer <joe@jschaf.com>
+Johannes Hoff <johshoff@gmail.com>
 Johannes Löthberg <johannes@kyriasis.com>
 Johannes Muenzel <jmuenzel@gmail.com>
+John Albietz <inthecloud247@gmail.com>
 John Barker <jebarker@gmail.com>
 John Clements <clements@racket-lang.org>
 John Fresco <john.fresco@utah.edu>
 John Gallagher <jgallagher@bignerdranch.com>
+John Kleint <jk@hinge.co>
 John Kåre Alsaker <john.kare.alsaker@gmail.com>
 John Louis Walker <injyuw@gmail.com>
 John Schmidt <john.schmidt.h@gmail.com>
 John Simon <john@johnsoft.com>
+Jon Haddad <jon@jonhaddad.com>
 Jon Morton <jonanin@gmail.com>
 Jonas Hietala <tradet.h@gmail.com>
 Jonathan Bailey <jbailey@mozilla.com>
@@ -320,12 +365,16 @@ Jonathan Boyett <jonathan@failingservers.com>
 Jonathan Reem <jonathan.reem@gmail.com>
 Jonathan S <gereeter@gmail.com>
 Jonathan Sternberg <jonathansternberg@gmail.com>
+Joonas Javanainen <joonas.javanainen@gmail.com>
 Jordi Boggiano <j.boggiano@seld.be>
-Jorge Aparicio <japaric@linux.com>
+Jorge Aparicio <japaricious@gmail.com>
 Joris Rehm <joris.rehm@wakusei.fr>
 Joseph Crail <jbcrail@gmail.com>
 Joseph Martin <pythoner6@gmail.com>
+Joseph Rushton Wakeling <joe@webdrake.net>
+Josh Haberman <jhaberman@gmail.com>
 Josh Matthews <josh@joshmatthews.net>
+Josh Stone <cuviper@gmail.com>
 Joshua Clark <joshua.clark@txstate.edu>
 Joshua Wise <joshua@joshuawise.com>
 Joshua Yanovski <pythonesque@gmail.com>
@@ -336,9 +385,11 @@ JustAPerson <jpriest8@ymail.com>
 Justin Noah <justinnoah@gmail.com>
 Jyun-Yan You <jyyou.tw@gmail.com>
 Kang Seonghoon <kang.seonghoon@mearie.org>
+Kang Seonghoon <public+git@mearie.org>
 Kasey Carrothers <kaseyc.808@gmail.com>
 Keegan McAllister <kmcallister@mozilla.com>
 Kelly Wilson <wilsonk@cpsc.ucalgary.ca>
+Ken Tossell <ken@tossell.net>
 Keshav Kini <keshav.kini@gmail.com>
 Kevin Atkinson <kevina@cs.utah.edu>
 Kevin Ballard <kevin@sb.org>
@@ -347,9 +398,11 @@ Kevin Cantu <me@kevincantu.org>
 Kevin Mehall <km@kevinmehall.net>
 Kevin Murphy <kemurphy.cmu@gmail.com>
 Kevin Walter <kevin.walter.private@googlemail.com>
+Kevin Yap <me@kevinyap.ca>
 Kiet Tran <ktt3ja@gmail.com>
 Kyeongwoon Lee <kyeongwoon.lee@samsung.com>
 Lars Bergstrom <lbergstrom@mozilla.com>
+Laurence Tratt <laurie@tratt.net>
 Laurent Bonnans <bonnans.l@gmail.com>
 Lawrence Velázquez <larryv@alum.mit.edu>
 Leah Hanson <astrieanna@gmail.com>
@@ -359,8 +412,10 @@ Lennart Kudling <github@kudling.de>
 Léo Testard <leo.testard@gmail.com>
 Liigo Zhuang <com.liigo@gmail.com>
 Lindsey Kuper <lindsey@composition.al>
+Lionel Flandrin <lionel.flandrin@parrot.com>
 Luca Bruno <lucab@debian.org>
 Luis de Bethencourt <luis@debethencourt.com>
+Luke Metz <luke.metz@students.olin.edu>
 Luqman Aden <me@luqman.ca>
 Magnus Auvinen <magnus.auvinen@gmail.com>
 Mahmut Bulut <mahmutbulut0@gmail.com>
@@ -373,17 +428,23 @@ Mark Lacey <641@rudkx.com>
 Mark Rowe <mrowe@bdash.net.nz>
 Mark Sinclair <mark.edward.x@gmail.com>
 Mark Vian <mrv.caseus@gmail.com>
+Markus Siemens <siemens1993@gmail.com>
 Markus Unterwaditzer <markus@unterwaditzer.net>
 Marti Raudsepp <marti@juffo.org>
 Martin DeMello <martindemello@gmail.com>
 Martin Olsson <martin@minimum.se>
+Martin Pool <mbp@sourcefrog.net>
 Marvin Löbel <loebel.marvin@gmail.com>
 Matej Lach <matej.lach@gmail.com>
 Mateusz Czapliński <czapkofan@gmail.com>
+Mathieu Poumeyrol <kali@zoy.org>
 Mathijs van de Nes <git@mathijs.vd-nes.nl>
 Matt Brubeck <mbrubeck@limpet.net>
 Matt Carberry <carberry.matt@gmail.com>
 Matt Coffin <mcoffin13@gmail.com>
+Matt McPherrin <git@mcpherrin.ca>
+Matt Murphy <matthew.john.murphy@gmail.com>
+Matt Windsor <mattwindsor@btinternet.com>
 Matthew Auld <matthew.auld@intel.com>
 Matthew Iselin <matthew@theiselins.net>
 Matthew McPherrin <matthew@mcpherrin.ca>
@@ -393,6 +454,9 @@ Matthijs Hofstra <thiezz@gmail.com>
 Matthijs van der Vleuten <git@zr40.nl>
 Max Penet <max.penet@gmail.com>
 Maxim Kolganov <kolganov.mv@gmail.com>
+Maxime Quandalle <maxime@quandalle.com>
+Maximilian Haack <mxhaack@gmail.com>
+Maya Nitu <maya_nitu@yahoo.com>
 Meyer S. Jacobs <meyermagic@gmail.com>
 Micah Chalmer <micah@micahchalmer.net>
 Michael Arntzenius <daekharel@gmail.com>
@@ -400,6 +464,7 @@ Michael Bebenita <mbebenita@mozilla.com>
 Michael Dagitses <dagitses@google.com>
 Michael Darakananda <pongad@gmail.com>
 Michael Fairley <michaelfairley@gmail.com>
+Michael Gehring <mg@ebfe.org>
 Michael Kainer <kaini1123@gmail.com>
 Michael Letterle <michael.letterle@gmail.com>
 Michael Matuzak <mmatuzak@gmail.com>
@@ -415,19 +480,28 @@ Mick Koch <kchmck@gmail.com>
 Mickaël Delahaye <mickael.delahaye@gmail.com>
 Mihnea Dobrescu-Balaur <mihnea@linux.com>
 Mike Boutin <mike.boutin@gmail.com>
+Mike Dilger <mike@efx.co.nz>
+Mike Pedersen <noctune9@gmail.com>
 Mike Robinson <mikeprobinsonuk@gmail.com>
 Mikko Perttunen <cyndis@kapsi.fi>
 Ms2ger <ms2ger@gmail.com>
 Mukilan Thiagarajan <mukilanthiagarajan@gmail.com>
+Mukilan Thiyagarajan <mukilanthiagarajan@gmail.com>
+Murarth <murarth@gmail.com>
 NODA, Kai <nodakai@gmail.com>
+Nafis <nhoss2@gmail.com>
 Nathan Froyd <froydnj@gmail.com>
 Nathan Typanski <ntypanski@gmail.com>
+Nathan Zadoks <nathan@nathan7.eu>
 Nathaniel Herman <nherman@college.harvard.edu>
+Neil Pankey <npankey@gmail.com>
 NiccosSystem <niccossystem@gmail.com>
+Nicholas Bishop <nicholasbishop@gmail.com>
 Nick Cameron <ncameron@mozilla.com>
 Nick Desaulniers <ndesaulniers@mozilla.com>
 Nick Howell <howellnick@gmail.com>
 Nicolas Silva <nical.silva@gmail.com>
+Niels Egberts <git@nielsegberts.nl>
 Niels langager Ellegaard <niels.ellegaard@gmail.com>
 Nif Ward <nif.ward@gmail.com>
 Nikita Pekin <contact@nikitapek.in>
@@ -437,6 +511,7 @@ Noam Yorav-Raphael <noamraph@gmail.com>
 Noufal Ibrahim <noufal@nibrahim.net.in>
 O S K Chaitanya <osk@medhas.org>
 OGINO Masanori <masanori.ogino@gmail.com>
+Oliver Schneider <oliver.schneider@kit.edu>
 Olivier Saut <osaut@airpost.net>
 Olle Jonsson <olle.jonsson@gmail.com>
 Or Brostovski <tohava@gmail.com>
@@ -446,28 +521,33 @@ P1start <rewi-github@whanau.org>
 Pablo Brasero <pablo@pablobm.com>
 Palmer Cox <p@lmercox.com>
 Paolo Falabella <paolo.falabella@gmail.com>
+Pascal Hertleif <killercup@gmail.com>
 Patrick Reisert <kpreisert@gmail.com>
 Patrick Walton <pcwalton@mimiga.net>
 Patrick Yevsukov <patrickyevsukov@users.noreply.github.com>
 Patrik Kårlin <patrik.karlin@gmail.com>
-Paul Collins <paul@ondioline.org>
+Paul Collier <paul@paulcollier.ca>
 Paul Stansifer <paul.stansifer@gmail.com>
 Paul Woolcock <pwoolcoc+github@gmail.com>
 Pavel Panchekha <me@pavpanchekha.com>
 Pawel Olzacki <p.olzacki2@samsung.com>
+Pedro Larroy <pedro.larroy@here.com>
 Peer Aramillo Irizar <peer.aramillo.irizar@gmail.com>
 Peter Atashian <retep998@gmail.com>
+Peter Elmers <peter.elmers@yahoo.com>
 Peter Hull <peterhull90@gmail.com>
 Peter Marheine <peter@taricorp.net>
 Peter Williams <peter@newton.cx>
 Peter Zotov <whitequark@whitequark.org>
 Petter Remen <petter.remen@gmail.com>
-Phil Dawes <phil@phildawes.net>
+Phil Dawes <pdawes@drw.com>
 Phil Ruffwind <rf@rufflewind.com>
+Philip Munksgaard <pmunksgaard@gmail.com>
 Philipp Brüschweiler <blei42@gmail.com>
 Philipp Gesang <phg42.2a@gmail.com>
 Piotr Czarnecki <pioczarn@gmail.com>
 Piotr Jawniak <sawyer47@gmail.com>
+Piotr Szotkowski <chastell@chastell.net>
 Piotr Zolnierek <pz@anixe.pl>
 Pradeep Kumar <gohanpra@gmail.com>
 Prudhvi Krishna Surapaneni <me@prudhvi.net>
@@ -480,6 +560,7 @@ Ramkumar Ramachandra <artagnon@gmail.com>
 Randati <anttivan@gmail.com>
 Raphael Catolino <raphael.catolino@gmail.com>
 Raphael Speyer <rspeyer@gmail.com>
+Ray Clanan <rclanan@utopianconcept.com>
 Reilly Watson <reillywatson@gmail.com>
 Renato Riccieri Santos Zannon <renato@rrsz.com.br>
 Renato Zannon <renato@rrsz.com.br>
@@ -489,6 +570,7 @@ Rich Lane <rlane@club.cc.cmu.edu>
 Richard Diamond <wichard@vitalitystudios.com>
 Richo Healey <richo@psych0tik.net>
 Rick Waldron <waldron.rick@gmail.com>
+Ricky Taylor <rickytaylor26@gmail.com>
 Rob Arnold <robarnold@cs.cmu.edu>
 Rob Hoelz <rob@hoelz.ro>
 Robert Buonpastore <robert.buonpastore@gmail.com>
@@ -497,9 +579,14 @@ Robert Gawdzik <rgawdzik@hotmail.com>
 Robert Irelan <rirelan@gmail.com>
 Robert Knight <robertknight@gmail.com>
 Robert Millar <robert.millar@cantab.net>
+Robin Gloster <robin@loc-com.de>
+Robin Stocker <robin@nibor.org>
+Rohit Joshi <rohit.joshi@capitalone.com>
 Roland Tanglao <roland@rolandtanglao.com>
-Rolf Timmermans <r.w.timmermans@gmail.com>
+Rolf Timmermans <rolftimmermans@voormedia.com>
+Rolf van de Krol <info@rolfvandekrol.nl>
 Ron Dahlgren <ronald.dahlgren@gmail.com>
+Roy Crihfield <rscrihf@gmail.com>
 Roy Frostig <rfrostig@mozilla.com>
 Russell <rpjohnst@gmail.com>
 Ruud van Asseldonk <dev@veniogames.com>
@@ -520,10 +607,13 @@ Saurabh Anand <saurabhanandiit@gmail.com>
 Scott Jenkins <scottdjwales@gmail.com>
 Scott Lawrence <bytbox@gmail.com>
 Sean Chalmers <sclhiannan@gmail.com>
+Sean Collins <sean@cllns.com>
 Sean Gillespie <sean.william.g@gmail.com>
+Sean Jensen-Grey <seanj@xyke.com>
 Sean McArthur <sean.monstar@gmail.com>
 Sean Moon <ssamoon@ucla.edu>
 Sean Stangl <sstangl@mozilla.com>
+Sean T Allen <sean@monkeysnatchbanana.com>
 Sebastian N. Fernandez <cachobot@gmail.com>
 Sebastian Zaha <sebastian.zaha@gmail.com>
 Sebastien Martini <seb@dbzteam.org>
@@ -531,12 +621,17 @@ Seo Sanghyeon <sanxiyn@gmail.com>
 Seonghyun Kim <sh8281.kim@samsung.com>
 Sergio Benitez <sbenitez@mit.edu>
 Seth Pink <sethpink@gmail.com>
+Seth Pollack <sethpollack@users.noreply.github.com>
 Shamir Khodzha <khodzha.sh@gmail.com>
 SiegeLord <slabode@aim.com>
 Simon Barber-Dueck <sbarberdueck@gmail.com>
 Simon Persson <simon@flaskpost.org>
-Simon Sapin <simon@exyr.org>
+Simon Sapin <simon.sapin@exyr.org>
+Simon Wollwage <mail.wollwage@gmail.com>
+Simonas Kazlauskas <git@kazlauskas.me>
+Son <leson.phung@gmail.com>
 Squeaky <squeaky_pl@gmx.com>
+Stefan Bucur <stefan.bucur@epfl.ch>
 Stefan Plantikow <stefan.plantikow@googlemail.com>
 Stepan Koltsov <stepan.koltsov@gmail.com>
 Sterling Greene <sterling.greene@gmail.com>
@@ -546,12 +641,15 @@ Steven Fackler <sfackler@gmail.com>
 Steven Sheldon <steven@sasheldon.com>
 Steven Stewart-Gallus <sstewartgallus00@langara.bc.ca>
 Strahinja Val Markovic <val@markovic.io>
-Stuart Pernsteiner <spernsteiner@mozilla.com>
+Stuart Pernsteiner <stuart@pernsteiner.org>
+Subhash Bhushan <subhash.bhushan@kaybus.com>
 Sylvestre Ledru <sylvestre@debian.org>
 Sébastien Chauvel <eichi237@mailoo.org>
 Sébastien Crozet <developer@crozet.re>
 Sébastien Paolacci <sebastien.paolacci@gmail.com>
+Tamir Duberstein <tamird@squareup.com>
 Taras Shpot <mrshpot@gmail.com>
+Taylor Hutchison <seanthutchison@gmail.com>
 Ted Horst <ted.horst@earthlink.net>
 Thad Guidry <thadguidry@gmail.com>
 Thomas Backman <serenity@exscape.org>
@@ -562,7 +660,9 @@ Tim Chevalier <chevalier@alum.wellesley.edu>
 Tim Joseph Dumol <tim@timdumol.com>
 Tim Kuehn <tkuehn@cmu.edu>
 Tim Taubert <tim@timtaubert.de>
+Timon Rapp <timon@zaeda.net>
 Timothée Ravier <tim@siosm.fr>
+Titouan Vervack <tivervac@gmail.com>
 Tobba <tobias.haegermarck@gmail.com>
 Tobias Bucher <tobiasbucher5991@gmail.com>
 Tohava <tohava@tohava-laptop.(none)>
@@ -581,27 +681,35 @@ TyOverby <ty@pre-alpha.com>
 Tycho Sci <tychosci@gmail.com>
 Tyler Bindon <martica@martica.org>
 U-NOV2010\eugals
+Ulysse Carion <ulysse@ulysse.io>
 Utkarsh Kukreti <utkarshkukreti@gmail.com>
 Uwe Dauernheim <uwe@dauernheim.net>
 Vadim Chugunov <vadimcn@gmail.com>
+Vadim Petrochenkov <vadim.petrochenkov@gmail.com>
 Valentin Tsatskin <vtsatskin@mozilla.com>
 Valerii Hiora <valerii.hiora@gmail.com>
 Victor Berger <victor.berger@m4x.org>
+Victor van den Elzen <victor.vde@gmail.com>
 Vijay Korapaty <rust@korapaty.com>
 Viktor Dahl <pazaconyoman@gmail.com>
 Vincent Belliard <vincent@famillebelliard.fr>
 Vinzent Steinberg <Vinzent.Steinberg@gmail.com>
 Virgile Andreani <virgile.andreani@anbuco.fr>
+Vitali Haravy <HumaneProgrammer@gmail.com>
 Vivek Galatage <vivekgalatage@gmail.com>
+Vladimir Matveev <vladimir.matweev@gmail.com>
 Vladimir Pouzanov <farcaller@gmail.com>
+Vladimir Smola <smola.vladimir@gmail.com>
 Volker Mische <volker.mische@gmail.com>
 Wade Mealing <wmealing@gmail.com>
 WebeWizard <webewizard@gmail.com>
 Wendell Smith <wendell.smith@yale.edu>
 William Ting <io@williamting.com>
 Yasuhiro Fujii <y-fujii@mimosa-pudica.net>
+YawarRaza7349 <YawarRaza7349@gmail.com>
 Yazhong Liu <yorkiefixer@gmail.com>
 Yehuda Katz <wycats@gmail.com>
+York Xiang <bombless@126.com>
 Young-il Choi <duddlf.choi@samsung.com>
 Youngmin Yoo <youngmin.yoo@samsung.com>
 Youngsoo Son <ysson83@gmail.com>
@@ -611,22 +719,29 @@ Zach Kamsler <smoo.master@gmail.com>
 Zach Pomerantz <zmp@umich.edu>
 Zack Corr <zack@z0w0.me>
 Zack Slayton <zack.slayton@gmail.com>
-Zbigniew Siciarz <antyqjon@gmail.com>
+Zbigniew Siciarz <zbigniew@siciarz.net>
 Ziad Hatahet <hatahet@gmail.com>
 Zooko Wilcox-O'Hearn <zooko@zooko.com>
 aochagavia <aochagavia92@gmail.com>
+areski <areski@gmail.com>
+arturo <arturo@openframeworks.cc>
 auREAX <mark@xn--hwg34fba.ws>
 b1nd <clint.ryan3@gmail.com>
 bachm <Ab@vapor.com>
 blake2-ppc <ulrik.sverdrup@gmail.com>
+bluss <bluss>
+bombless <bombless@126.com>
 bors <bors@rust-lang.org>
 chitra
 chromatic <chromatic@wgz.org>
 comex <comexk@gmail.com>
+crhino <piraino.chris@gmail.com>
+dan@daramos.com <dan@daramos.com>
 darkf <lw9k123@gmail.com>
 dgoon <dgoon@dgoon.net>
 donkopotamus <general@chocolate-fish.com>
 eliovir <eliovir@gmail.com>
+elszben <notgonna@tellyou>
 flo-l <lacknerflo@gmail.com>
 fort <e@mail.com>
 free-Runner <aali07@students.poly.edu>
@@ -638,10 +753,17 @@ hansjorg <hansjorg@gmail.com>
 iancormac84 <wilnathan@gmail.com>
 inrustwetrust <inrustwetrust@users.noreply.github.com>
 jamesluke <jamesluke@users.noreply.github.com>
+jbranchaud <jbranchaud@gmail.com>
+jfager <jfager@gmail.com>
 jmgrosen <jmgrosen@gmail.com>
+jmu303 <muj@bc.edu>
 joaoxsouls <joaoxsouls@gmail.com>
+jrincayc <jrincayc@users.noreply.github.com>
+juxiliary <juxiliary@gmail.com>
+jxv <joevargas@hush.com>
 klutzy <klutzytheklutzy@gmail.com>
 korenchkin <korenchkin2@gmail.com>
+kulakowski <george.kulakowski@gmail.com>
 kvark <kvarkus@gmail.com>
 kwantam <kwantam@gmail.com>
 lpy <pylaurent1314@gmail.com>
@@ -650,6 +772,7 @@ lyuts <dioxinu@gmail.com>
 m-r-r <raybaudroigm@gmail.com>
 maikklein <maikklein@googlemail.com>
 masklinn <github.com@masklinn.net>
+mchaput <matt@whoosh.ca>
 mdinger <mdinger.bugzilla@gmail.com>
 mitchmindtree <mitchell.nordine@gmail.com>
 moonglum <moonglum@moonbeamlabs.com>
@@ -659,15 +782,25 @@ musitdev <philippe.delrieu@free.fr>
 nham <hamann.nick@gmail.com>
 noam <noam@clusterfoo.com>
 novalis <novalis@novalis.org>
+oli-obk <github6541940@oli-obk.de>
+olivren <o.renaud@gmx.fr>
 osa1 <omeragacan@gmail.com>
+qwitwa <qwitwa@gmail.com>
 reedlepee <reedlepee123@gmail.com>
+rjz <rj@rjzaworski.com>
 sevrak <sevrak@rediffmail.com>
+sheroze1123 <mss385@cornell.edu>
 smenardpw <sebastien@knoglr.com>
 sp3d <sp3d@github>
 startling <tdixon51793@gmail.com>
+th0114nd <th0114nd@gmail.com>
 theptrk <patrick.tran06@gmail.com>
+thiagopnts <thiagopnts@gmail.com>
 tinaun <tinagma@gmail.com>
+tshakah <tshakah@gmail.com>
 ville-h <ville3.14159@gmail.com>
+we <vadim.petrochenkov@gmail.com>
+whataloadofwhat <unusualmoniker@gmail.com>
 wickerwaka <martin.donlon@gmail.com>
 xales <xales@naveria.com>
 zofrex <zofrex@gmail.com>
index 8d1c6e0e987cf4f896ab552ce1be8a95239c25d2..f7c385cbe7c1fb0c561bf93b37822e6cd9f4d845 100644 (file)
@@ -1,3 +1,185 @@
+Version 1.0.0-alpha (January 2015)
+----------------------------------
+
+  * ~2400 changes, numerous bugfixes
+
+  * Highlights
+
+    * The language itself is considered feature complete for 1.0,
+      though there will be many usability improvements and bugfixes
+      before the final release.
+    * Nearly 50% of the public API surface of the standard library has
+      been declared 'stable'. Those interfaces are unlikely to change
+      before 1.0.
+    * The long-running debate over integer types has been
+      [settled][ints]: Rust will ship with types named `isize` and
+      `usize`, rather than `int` and `uint`, for pointer-sized
+      integers. Guidelines will be rolled out during the alpha cycle.
+    * Most crates that are not `std` have been moved out of the Rust
+      distribution into the Cargo ecosystem so they can evolve
+      separately and don't need to be stabilized as quickly, including
+      'time', 'getopts', 'num', 'regex', and 'term'.
+    * Documentation continues to be expanded with more guides, more
+      API coverage and more examples.
+    * All official Rust binary installers now come with [Cargo], the
+      Rust package manager.
+
+* Language
+
+    * Closures have been [completely redesigned][unboxed] to be
+      implemented in terms of traits, can now be used as generic type
+      bounds and thus monomorphized and inlined, or via an opaque
+      pointer (boxed) as in the old system. The new system is often
+      referred to as 'unboxed' closures.
+    * Traits now support [associated types][assoc], allowing families
+      of related types to be defined together and used generically in
+      powerful ways.
+    * Enum variants are [namespaced by their type names][enum].
+    * [`where` clauses][where] provide a more versatile and attractive
+      syntax for specifying generic bounds, though the previous syntax
+      remains valid.
+    * Rust again picks a [fallback][fb] (either i32 or f64) for uninferred
+      numeric types.
+    * Rust [no longer has a runtime][rt] of any description, and only
+      supports OS threads, not green threads.
+    * At long last, Rust has been overhauled for 'dynamically-sized
+      types' ([DST]), which integrates 'fat pointers' (object types,
+      arrays, and `str`) more deeply into the type system, making it
+      more consistent.
+    * Rust now has a general [range syntax][range], `i..j`, `i..`, and
+      `..j` that produce range types and which, when combined with the
+      `Index` operator and multidispatch, leads to a convenient slice
+      notation, `[i..j]`.
+    * The new range syntax revealed an ambiguity in the fixed-length
+      array syntax, so now fixed length arrays [are written `[T;
+      N]`][arrays].
+    * The `Copy` trait is no longer implemented automatically. Unsafe
+      pointers no longer implement `Sync` and `Send` so types
+      containing them don't automatically either. `Sync` and `Send`
+      are now 'unsafe traits' so one can "forcibly" implement them via
+      `unsafe impl` if a type confirms to the requirements for them
+      even though the internals do not (e.g. structs containing unsafe
+      pointers like `Arc`). These changes are intended to prevent some
+      footguns and are collectively known as [opt-in built-in
+      traits][oibit] (though `Sync` and `Send` will soon become pure
+      library types unknown to the compiler).
+    * Operator traits now take their operands [by value][ops], and
+      comparison traits can use multidispatch to compare one type
+      against multiple other types, allowing e.g. `String` to be
+      compared with `&str`.
+    * `if let` and `while let` are no longer feature-gated.
+    * Rust has adopted a more [uniform syntax for escaping unicode
+      characters][unicode].
+    * `macro_rules!` [has been declared stable][mac]. Though it is a
+      flawed system it is sufficiently popular that it must be usable
+      for 1.0. Effort has gone into [future-proofing][mac-future] it
+      in ways that will allow other macro systems to be developed in
+      parallel, and won't otherwise impact the evolution of the
+      language.
+    * The prelude has been [pared back significantly][prelude] such
+      that it is the minimum necessary to support the most pervasive
+      code patterns, and through [generalized where clauses][where]
+      many of the prelude extension traits have been consolidated.
+    * Rust's rudimentary reflection [has been removed][refl], as it
+      incurred too much code generation for little benefit.
+    * [Struct variants][structvars] are no longer feature-gated.
+    * Trait bounds can be [polymorphic over lifetimes][hrtb]. Also
+      known as 'higher-ranked trait bounds', this crucially allows
+      unboxed closures to work.
+    * Macros invocations surrounded by parens or square brackets and
+      not terminated by a semicolon are [parsed as
+      expressions][macros], which makes expressions like `vec![1i32,
+      2, 3].len()` work as expected.
+    * Trait objects now implement their traits automatically, and
+      traits that can be coerced to objects now must be [object
+      safe][objsafe].
+    * Automatically deriving traits is now done with `#[derive(...)]`
+      not `#[deriving(...)]` for [consistency with other naming
+      conventions][derive].
+    * Importing the containing module or enum at the same time as
+      items or variants they contain is [now done with `self` instead
+      of `mod`][self], as in use `foo::{self, bar}`
+    * Glob imports are no longer feature-gated.
+    * The `box` operator and `box` patterns have been feature-gated
+      pending a redesign. For now unique boxes should be allocated
+      like other containers, with `Box::new`.
+
+* Libraries
+
+    * A [series][coll1] of [efforts][coll2] to establish
+      [conventions][coll3] for collections types has resulted in API
+      improvements throughout the standard library.
+    * New [APIs for error handling][err] provide ergonomic interop
+      between error types, and [new conventions][err-conv] describe
+      more clearly the recommended error handling strategies in Rust.
+    * The `fail!` macro has been renamed to [`panic!`][panic] so that
+      it is easier to discuss failure in the context of error handling
+      without making clarifications as to whether you are referring to
+      the 'fail' macro or failure more generally.
+    * On Linux, `OsRng` prefers the new, more reliable `getrandom`
+      syscall when available.
+    * The 'serialize' crate has been renamed 'rustc-serialize' and
+      moved out of the distribution to Cargo. Although it is widely
+      used now, it is expected to be superceded in the near future.
+    * The `Show` formatter, typically implemented with
+      `#[derive(Show)]` is [now requested with the `{:?}`
+      specifier][show] and is intended for use by all types, for uses
+      such as `println!` debugging. The new `String` formatter must be
+      implemented by hand, uses the `{}` specifier, and is intended
+      for full-fidelity conversions of things that can logically be
+      represented as strings.
+
+* Tooling
+
+    * [Flexible target specification][flex] allows rustc's code
+      generation to be configured to support otherwise-unsupported
+      platforms.
+    * Rust comes with rust-gdb and rust-lldb scripts that launch their
+      respective debuggers with Rust-appropriate pretty-printing.
+    * The Windows installation of Rust is distributed with the the
+      MinGW components currently required to link binaries on that
+      platform.
+
+* Misc
+
+    * Nullable enum optimizations have been extended to more types so
+      that e.g. `Option<Vec<T>>` and `Option<String>` take up no more
+      space than the inner types themselves.
+    * Work has begun on supporting AArch64.
+
+[Cargo]: https://crates.io
+[unboxed]: http://smallcultfollowing.com/babysteps/blog/2014/11/26/purging-proc/
+[enum]: https://github.com/rust-lang/rfcs/blob/master/text/0390-enum-namespacing.md
+[flex]: https://github.com/rust-lang/rfcs/blob/master/text/0131-target-specification.md
+[err]: https://github.com/rust-lang/rfcs/blob/master/text/0201-error-chaining.md
+[err-conv]: https://github.com/rust-lang/rfcs/blob/master/text/0236-error-conventions.md
+[rt]: https://github.com/rust-lang/rfcs/blob/master/text/0230-remove-runtime.md
+[mac]: https://github.com/rust-lang/rfcs/blob/master/text/0453-macro-reform.md
+[mac-future]: https://github.com/rust-lang/rfcs/pull/550
+[DST]: http://smallcultfollowing.com/babysteps/blog/2014/01/05/dst-take-5/
+[coll1]: https://github.com/rust-lang/rfcs/blob/master/text/0235-collections-conventions.md
+[coll2]: https://github.com/rust-lang/rfcs/blob/master/text/0509-collections-reform-part-2.md
+[coll3]: https://github.com/rust-lang/rfcs/blob/master/text/0216-collection-views.md
+[ops]: https://github.com/rust-lang/rfcs/blob/master/text/0439-cmp-ops-reform.md
+[prelude]: https://github.com/rust-lang/rfcs/blob/master/text/0503-prelude-stabilization.md
+[where]: https://github.com/rust-lang/rfcs/blob/master/text/0135-where.md
+[refl]: https://github.com/rust-lang/rfcs/blob/master/text/0379-remove-reflection.md
+[panic]: https://github.com/rust-lang/rfcs/blob/master/text/0221-panic.md
+[structvars]: https://github.com/rust-lang/rfcs/blob/master/text/0418-struct-variants.md
+[hrtb]: https://github.com/rust-lang/rfcs/blob/master/text/0387-higher-ranked-trait-bounds.md
+[unicode]: https://github.com/rust-lang/rfcs/blob/master/text/0446-es6-unicode-escapes.md
+[oibit]: https://github.com/rust-lang/rfcs/blob/master/text/0019-opt-in-builtin-traits.md
+[macros]: https://github.com/rust-lang/rfcs/blob/master/text/0378-expr-macros.md
+[range]: https://github.com/rust-lang/rfcs/blob/master/text/0439-cmp-ops-reform.md#indexing-and-slicing
+[arrays]: https://github.com/rust-lang/rfcs/blob/master/text/0520-new-array-repeat-syntax.md
+[show]: https://github.com/rust-lang/rfcs/blob/master/text/0504-show-stabilization.md
+[derive]: https://github.com/rust-lang/rfcs/blob/master/text/0534-deriving2derive.md
+[self]: https://github.com/rust-lang/rfcs/blob/master/text/0532-self-in-use.md
+[fb]: https://github.com/rust-lang/rfcs/blob/master/text/0212-restore-int-fallback.md
+[objsafe]: https://github.com/rust-lang/rfcs/blob/master/text/0255-object-safety.md
+[assoc]: https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md
+[ints]: https://github.com/rust-lang/rfcs/pull/544#issuecomment-68760871
+
 Version 0.12.0 (October 2014)
 -----------------------------
 
index 202a87fcdc9e7516406af1dd48639b954314ad19..c29f74d74181087ab05ef8f6f6e79af20fdc6670 100644 (file)
@@ -43,9 +43,9 @@ fn from_str(s: &str) -> Option<Mode> {
     }
 }
 
-impl fmt::Show for Mode {
+impl fmt::String for Mode {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let msg = match *self {
+        fmt::String::fmt(match *self {
             CompileFail => "compile-fail",
             RunFail => "run-fail",
             RunPass => "run-pass",
@@ -54,8 +54,13 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             DebugInfoGdb => "debuginfo-gdb",
             DebugInfoLldb => "debuginfo-lldb",
             Codegen => "codegen",
-        };
-        msg.fmt(f)
+        }, f)
+    }
+}
+
+impl fmt::Show for Mode {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
     }
 }
 
index 0ce31a335d8ab7d698804a6ed7efd31172d23a67..e2420b0a22024848204509e849edbc066b166a78 100644 (file)
@@ -9,21 +9,15 @@
 // except according to those terms.
 
 #![crate_type = "bin"]
-#![feature(phase, slicing_syntax, globs, unboxed_closures)]
+#![feature(slicing_syntax, unboxed_closures)]
 
 #![deny(warnings)]
 
 extern crate test;
 extern crate getopts;
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
 #[macro_use]
 extern crate log;
-
 extern crate regex;
 
 use std::os;
@@ -108,7 +102,7 @@ pub fn parse_config(args: Vec<String> ) -> Config {
     let matches =
         &match getopts::getopts(args_.as_slice(), groups.as_slice()) {
           Ok(m) => m,
-          Err(f) => panic!("{}", f)
+          Err(f) => panic!("{:?}", f)
         };
 
     if matches.opt_present("h") || matches.opt_present("help") {
@@ -127,7 +121,7 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
         match regex::Regex::new(s) {
             Ok(re) => Some(re),
             Err(e) => {
-                println!("failed to parse filter /{}/: {}", s, e);
+                println!("failed to parse filter /{}/: {:?}", s, e);
                 panic!()
             }
         }
@@ -186,11 +180,11 @@ fn opt_path(m: &getopts::Matches, nm: &str) -> Path {
 pub fn log_config(config: &Config) {
     let c = config;
     logv(c, format!("configuration:"));
-    logv(c, format!("compile_lib_path: {}", config.compile_lib_path));
-    logv(c, format!("run_lib_path: {}", config.run_lib_path));
-    logv(c, format!("rustc_path: {}", config.rustc_path.display()));
-    logv(c, format!("src_base: {}", config.src_base.display()));
-    logv(c, format!("build_base: {}", config.build_base.display()));
+    logv(c, format!("compile_lib_path: {:?}", config.compile_lib_path));
+    logv(c, format!("run_lib_path: {:?}", config.run_lib_path));
+    logv(c, format!("rustc_path: {:?}", config.rustc_path.display()));
+    logv(c, format!("src_base: {:?}", config.src_base.display()));
+    logv(c, format!("build_base: {:?}", config.build_base.display()));
     logv(c, format!("stage_id: {}", config.stage_id));
     logv(c, format!("mode: {}", config.mode));
     logv(c, format!("run_ignored: {}", config.run_ignored));
@@ -206,10 +200,10 @@ pub fn log_config(config: &Config) {
     logv(c, format!("jit: {}", config.jit));
     logv(c, format!("target: {}", config.target));
     logv(c, format!("host: {}", config.host));
-    logv(c, format!("android-cross-path: {}",
+    logv(c, format!("android-cross-path: {:?}",
                     config.android_cross_path.display()));
-    logv(c, format!("adb_path: {}", config.adb_path));
-    logv(c, format!("adb_test_dir: {}", config.adb_test_dir));
+    logv(c, format!("adb_path: {:?}", config.adb_path));
+    logv(c, format!("adb_test_dir: {:?}", config.adb_test_dir));
     logv(c, format!("adb_device_status: {}",
                     config.adb_device_status));
     match config.test_shard {
@@ -271,7 +265,7 @@ pub fn run_tests(config: &Config) {
         Ok(true) => {}
         Ok(false) => panic!("Some tests failed"),
         Err(e) => {
-            println!("I/O failure during tests: {}", e);
+            println!("I/O failure during tests: {:?}", e);
         }
     }
 }
@@ -299,13 +293,13 @@ pub fn test_opts(config: &Config) -> test::TestOpts {
 }
 
 pub fn make_tests(config: &Config) -> Vec<test::TestDescAndFn> {
-    debug!("making tests from {}",
+    debug!("making tests from {:?}",
            config.src_base.display());
     let mut tests = Vec::new();
     let dirs = fs::readdir(&config.src_base).unwrap();
     for file in dirs.iter() {
         let file = file.clone();
-        debug!("inspecting file {}", file.display());
+        debug!("inspecting file {:?}", file.display());
         if is_test(config, &file) {
             let t = make_test(config, &file, || {
                 match config.mode {
index f330bb3143eaba2a29c7af5892c2da410209b7b7..dcfac688c7f62cd0083c919df1bf1c55209f9522 100644 (file)
@@ -84,7 +84,7 @@ fn parse_expected(last_nonfollow_error: Option<uint>,
             (which, line)
         };
 
-        debug!("line={} which={} kind={} msg={}", line_num, which, kind, msg);
+        debug!("line={} which={:?} kind={:?} msg={:?}", line_num, which, kind, msg);
         Some((which, ExpectedError { line: line,
                                      kind: kind,
                                      msg: msg, }))
index 875061e69b7a28ce49bfc6c8070dbd5bb6f4c619..f8e2ba4828f383773acd17983a7db49636afd2e7 100644 (file)
@@ -61,7 +61,7 @@ pub fn run_metrics(config: Config, testfile: String, mm: &mut MetricMap) {
         print!("\n\n");
     }
     let testfile = Path::new(testfile);
-    debug!("running {}", testfile.display());
+    debug!("running {:?}", testfile.display());
     let props = header::load_props(&testfile);
     debug!("loaded props");
     match config.mode {
@@ -141,7 +141,7 @@ 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: {}",
+            format!("failure produced the wrong error: {:?}",
                     proc_res.status).as_slice(),
             proc_res);
     }
@@ -410,7 +410,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).as_slice());
 
             procsrv::run("",
                          config.adb_path.as_slice(),
@@ -422,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).as_slice());
 
             let adb_arg = format!("export LD_LIBRARY_PATH={}; \
                                    gdbserver :5039 {}/{}",
@@ -443,11 +443,11 @@ 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).as_slice());
             loop {
                 //waiting 1 second for gdbserver start
                 timer::sleep(Duration::milliseconds(1000));
-                let result = Thread::spawn(move || {
+                let result = Thread::scoped(move || {
                     tcp::TcpStream::connect("127.0.0.1:5039").unwrap();
                 }).join();
                 if result.is_err() {
@@ -481,7 +481,7 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
                              debugger_opts.as_slice(),
                              vec!(("".to_string(), "".to_string())),
                              None)
-                .expect(format!("failed to exec `{}`", gdb_path).as_slice());
+                .expect(format!("failed to exec `{:?}`", gdb_path).as_slice());
             let cmdline = {
                 let cmdline = make_cmdline("",
                                            "arm-linux-androideabi-gdb",
@@ -539,18 +539,17 @@ fn run_debuginfo_gdb_test(config: &Config, props: &TestProps, testfile: &Path) {
             script_str.push_str("set print pretty off\n");
 
             // Add the pretty printer directory to GDB's source-file search path
-            script_str.push_str(format!("directory {}\n", rust_pp_module_abs_path)[]);
+            script_str.push_str(&format!("directory {}\n", rust_pp_module_abs_path)[]);
 
             // Load the target executable
-            script_str.push_str(format!("file {}\n",
-                                        exe_file.as_str().unwrap().replace("\\", "\\\\"))
-                                    .as_slice());
+            script_str.push_str(&format!("file {}\n",
+                                         exe_file.as_str().unwrap().replace("\\", "\\\\"))[]);
 
             // Add line breakpoints
             for line in breakpoint_lines.iter() {
-                script_str.push_str(format!("break '{}':{}\n",
-                                            testfile.filename_display(),
-                                            *line)[]);
+                script_str.push_str(&format!("break '{:?}':{}\n",
+                                             testfile.filename_display(),
+                                             *line)[]);
             }
 
             script_str.push_str(cmds.as_slice());
@@ -676,7 +675,7 @@ fn run_debuginfo_lldb_test(config: &Config, props: &TestProps, testfile: &Path)
                                                .unwrap()
                                                .to_string();
 
-    script_str.push_str(format!("command script import {}\n", rust_pp_module_abs_path[])[]);
+    script_str.push_str(&format!("command script import {}\n", &rust_pp_module_abs_path[])[]);
     script_str.push_str("type summary add --no-value ");
     script_str.push_str("--python-function lldb_rust_formatters.print_val ");
     script_str.push_str("-x \".*\" --category Rust\n");
@@ -889,7 +888,7 @@ 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 {}",
+        fatal(format!("no error pattern specified in {:?}",
                       testfile.display()).as_slice());
     }
     let mut next_err_idx = 0u;
@@ -910,7 +909,7 @@ fn check_error_patterns(props: &TestProps,
     if done { return; }
 
     let missing_patterns =
-        props.error_patterns[next_err_idx..];
+        props.error_patterns.index(&(next_err_idx..));
     if missing_patterns.len() == 1u {
         fatal_proc_rec(format!("error pattern '{}' not found!",
                               missing_patterns[0]).as_slice(),
@@ -955,7 +954,7 @@ fn check_expected_errors(expected_errors: Vec<errors::ExpectedError> ,
     }
 
     let prefixes = expected_errors.iter().map(|ee| {
-        format!("{}:{}:", testfile.display(), ee.line)
+        format!("{:?}:{}:", testfile.display(), ee.line)
     }).collect::<Vec<String> >();
 
     #[cfg(windows)]
@@ -1191,7 +1190,7 @@ fn compose_and_run_compiler(
                                      None);
         if !auxres.status.success() {
             fatal_proc_rec(
-                format!("auxiliary build of {} failed to compile: ",
+                format!("auxiliary build of {:?} failed to compile: ",
                         abs_ab.display()).as_slice(),
                 &auxres);
         }
@@ -1601,7 +1600,7 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
                 .expect(format!("failed to exec `{}`", config.adb_path).as_slice());
 
             if config.verbose {
-                println!("push ({}) {} {} {}",
+                println!("push ({}) {:?} {} {}",
                     config.target, file.display(),
                     copy_result.out, copy_result.err);
             }
index d833827981e277ffd2f1205bbf01b7230ebc6cfb..d241e77f810c70f61361c2a69927ca29773a0914 100644 (file)
@@ -167,10 +167,10 @@ fn parse_version(header: &[u8]) -> Result<Version, ParseError> {
 let version = parse_version(&[1, 2, 3, 4]);
 match version {
     Ok(v) => {
-        println!("working with version: {}", v);
+        println!("working with version: {:?}", v);
     }
     Err(e) => {
-        println!("error parsing header: {}", e);
+        println!("error parsing header: {:?}", e);
     }
 }
 ```
index dc6d281307a7a602e746a599b78f16961f628da9..95f5305775eedfa1147db08d02b35ffc7ed74498 100644 (file)
@@ -42,7 +42,7 @@ the pattern in the above code:
 # let input_1 = T::SpecialA(0);
 # let input_2 = T::SpecialA(0);
 macro_rules! early_return {
-    ($inp:expr $sp:path) => ( // invoke it like `(input_5 SpecialE)`
+    ($inp:expr, $sp:path) => ( // invoke it like `(input_5 SpecialE)`
         match $inp {
             $sp(x) => { return x; }
             _ => {}
@@ -50,9 +50,9 @@ macro_rules! early_return {
     );
 }
 // ...
-early_return!(input_1 T::SpecialA);
+early_return!(input_1, T::SpecialA);
 // ...
-early_return!(input_2 T::SpecialB);
+early_return!(input_2, T::SpecialB);
 # return 0;
 # }
 # fn main() {}
@@ -161,7 +161,7 @@ instead of `*` to mean "at least one".
 # let input_1 = T::SpecialA(0);
 # let input_2 = T::SpecialA(0);
 macro_rules! early_return {
-    ($inp:expr, [ $($sp:path)|+ ]) => (
+    ($inp:expr, [ $($sp:path),+ ]) => (
         match $inp {
             $(
                 $sp(x) => { return x; }
@@ -171,7 +171,7 @@ macro_rules! early_return {
     )
 }
 // ...
-early_return!(input_1, [T::SpecialA|T::SpecialC|T::SpecialD]);
+early_return!(input_1, [T::SpecialA,T::SpecialC,T::SpecialD]);
 // ...
 early_return!(input_2, [T::SpecialB]);
 # return 0;
@@ -245,7 +245,7 @@ can solve the problem:
 ~~~~
 macro_rules! biased_match {
     // special case: `let (x) = ...` is illegal, so use `let x = ...` instead
-    ( ($e:expr) ~ ($p:pat) else $err:stmt ;
+    ( ($e:expr) -> ($p:pat) else $err:stmt ;
       binds $bind_res:ident
     ) => (
         let $bind_res = match $e {
@@ -254,7 +254,7 @@ macro_rules! biased_match {
         };
     );
     // more than one name; use a tuple
-    ( ($e:expr) ~ ($p:pat) else $err:stmt ;
+    ( ($e:expr) -> ($p:pat) else $err:stmt ;
       binds $( $bind_res:ident ),*
     ) => (
         let ( $( $bind_res ),* ) = match $e {
@@ -268,9 +268,9 @@ macro_rules! biased_match {
 # struct T2 { body: T3 }
 # enum T3 { Good2(uint), Bad2}
 # fn f(x: T1) -> uint {
-biased_match!((x)       ~ (T1::Good1(g1, val)) else { return 0 };
+biased_match!((x)       -> (T1::Good1(g1, val)) else { return 0 };
               binds g1, val );
-biased_match!((g1.body) ~ (T3::Good2(result) )
+biased_match!((g1.body) -> (T3::Good2(result) )
                   else { panic!("Didn't get good_2") };
               binds result );
 // complicated stuff goes here
@@ -286,7 +286,7 @@ pattern we want is clear:
 ~~~~
 # fn main() {}
 # macro_rules! b {
-    ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
+    ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
       binds $( $bind_res:ident ),*
     )
 # => (0) }
@@ -317,8 +317,8 @@ input patterns:
 ~~~~
 # fn main() {}
 # macro_rules! b {
-    (    ($e     :expr) ~ ($p     :pat) else $err     :stmt ;
-      $( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
+    (    ($e     :expr) -> ($p     :pat) else $err     :stmt ;
+      $( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
       binds  $( $bind_res:ident ),*
     )
 # => (0) }
@@ -333,14 +333,14 @@ piece of syntax (the `let`) which we only want to transcribe once.
 
 macro_rules! biased_match_rec {
     // Handle the first layer
-    (   ($e     :expr) ~ ($p     :pat) else $err     :stmt ;
-     $( ($e_rest:expr) ~ ($p_rest:pat) else $err_rest:stmt ; )*
+    (   ($e     :expr) -> ($p     :pat) else $err     :stmt ;
+     $( ($e_rest:expr) -> ($p_rest:pat) else $err_rest:stmt ; )*
      binds $( $bind_res:ident ),*
     ) => (
         match $e {
             $p => {
                 // Recursively handle the next layer
-                biased_match_rec!($( ($e_rest) ~ ($p_rest) else $err_rest ; )*
+                biased_match_rec!($( ($e_rest) -> ($p_rest) else $err_rest ; )*
                                   binds $( $bind_res ),*
                 )
             }
@@ -354,20 +354,20 @@ macro_rules! biased_match_rec {
 // Wrap the whole thing in a `let`.
 macro_rules! biased_match {
     // special case: `let (x) = ...` is illegal, so use `let x = ...` instead
-    ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
+    ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
       binds $bind_res:ident
     ) => (
         let $bind_res = biased_match_rec!(
-            $( ($e) ~ ($p) else $err ; )*
+            $( ($e) -> ($p) else $err ; )*
             binds $bind_res
         );
     );
     // more than one name: use a tuple
-    ( $( ($e:expr) ~ ($p:pat) else $err:stmt ; )*
+    ( $( ($e:expr) -> ($p:pat) else $err:stmt ; )*
       binds  $( $bind_res:ident ),*
     ) => (
         let ( $( $bind_res ),* ) = biased_match_rec!(
-            $( ($e) ~ ($p) else $err ; )*
+            $( ($e) -> ($p) else $err ; )*
             binds $( $bind_res ),*
         );
     )
@@ -379,8 +379,8 @@ macro_rules! biased_match {
 # enum T3 { Good2(uint), Bad2}
 # fn f(x: T1) -> uint {
 biased_match!(
-    (x)       ~ (T1::Good1(g1, val)) else { return 0 };
-    (g1.body) ~ (T3::Good2(result) ) else { panic!("Didn't get Good2") };
+    (x)       -> (T1::Good1(g1, val)) else { return 0 };
+    (g1.body) -> (T3::Good2(result) ) else { panic!("Didn't get Good2") };
     binds val, result );
 // complicated stuff goes here
 return result + val;
index 678e817e2ebbe06b751610278775c2b2aeae0d1b..14e33ab0f74a9edfdb4ca90a345e5158bbc4e8d1 100644 (file)
@@ -620,7 +620,7 @@ enum List<T> {
 
 fn main() {
     let list: List<int> = List::Cons(1, box List::Cons(2, box List::Cons(3, box List::Nil)));
-    println!("{}", list);
+    println!("{:?}", list);
 }
 ```
 
index bda1b34563208e0317b958b1b1f9e029b7b1d902..11bc0bc30f20ee863fb614b1376da2786fcc4e4a 100644 (file)
@@ -703,10 +703,10 @@ Other features provided by lang items include:
   `deref`, and `add` respectively.
 - stack unwinding and general failure; the `eh_personality`, `fail`
   and `fail_bounds_checks` lang items.
-- the traits in `std::kinds` used to indicate types that satisfy
+- the traits in `std::markers` used to indicate types of
   various kinds; lang items `send`, `sync` and `copy`.
 - the marker types and variance indicators found in
-  `std::kinds::markers`; lang items `covariant_type`,
+  `std::markers`; lang items `covariant_type`,
   `contravariant_lifetime`, `no_sync_bound`, etc.
 
 Lang items are loaded lazily by the compiler; e.g. if one never uses
index 66551ec499a89eeb96044251a9b440b9910e46ae..f736ef821fa37ae723bca74e8ac7962cef9ef353 100644 (file)
@@ -90,7 +90,7 @@ $ rustc --version
 You should see some output that looks something like this:
 
 ```bash
-rustc 0.12.0-nightly (b7aa03a3c 2014-09-28 11:38:01 +0000)
+rustc 1.0.0-nightly (f11f3e7ba 2015-01-04 20:02:14 +0000)
 ```
 
 If you did, Rust has been installed successfully! Congrats!
@@ -1377,7 +1377,7 @@ As you can see, `enum` and `match` used together are quite useful!
 
 `match` is also an expression, which means we can use it on the right-hand
 side of a `let` binding or directly where an expression is used. We could
-also implement the previous line like this:
+also implement the previous example like this:
 
 ```{rust}
 use std::cmp::Ordering;
@@ -1653,7 +1653,7 @@ for e in a.iter() {
 You can access a particular element of an array with **subscript notation**:
 
 ```{rust}
-let names = ["Graydon", "Brian", "Niko"]; // names: [&str, 3]
+let names = ["Graydon", "Brian", "Niko"]; // names: [&str; 3]
 
 println!("The second name is: {}", names[1]);
 ```
@@ -4789,7 +4789,7 @@ of `Option`, we need to provide a concrete type in place of the type
 parameter. For example, if we wanted something like our `OptionalInt`, we would
 need to instantiate an `Option<i32>`. Inside the declaration of our enum,
 wherever we see a `T`, we replace it with the type specified (or inferred by the
-the compiler).
+compiler).
 
 ```{rust}
 let x: Option<i32> = Some(5);
index a4e9d85bffdf8eb203e0de8dc2f0319b06e1b130..fbc96a577a41acc43c237f2d951c53869ff8d544 100644 (file)
@@ -395,7 +395,7 @@ fn main() {
     for _ in range(0u, 10u) {
         Thread::spawn(move || {
             println!("Hello, world!");
-        }).detach();
+        });
     }
 }
 ```
@@ -405,8 +405,7 @@ This program creates ten threads, who all print `Hello, world!`. The
 double bars `||`. (The `move` keyword indicates that the closure takes
 ownership of any data it uses; we'll have more on the significance of
 this shortly.) This closure is executed in a new thread created by
-`spawn`. The `detach` method means that the child thread is allowed to
-outlive its parent.
+`spawn`.
 
 One common form of problem in concurrent programs is a 'data race.'
 This occurs when two different threads attempt to access the same
@@ -429,7 +428,7 @@ fn main() {
     for i in range(0u, 3u) {
         Thread::spawn(move || {
             for j in range(0, 3) { numbers[j] += 1 }
-        }).detach();
+        });
     }
 }
 ```
@@ -488,7 +487,7 @@ fn main() {
             (*array)[i] += 1;
 
             println!("numbers[{}] is {}", i, (*array)[i]);
-        }).detach();
+        });
     }
 }
 ```
index 358d20feb06e1ee3f4d71b52159b61482cb7b49d..febd5f883d14d07f3bc0932635a1900fd5f5dc7b 100644 (file)
@@ -690,10 +690,9 @@ balanced, but they are otherwise not special.
 
 In the matcher, `$` _name_ `:` _designator_ matches the nonterminal in the Rust
 syntax named by _designator_. Valid designators are `item`, `block`, `stmt`,
-`pat`, `expr`, `ty` (type), `ident`, `path`, `matchers` (lhs of the `=>` in
-macro rules), `tt` (rhs of the `=>` in macro rules). In the transcriber, the
-designator is already known, and so only the name of a matched nonterminal
-comes after the dollar sign.
+`pat`, `expr`, `ty` (type), `ident`, `path`, `tt` (either side of the `=>`
+in macro rules). In the transcriber, the designator is already known, and so
+only the name of a matched nonterminal comes after the dollar sign.
 
 In both the matcher and transcriber, the Kleene star-like operator indicates
 repetition. The Kleene star operator consists of `$` and parens, optionally
old mode 100644 (file)
new mode 100755 (executable)
index 7e5918e..b6770c9
@@ -51,7 +51,7 @@ def rust_pretty_printer_lookup_function(val):
     enum_member_count = len(enum_members)
 
     if enum_member_count == 0:
-      return RustStructPrinter(val, false)
+      return RustStructPrinter(val, False)
 
     if enum_member_count == 1:
       first_variant_name = enum_members[0].name
@@ -60,21 +60,27 @@ def rust_pretty_printer_lookup_function(val):
         return rust_pretty_printer_lookup_function(val[enum_members[0]])
       else:
         assert first_variant_name.startswith("RUST$ENCODED$ENUM$")
-        # This is a space-optimized enum
+        # This is a space-optimized enum.
+        # This means this enum has only two states, and Rust uses one of the
+        # fields somewhere in the struct to determine which of the two states
+        # it's in. The location of the field is encoded in the name as something
+        # like RUST$ENCODED$ENUM$(num$)*name_of_zero_state
         last_separator_index = first_variant_name.rfind("$")
-        second_last_separator_index = first_variant_name.rfind("$", 0, last_separator_index)
-        disr_field_index = first_variant_name[second_last_separator_index + 1 :
-                                              last_separator_index]
-        disr_field_index = int(disr_field_index)
+        start_index = len("RUST$ENCODED$ENUM$")
+        disr_field_indices = first_variant_name[start_index :
+                                              last_separator_index].split("$")
+        disr_field_indices = [int(index) for index in disr_field_indices]
 
         sole_variant_val = val[enum_members[0]]
-        disr_field = get_field_at_index(sole_variant_val, disr_field_index)
-        discriminant = sole_variant_val[disr_field]
+        discriminant = sole_variant_val
+        for disr_field_index in disr_field_indices:
+          disr_field = get_field_at_index(discriminant, disr_field_index)
+          discriminant = discriminant[disr_field]
 
         # If the discriminant field is a fat pointer we have to consider the
         # first word as the true discriminant
         if discriminant.type.code == gdb.TYPE_CODE_STRUCT:
-            discriminant = discriminant[get_field_at_index(discriminant, 0)]
+          discriminant = discriminant[get_field_at_index(discriminant, 0)]
 
         if discriminant == 0:
           null_variant_name = first_variant_name[last_separator_index + 1:]
@@ -234,4 +240,5 @@ def get_field_at_index(val, index):
   for field in val.type.fields():
     if i == index:
       return field
+    i += 1
   return None
index 1fb01767a130b4833f0a36031a7ae678c652dbb4..41dc2d1fbda065622e28442934854e98b7e3507e 100644 (file)
@@ -7,7 +7,7 @@
        <!ENTITY rustIdent "[a-zA-Z_][a-zA-Z_0-9]*">
        <!ENTITY rustIntSuf "([iu](8|16|32|64)?)?">
 ]>
-<language name="Rust" version="0.13.0" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
+<language name="Rust" version="1.0.0" kateversion="2.4" section="Sources" extensions="*.rs" mimetype="text/x-rust" priority="15">
 <highlighting>
        <list name="fn">
                <item> fn </item>
index f4f1a5121d1957a06862c97efa11f89a4fa25c5d..05d71902904b46b5ee3b9eecf92d3e9595a70b0c 100644 (file)
@@ -79,11 +79,11 @@ def print_struct_val_starting_from(field_start_index, val, internal_dict):
   has_field_names = type_has_field_names(t)
 
   if has_field_names:
-      template = "%(type_name)s {\n%(body)s\n}"
-      separator = ", \n"
+    template = "%(type_name)s {\n%(body)s\n}"
+    separator = ", \n"
   else:
-      template = "%(type_name)s(%(body)s)"
-      separator = ", "
+    template = "%(type_name)s(%(body)s)"
+    separator = ", "
 
   if type_name.startswith("("):
     # this is a tuple, so don't print the type name
@@ -125,25 +125,25 @@ def print_enum_val(val, internal_dict):
       if last_separator_index == -1:
         return "<invalid enum encoding: %s>" % first_variant_name
 
-      second_last_separator_index = first_variant_name.rfind("$", 0, last_separator_index)
-      if second_last_separator_index == -1:
-        return "<invalid enum encoding: %s>" % first_variant_name
+      start_index = len("RUST$ENCODED$ENUM$")
 
-      # Extract index of the discriminator field
+      # Extract indices of the discriminator field
       try:
-        disr_field_index = first_variant_name[second_last_separator_index + 1 :
-                                              last_separator_index]
-        disr_field_index = int(disr_field_index)
+        disr_field_indices = first_variant_name[start_index :
+                                              last_separator_index].split("$")
+        disr_field_indices = [int(index) for index in disr_field_indices]
       except:
         return "<invalid enum encoding: %s>" % first_variant_name
 
       # Read the discriminant
-      disr_val = val.GetChildAtIndex(0).GetChildAtIndex(disr_field_index)
+      disr_val = val.GetChildAtIndex(0)
+      for index in disr_field_indices:
+        disr_val = disr_val.GetChildAtIndex(index)
 
       # If the discriminant field is a fat pointer we have to consider the
       # first word as the true discriminant
       if disr_val.GetType().GetTypeClass() == lldb.eTypeClassStruct:
-          disr_val = disr_val.GetChildAtIndex(0)
+        disr_val = disr_val.GetChildAtIndex(0)
 
       if disr_val.GetValueAsUnsigned() == 0:
         # Null case: Print the name of the null-variant
index f4e8f6f7873c9baa0bc64f59eb11530dd753e017..404f622f970c37f237bed5fd51a79964889b192b 100644 (file)
@@ -20,35 +20,37 @@ _rustc_crate_types=(
 
 _rustc_emit_types=(
     'asm'
-    'bc'
-    'ir'
+    'llvm-bc'
+    'llvm-ir'
     'obj'
     'link'
+    'dep-info'
 )
 _rustc_pretty_types=(
     'normal[un-annotated source]'
     'expanded[crates expanded]'
     'typed[crates  expanded,  with  type  annotations]'
     'identified[fully parenthesized, AST nodes and blocks with IDs]'
-    'flowgraph=[graphviz formatted flowgraph for node]:NODEID:'
+    'flowgraph[graphviz formatted flowgraph for node]:NODEID:'
 )
 _rustc_color_types=(
     'auto[colorize, if output goes to a tty (default)]'
     'always[always colorize output]'
     'never[never colorize output]'
 )
+_rustc_info_types=(
+    'crate-name[Output the crate name and exit]'
+    'file-names[Output the file(s) that would be written if compilation continued and exited]'
+    'sysroot[Output the sysroot and exit]'
+)
 
 _rustc_opts_vals=(
     --crate-name='[Specify the name of the crate being built]'
     --crate-type='[Comma separated list of types of crates for the compiler to emit]:TYPES:_values -s "," "Crate types"  "$_rustc_crate_types[@]"'
     --emit='[Comma separated list of types of output for the compiler to emit]:TYPES:_values -s "," "Emit Targets" "$_rustc_emit_types[@]"'
-    --debuginfo='[Emit DWARF debug info to the objects created]:LEVEL:_values "Debug Levels" "$_rustc_debuginfo_levels[@]"'
-    --dep-info='[Output dependency info to <filename> after compiling]::FILE:_files -/'
-    --sysroot='[Override the system root]:PATH:_files -/'
     --cfg='[Configure the compilation environment]:SPEC:'
     --out-dir='[Write output to compiler-chosen filename in <dir>.  Ignored  if  -o  is  specified. (default the current directory)]:DIR:_files -/'
     -o'[Write output to <filename>. Ignored if more than one --emit is specified.]:FILENAME:_files'
-    --opt-level='[Optimize with possible levels 0-3]:LEVEL:(0 1 2 3)'
     --pretty='[Pretty-print the input instead of compiling]::TYPE:_values "TYPES" "$_rustc_pretty_types[@]"'
     -L'[Add a directory to the library search path]:DIR:_files -/'
     --target='[Target triple cpu-manufacturer-kernel\[-os\] to compile]:TRIPLE:'
@@ -56,27 +58,33 @@ _rustc_opts_vals=(
     {-v,--version}'[Print version info and exit]::VERBOSE:(verbose)'
     --explain='[Provide a detailed explanation of an error message]:OPT:'
     --extern'[Specify where an external rust library is located]:ARG:'
+    --print='[Comma separated list of compiler information to print on stdout]:TYPES:_values -s "," "Compiler Information" "$_rustc_info_types[@]"'
 )
 
 _rustc_opts_switches=(
-    -g'[Equivalent to --debuginfo=2]'
-    {-h,--help}'[Display this message]'
-    --no-analysis'[Parse and expand the output, but run no analysis or produce output]'
-    --no-trans'[Run all passes except translation; no output]'
-    -O'[Equivalent to --opt-level=2]'
-    --parse-only'[Parse only; do not compile, assemble, or link]'
-    --print-crate-name'[Output the crate name and exit]'
-    --print-file-name'[Output the file(s) that would be written if compilation continued and exit]'
+    -g'[Equivalent to -C debuginfo=2]'
+    {-h,--help}'[Display the help message]'
+    {-V,--verbose}'[use verbose output]'
+    -O'[Equivalent to -C opt-level=2]'
     --test'[Build a test harness]'
 )
+
+
+_rustc_opts_link=(
+    'static[Path to the library to link statically]:PATH:_files -/'
+    'dylib[Path to the library to link dynamically]:PATH:_files -/'
+    'framework[Path to the library to link as a framework]:PATH:_files -/'
+)
+
 _rustc_opts_codegen=(
-    'ar=[Path to the archive utility to use when assembling archives.]:BIN:_path_files'
-    'linker=[Path to the linker utility to use when linking libraries, executables, and objects.]:BIN:_path_files'
-    'link-args=[A space-separated list of extra arguments to pass to the linker when the linker is invoked.]:ARGS:'
-    'target-cpu=[Selects a target processor. If the value is "help", then a list of  available  CPUs is printed.]:CPU:'
-    'target-feature=[A space-separated list of features to enable or disable for the target. A preceding "+" enables a feature while a preceding "-" disables it. Available features can be discovered through target-cpu=help.]:FEATURE:'
-    'passes=[A space-separated list of extra LLVM passes to run. A value of "list" will cause rustc to print all known passes and exit. The passes specified are appended at the end of the normal pass manager.]:LIST:'
-    'llvm-args=[A space-separated list of arguments to pass through to LLVM.]:ARGS:'
+    'ar[Path to the archive utility to use when assembling archives.]:BIN:_path_files'
+    'linker[Path to the linker utility to use when linking libraries, executables, and objects.]:BIN:_path_files'
+    'link-args[A space-separated list of extra arguments to pass to the linker when the linker is invoked.]:ARGS:'
+    'lto[Perform LLVM link-time optimizations]'
+    'target-cpu[Selects a target processor. If the value is "help", then a list of  available  CPUs is printed.]:CPU:'
+    'target-feature[A space-separated list of features to enable or disable for the target. A preceding "+" enables a feature while a preceding "-" disables it. Available features can be discovered through target-cpu=help.]:FEATURE:'
+    'passes[A space-separated list of extra LLVM passes to run. A value of "list" will cause rustc to print all known passes and exit. The passes specified are appended at the end of the normal pass manager.]:LIST:'
+    'llvm-args[A space-separated list of arguments to pass through to LLVM.]:ARGS:'
     'save-temps[If specified, the compiler will save more files (.bc, .o, .no-opt.bc) generated throughout compilation in the output directory.]'
     'rpath[If specified, then the rpath value for dynamic libraries will be set in either dynamic library or executable outputs.]'
     'no-prepopulate-passes[Suppresses pre-population of the LLVM pass manager that is run over the module.]'
@@ -86,55 +94,62 @@ _rustc_opts_codegen=(
     'prefer-dynamic[Prefers dynamic linking to static linking.]'
     "no-integrated-as[Force usage of an external assembler rather than LLVM's integrated one.]"
     'no-redzone[disable the use of the redzone]'
-    'relocation-model=[The relocation model to use. (default: pic)]:MODEL:(pic static dynamic-no-pic)'
-    'code-model=[choose the code model to use (llc -code-model for details)]:MODEL:'
-    'metadata=[metadata to mangle symbol names with]:VAL:'
-    'extra-filenames=[extra data to put in each output filename]:VAL:'
-    'codegen-units=[divide crate into N units to optimize in parallel]:N:'
+    'relocation-model[The relocation model to use. (default: pic)]:MODEL:(pic static dynamic-no-pic)'
+    'code-model[choose the code model to use (llc -code-model for details)]:MODEL:'
+    'metadata[metadata to mangle symbol names with]:VAL:'
+    'extra-filenames[extra data to put in each output filename]:VAL:'
+    'codegen-units[divide crate into N units to optimize in parallel]:N:'
+    'remark[print remarks for these optimization passes (space separated, or "all")]:TYPE:'
+    'debuginfo[debug info emission level, 0 = no debug info, 1 = line tables only, 2 = full debug info with variable and type information]:LEVEL:_values "Debug Levels" "$_rustc_debuginfo_levels[@]"'
+    'opt-level[Optimize with possible levels 0-3]:LEVEL:(0 1 2 3)'
     'help[Show all codegen options]'
 )
 
 _rustc_opts_lint=(
     'help[Show a list of all lints]'
-    'experimental[detects use of #\[experimental\] items]'
-    'heap-memory[use of any (Box type or @ type) heap memory]'
-    'managed-heap-memory[use of managed (@ type) heap memory]'
-    'missing-doc[detects missing documentation for public members]'
-    'non-uppercase-statics[static constants should have uppercase identifiers]'
-    'owned-heap-memory[use of owned (~ type) heap memory]'
-    'unnecessary-qualification[detects unnecessarily qualified names]'
-    'unsafe-block[usage of an `unsafe` block]'
-    'unstable[detects use of #\[unstable\] items (incl. items with no stability attribute)]'
-    'unused-result[unused result of an expression in a statement]'
-    'variant-size-difference[detects enums with widely varying variant sizes]'
-    'ctypes[proper use of libc types in foreign modules]'
-    'dead-assignment[detect assignments that will never be read]'
-    'dead-code[detect piece of code that will never be used]'
-    'deprecated[detects use of #\[deprecated\] items]'
-    'non-camel-case-types[types, variants and traits should have camel case names]'
-    'non-snake-case[methods, functions, lifetime parameters and modules should have snake case names]'
-    'path-statement[path statements with no effect]'
-    'raw-pointer-deriving[uses of #\[deriving\] with raw pointers are rarely correct]'
-    'type-limits[comparisons made useless by limits of the types involved]'
-    'type-overflow[literal out of range for its type]'
-    'unnecessary-allocation[detects unnecessary allocations that can be eliminated]'
-    'unnecessary-parens[`if`, `match`, `while` and `return` do not need parentheses]'
-    'unreachable-code[detects unreachable code]'
-    'unrecognized-lint[unrecognized lint attribute]'
-    'unsigned-negate[using an unary minus operator on unsigned type]'
-    'unused-attribute[detects attributes that were not used by the compiler]'
-    'unused-imports[imports that are never used]'
-    'unused-must-use[unused result of a type flagged as #\[must_use\]]'
-    "unused-mut[detect mut variables which don't need to be mutable]"
-    'unused-unsafe[unnecessary use of an `unsafe` block]'
-    'unused-variable[detect variables which are not used in any way]'
-    'visible-private-types[detect use of private types in exported type signatures]'
-    'warnings[mass-change the level for lints which produce warnings]'
-    'while-true[suggest using `loop { }` instead of `while true { }`]'
-    'unknown-crate-type[unknown crate type found in #\[crate_type\] directive]'
-    'unknown-features[unknown features found in crate-level #\[feature\] directives]'
-    'bad-style[group of non_camel_case_types, non_snake_case, non_uppercase_statics]'
-    'unused[group of unused_imports, unused_variable, dead_assignment, dead_code, unused_mut, unreachable_code]'
+    'box-pointers[(default: allow) use of owned (Box type) heap memory]'
+    'experimental[(default: allow) detects use of #\[experimental\] items]'
+    'fat-ptr-transmutes[(default: allow) detects transmutes of fat pointers]'
+    'missing-docs[(default: allow) detects missing documentation for public members]'
+    'unsafe-blocks[(default: allow) usage of an "unsafe" block]'
+    'unstable[(default: allow) detects use of #\[unstable\] items (incl. items with no stability attribute)]'
+    'unused-extern-crates[(default: allow) extern crates that are never used]'
+    'unused-import-braces[(default: allow) unnecessary braces around an imported item]'
+    'unused-qualifications[(default: allow) detects unnecessarily qualified names]'
+    'unused-results[(default: allow) unused result of an expression in a statement]'
+    'unused-typecasts[(default: allow) detects unnecessary type casts that can be removed]'
+    'variant-size-differences[(default: allow) detects enums with widely varying variant sizes]'
+    'dead-code[(default: warn) detect unused, unexported items]'
+    'deprecated[(default: warn) detects use of #\[deprecated\] items]'
+    'improper-ctypes[(default: warn) proper use of libc types in foreign modules]'
+    'missing-copy-implementations[(default: warn) detects potentially-forgotten implementations of "Copy"]'
+    'non-camel-case-types[(default: warn) types, variants, traits and type parameters should have camel case names]'
+    'non-shorthand-field-patterns[(default: warn) using "Struct { x: x }" instead of "Struct { x }"]'
+    'non-snake-case[(default: warn) methods, functions, lifetime parameters and modules should have snake case names]'
+    'non-upper-case-globals[(default: warn) static constants should have uppercase identifiers]'
+    'overflowing-literals[(default: warn) literal out of range for its type]'
+    'path-statements[(default: warn) path statements with no effect]'
+    'raw-pointer-deriving[(default: warn) uses of #\[derive\] with raw pointers are rarely correct]'
+    'unknown-lints[(default: warn) unrecognized lint attribute]'
+    'unreachable-code[(default: warn) detects unreachable code paths]'
+    'unsigned-negation[(default: warn) using an unary minus operator on unsigned type]'
+    'unused-allocation[(default: warn) detects unnecessary allocations that can be eliminated]'
+    'unused-assignments[(default: warn) detect assignments that will never be read]'
+    'unused-attributes[(default: warn) detects attributes that were not used by the compiler]'
+    'unused-comparisons[(default: warn) comparisons made useless by limits of the types involved]'
+    'unused-imports[(default: warn) imports that are never used]'
+    'unused-must-use[(default: warn) unused result of a type flagged as must_use]'
+    "unused-mut[(default: warn) detect mut variables which don't need to be mutable]"
+    'unused-parens[(default: warn) "if", "match", "while" and "return" do not need parentheses]'
+    'unused-unsafe[(default: warn) unnecessary use of an "unsafe" block]'
+    'unused-variables[(default: warn) detect variables which are not used in any way]'
+    'warnings[(default: warn) mass-change the level for lints which produce warnings]'
+    'while-true[(default: warn) suggest using "loop { }" instead of "while true { }"]'
+    "exceeding-bitshifts[(default: deny) shift exceeds the type's number of bits]"
+    'unknown-crate-types[(default: deny) unknown crate type found in #\[crate_type\] directive]'
+    'unknown-features[(default: deny) unknown features found in crate-level #\[feature\] directives]'
+    'bad-style[non-camel-case-types, non-snake-case, non-upper-case-globals]'
+    'unused[unused-imports, unused-variables, unused-assignments, dead-code, unused-mut, unreachable-code, unused-must-use, unused-unsafe, path-statements]'
 )
 
 _rustc_opts_debug=(
@@ -151,11 +166,9 @@ _rustc_opts_debug=(
     'show-span[show spans for compiler debugging]'
     'count-type-sizes[count the sizes of aggregate types]'
     'meta-stats[gather metadata statistics]'
-    'no-opt[do not optimize, even if -O is passed]'
     'print-link-args[Print the arguments passed to the linker]'
     'gc[Garbage collect shared data (experimental)]'
     'print-llvm-passes[Prints the llvm optimization passes being run]'
-    'lto[Perform LLVM link-time optimizations]'
     'ast-json[Print the AST as JSON and halt]'
     'ast-json-noexpand[Print the pre-expansion AST as JSON and halt]'
     'ls[List the symbols defined by a library crate]'
@@ -164,6 +177,12 @@ _rustc_opts_debug=(
     'flowgraph-print-moves[Include move analysis data in --pretty flowgraph output]'
     'flowgraph-print-assigns[Include assignment analysis data in --pretty flowgraph output]'
     'flowgraph-print-all[Include all dataflow analysis data in --pretty flowgraph output]'
+    'print-regiion-graph[Prints region inference graph. Use with RUST_REGION_GRAPH=help for more info]'
+    'parse-only[Parse only; do not compile, assemble, or link]'
+    'no-trans[Run all passes except translation; no output]'
+    'no-analysis[Parse and expand the source, but run no analysis]'
+    'unstable-options[Adds unstable command line options to rustc interface]'
+    'print-enum-sizes[Print the size of enums and their variants]'
 )
 
 _rustc_opts_fun_lint(){
@@ -179,13 +198,18 @@ _rustc_opts_fun_codegen(){
     _values 'options' "$_rustc_opts_codegen[@]"
 }
 
+_rustc_opts_fun_link(){
+    _values 'options' "$_rustc_opts_link[@]"
+}
+
 _arguments -s :  \
     '(-W --warn)'{-W,--warn=}'[Set lint warnings]:lint options:_rustc_opts_fun_lint' \
     '(-A --allow)'{-A,--allow=}'[Set lint allowed]:lint options:_rustc_opts_fun_lint' \
     '(-D --deny)'{-D,--deny=}'[Set lint denied]:lint options:_rustc_opts_fun_lint' \
     '(-F --forbid)'{-F,--forbid=}'[Set lint forbidden]:lint options:_rustc_opts_fun_lint' \
     '*-Z[Set internal debugging options]:debug options:_rustc_opts_fun_debug' \
-    '*-C[Set internal Codegen options]:codegen options:_rustc_opts_fun_codegen' \
+    '(-C --codegen)'{-C,--codegen}'[Set internal Codegen options]:codegen options:_rustc_opts_fun_codegen' \
+    '*-l[Link the generated crates to the specified native library NAME. the optional KIND can be one of, static, dylib, or framework. If omitted, dylib is assumed.]:ARG:_rustc_opts_fun_link' \
     "$_rustc_opts_switches[@]" \
     "$_rustc_opts_vals[@]" \
     '::files:_files -g "*.rs"'
index 25f80ad11bd1124b87ef34445b799b4dd67f80cf..8def8ad7215284b759b7a91a7de2c12234f9d5c5 100644 (file)
@@ -41,8 +41,8 @@
 //!     let five = five.clone();
 //!
 //!     Thread::spawn(move || {
-//!         println!("{}", five);
-//!     }).detach();
+//!         println!("{:?}", five);
+//!     });
 //! }
 //! ```
 //!
@@ -63,7 +63,7 @@
 //!         *number += 1;
 //!
 //!         println!("{}", *number); // prints 6
-//!     }).detach();
+//!     });
 //! }
 //! ```
 
@@ -74,7 +74,7 @@
 use core::fmt::{self, Show};
 use core::cmp::{Eq, Ord, PartialEq, PartialOrd, Ordering};
 use core::default::Default;
-use core::kinds::{Sync, Send};
+use core::marker::{Sync, Send};
 use core::mem::{min_align_of, size_of, drop};
 use core::mem;
 use core::nonzero::NonZero;
 ///             let local_numbers = child_numbers.as_slice();
 ///
 ///             // Work with the local numbers
-///         }).detach();
+///         });
 ///     }
 /// }
 /// ```
@@ -581,7 +581,7 @@ impl<T: Eq> Eq for Arc<T> {}
 
 impl<T: fmt::Show> fmt::Show for Arc<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        (**self).fmt(f)
+        write!(f, "Arc({:?})", (**self))
     }
 }
 
@@ -794,7 +794,7 @@ fn test_weak_count() {
     #[test]
     fn show_arc() {
         let a = Arc::new(5u32);
-        assert!(format!("{}", a) == "5")
+        assert!(format!("{:?}", a) == "Arc(5u32)")
     }
 
     // Make sure deriving works with Arc<T>
index 6df8bb5f7aaf4b146b76b88ea00850932c17b7e3..d46f18abf97b481f781225bc42b7d291cc399f37 100644 (file)
@@ -18,7 +18,7 @@
 use core::default::Default;
 use core::fmt;
 use core::hash::{self, Hash};
-use core::kinds::Sized;
+use core::marker::Sized;
 use core::mem;
 use core::option::Option;
 use core::ptr::Unique;
@@ -145,7 +145,13 @@ fn downcast<T: 'static>(self) -> Result<Box<T>, Box<Any>> {
 
 impl<T: ?Sized + fmt::Show> fmt::Show for Box<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        (**self).fmt(f)
+        write!(f, "Box({:?})", &**self)
+    }
+}
+
+impl<T: ?Sized + fmt::String> fmt::String for Box<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(&**self, f)
     }
 }
 
index 001e02f9c0dd5c29cc91e2f0f25ecd51b4697e86..ba6e89cdd768e5016ec408f43c7206e00fa41876 100644 (file)
 
 #![no_std]
 #![allow(unknown_features)]
-#![feature(lang_items, phase, unsafe_destructor, default_type_params, old_orphan_check)]
-#![feature(associated_types)]
+#![feature(lang_items, unsafe_destructor)]
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate core;
-
-#[cfg(not(stage0))]
 #[macro_use]
 extern crate core;
-
 extern crate libc;
 
 // Allow testing this library
 
-#[cfg(all(test, stage0))]
-#[phase(plugin, link)]
-extern crate std;
-
-#[cfg(all(test, not(stage0)))]
-#[macro_use]
-extern crate std;
-
-#[cfg(all(test, stage0))]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(all(test, not(stage0)))]
-#[macro_use]
-extern crate log;
+#[cfg(test)] #[macro_use] extern crate std;
+#[cfg(test)] #[macro_use] extern crate log;
 
 // Heaps provided for low-level allocation strategies
 
index 175bba4e71dc46f9671f04658e5a3b034914a43e..67b254277101229ae9d8bab6de237e4fc28cf90d 100644 (file)
 use core::default::Default;
 use core::fmt;
 use core::hash::{self, Hash};
-use core::kinds::marker;
+use core::marker;
 use core::mem::{transmute, min_align_of, size_of, forget};
 use core::nonzero::NonZero;
 use core::ops::{Deref, Drop};
@@ -607,7 +607,7 @@ fn hash(&self, state: &mut S) {
 #[experimental = "Show is experimental."]
 impl<T: fmt::Show> fmt::Show for Rc<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        (**self).fmt(f)
+        write!(f, "Rc({:?})", **self)
     }
 }
 
@@ -962,4 +962,10 @@ fn test_cowrc_clone_weak() {
         assert!(cow1_weak.upgrade().is_none());
     }
 
+    #[test]
+    fn test_show() {
+        let foo = Rc::new(75u);
+        assert!(format!("{:?}", foo) == "Rc(75u)")
+    }
+
 }
index c092e000215d3ffdc1858c3bbf5762a2abf2b8a2..2154d06377a198913632f25f5ec58e90300e3572 100644 (file)
@@ -143,17 +143,17 @@ fn match_words <'a,'b>(a: &'a Bitv, b: &'b Bitv) -> (MatchWords<'a>, MatchWords<
 /// bv.set(3, true);
 /// bv.set(5, true);
 /// bv.set(7, true);
-/// println!("{}", bv.to_string());
+/// println!("{:?}", bv);
 /// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
 ///
 /// // flip all values in bitvector, producing non-primes less than 10
 /// bv.negate();
-/// println!("{}", bv.to_string());
+/// println!("{:?}", bv);
 /// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
 ///
 /// // reset bitvector to empty
 /// bv.clear();
-/// println!("{}", bv.to_string());
+/// println!("{:?}", bv);
 /// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
 /// ```
 #[stable]
@@ -330,7 +330,7 @@ pub fn from_bytes(bytes: &[u8]) -> Bitv {
 
         if extra_bytes > 0 {
             let mut last_word = 0u32;
-            for (i, &byte) in bytes[complete_words*4..].iter().enumerate() {
+            for (i, &byte) in bytes.index(&((complete_words*4)..)).iter().enumerate() {
                 last_word |= (reverse_bits(byte) as u32) << (i * 8);
             }
             bitv.storage.push(last_word);
@@ -1729,13 +1729,13 @@ pub fn remove(&mut self, value: &uint) -> bool {
 
 impl fmt::Show for BitvSet {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(fmt, "{{"));
+        try!(write!(fmt, "BitvSet {{"));
         let mut first = true;
         for n in self.iter() {
             if !first {
                 try!(write!(fmt, ", "));
             }
-            try!(write!(fmt, "{}", n));
+            try!(write!(fmt, "{:?}", n));
             first = false;
         }
         write!(fmt, "}}")
@@ -1881,10 +1881,10 @@ mod tests {
     #[test]
     fn test_to_str() {
         let zerolen = Bitv::new();
-        assert_eq!(zerolen.to_string(), "");
+        assert_eq!(format!("{:?}", zerolen), "");
 
         let eightbits = Bitv::from_elem(8u, false);
-        assert_eq!(eightbits.to_string(), "00000000")
+        assert_eq!(format!("{:?}", eightbits), "00000000")
     }
 
     #[test]
@@ -1910,7 +1910,7 @@ fn test_2_elements() {
         let mut b = Bitv::from_elem(2, false);
         b.set(0, true);
         b.set(1, false);
-        assert_eq!(b.to_string(), "10");
+        assert_eq!(format!("{:?}", b), "10");
         assert!(!b.none() && !b.all());
     }
 
@@ -2245,7 +2245,7 @@ fn test_equal_sneaky_big() {
     fn test_from_bytes() {
         let bitv = Bitv::from_bytes(&[0b10110110, 0b00000000, 0b11111111]);
         let str = concat!("10110110", "00000000", "11111111");
-        assert_eq!(bitv.to_string(), str);
+        assert_eq!(format!("{:?}", bitv), str);
     }
 
     #[test]
@@ -2264,7 +2264,7 @@ fn test_to_bytes() {
     fn test_from_bools() {
         let bools = vec![true, false, true, true];
         let bitv: Bitv = bools.iter().map(|n| *n).collect();
-        assert_eq!(bitv.to_string(), "1011");
+        assert_eq!(format!("{:?}", bitv), "1011");
     }
 
     #[test]
@@ -2622,7 +2622,7 @@ fn test_bitv_set_show() {
         s.insert(10);
         s.insert(50);
         s.insert(2);
-        assert_eq!("{1, 2, 10, 50}", s.to_string());
+        assert_eq!("BitvSet {1u, 2u, 10u, 50u}", format!("{:?}", s));
     }
 
     #[test]
index b85ea65f5ce5880140611f8be2d09687be61c5d0..4e44779810b29257aa88309e5e2ee7c5f0f569f0 100644 (file)
@@ -19,7 +19,7 @@
 
 use core::prelude::*;
 
-use core::borrow::{BorrowFrom, ToOwned};
+use core::borrow::BorrowFrom;
 use core::cmp::Ordering;
 use core::default::Default;
 use core::fmt::Show;
@@ -128,24 +128,24 @@ pub struct Values<'a, K: 'a, V: 'a> {
     inner: Map<(&'a K, &'a V), &'a V, Iter<'a, K, V>, fn((&'a K, &'a V)) -> &'a V>
 }
 
-#[stable]
 /// A view into a single entry in a map, which may either be vacant or occupied.
-pub enum Entry<'a, Q: ?Sized +'a, K:'a, V:'a> {
+#[unstable = "precise API still under development"]
+pub enum Entry<'a, K:'a, V:'a> {
     /// A vacant Entry
-    Vacant(VacantEntry<'a, Q, K, V>),
+    Vacant(VacantEntry<'a, K, V>),
     /// An occupied Entry
     Occupied(OccupiedEntry<'a, K, V>),
 }
 
-#[stable]
 /// A vacant Entry.
-pub struct VacantEntry<'a, Q: ?Sized +'a, K:'a, V:'a> {
-    key: &'a Q,
+#[unstable = "precise API still under development"]
+pub struct VacantEntry<'a, K:'a, V:'a> {
+    key: K,
     stack: stack::SearchStack<'a, K, V, node::handle::Edge, node::handle::Leaf>,
 }
 
-#[stable]
 /// An occupied Entry.
+#[unstable = "precise API still under development"]
 pub struct OccupiedEntry<'a, K:'a, V:'a> {
     stack: stack::SearchStack<'a, K, V, node::handle::KV, node::handle::LeafOrInternal>,
 }
@@ -480,7 +480,7 @@ enum Continuation<A, B> {
 /// boilerplate gets cut out.
 mod stack {
     use core::prelude::*;
-    use core::kinds::marker;
+    use core::marker;
     use core::mem;
     use core::ops::{Deref, DerefMut};
     use super::BTreeMap;
@@ -866,11 +866,11 @@ fn cmp(&self, other: &BTreeMap<K, V>) -> Ordering {
 #[stable]
 impl<K: Show, V: Show> Show for BTreeMap<K, V> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
+        try!(write!(f, "BTreeMap {{"));
 
         for (i, (k, v)) in self.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{}: {}", *k, *v));
+            try!(write!(f, "{:?}: {:?}", *k, *v));
         }
 
         write!(f, "}}")
@@ -933,7 +933,7 @@ enum StackOp<T> {
 }
 
 impl<K, V, E, T> Iterator for AbsIter<T> where
-    T: DoubleEndedIterator + Iterator<Item=TraversalItem<K, V, E>> + Traverse<E>,
+    T: DoubleEndedIterator<Item=TraversalItem<K, V, E>> + Traverse<E>,
 {
     type Item = (K, V);
 
@@ -1002,7 +1002,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 }
 
 impl<K, V, E, T> DoubleEndedIterator for AbsIter<T> where
-    T: DoubleEndedIterator + Iterator<Item=TraversalItem<K, V, E>> + Traverse<E>,
+    T: DoubleEndedIterator<Item=TraversalItem<K, V, E>> + Traverse<E>,
 {
     // next_back is totally symmetric to next
     fn next_back(&mut self) -> Option<(K, V)> {
@@ -1111,10 +1111,10 @@ fn next_back(&mut self) -> Option<(&'a V)> { self.inner.next_back() }
 #[stable]
 impl<'a, K, V> ExactSizeIterator for Values<'a, K, V> {}
 
-impl<'a, Q: ?Sized, K: Ord, V> Entry<'a, Q, K, V> {
+impl<'a, K: Ord, V> Entry<'a, K, V> {
     #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
-    pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
+    pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
         match self {
             Occupied(entry) => Ok(entry.into_mut()),
             Vacant(entry) => Err(entry),
@@ -1122,44 +1122,44 @@ pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
     }
 }
 
-impl<'a, Q: ?Sized + ToOwned<K>, K: Ord, V> VacantEntry<'a, Q, K, V> {
-    #[stable]
+impl<'a, K: Ord, V> VacantEntry<'a, K, V> {
     /// Sets the value of the entry with the VacantEntry's key,
     /// and returns a mutable reference to it.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn insert(self, value: V) -> &'a mut V {
-        self.stack.insert(self.key.to_owned(), value)
+        self.stack.insert(self.key, value)
     }
 }
 
 impl<'a, K: Ord, V> OccupiedEntry<'a, K, V> {
-    #[stable]
     /// Gets a reference to the value in the entry.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn get(&self) -> &V {
         self.stack.peek()
     }
 
-    #[stable]
     /// Gets a mutable reference to the value in the entry.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn get_mut(&mut self) -> &mut V {
         self.stack.peek_mut()
     }
 
-    #[stable]
     /// Converts the entry into a mutable reference to its value.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn into_mut(self) -> &'a mut V {
         self.stack.into_top()
     }
 
-    #[stable]
     /// Sets the value of the entry with the OccupiedEntry's key,
     /// and returns the entry's old value.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn insert(&mut self, mut value: V) -> V {
         mem::swap(self.stack.peek_mut(), &mut value);
         value
     }
 
-    #[stable]
     /// Takes the value of the entry out of the map, and returns it.
+    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
     pub fn remove(self) -> V {
         self.stack.remove()
     }
@@ -1347,7 +1347,7 @@ impl<K: Ord, V> BTreeMap<K, V> {
     ///
     /// // count the number of occurrences of letters in the vec
     /// for x in vec!["a","b","a","c","a","b"].iter() {
-    ///     match count.entry(x) {
+    ///     match count.entry(*x) {
     ///         Entry::Vacant(view) => {
     ///             view.insert(1);
     ///         },
@@ -1361,15 +1361,13 @@ impl<K: Ord, V> BTreeMap<K, V> {
     /// assert_eq!(count["a"], 3u);
     /// ```
     /// The key must have the same ordering before or after `.to_owned()` is called.
-    #[stable]
-    pub fn entry<'a, Q: ?Sized>(&'a mut self, mut key: &'a Q) -> Entry<'a, Q, K, V>
-        where Q: Ord + ToOwned<K>
-    {
+    #[unstable = "precise API still under development"]
+    pub fn entry<'a>(&'a mut self, mut key: K) -> Entry<'a, K, V> {
         // same basic logic of `swap` and `pop`, blended together
         let mut stack = stack::PartialSearchStack::new(self);
         loop {
             let result = stack.with(move |pusher, node| {
-                return match Node::search(node, key) {
+                return match Node::search(node, &key) {
                     Found(handle) => {
                         // Perfect match
                         Finished(Occupied(OccupiedEntry {
@@ -1412,7 +1410,7 @@ pub fn entry<'a, Q: ?Sized>(&'a mut self, mut key: &'a Q) -> Entry<'a, Q, K, V>
 #[cfg(test)]
 mod test {
     use prelude::*;
-    use std::borrow::{ToOwned, BorrowFrom};
+    use std::borrow::BorrowFrom;
 
     use super::{BTreeMap, Occupied, Vacant};
 
@@ -1562,7 +1560,7 @@ fn test_entry(){
         let mut map: BTreeMap<int, int> = xs.iter().map(|&x| x).collect();
 
         // Existing key (insert)
-        match map.entry(&1) {
+        match map.entry(1) {
             Vacant(_) => unreachable!(),
             Occupied(mut view) => {
                 assert_eq!(view.get(), &10);
@@ -1574,7 +1572,7 @@ fn test_entry(){
 
 
         // Existing key (update)
-        match map.entry(&2) {
+        match map.entry(2) {
             Vacant(_) => unreachable!(),
             Occupied(mut view) => {
                 let v = view.get_mut();
@@ -1585,7 +1583,7 @@ fn test_entry(){
         assert_eq!(map.len(), 6);
 
         // Existing key (take)
-        match map.entry(&3) {
+        match map.entry(3) {
             Vacant(_) => unreachable!(),
             Occupied(view) => {
                 assert_eq!(view.remove(), 30);
@@ -1596,7 +1594,7 @@ fn test_entry(){
 
 
         // Inexistent key (insert)
-        match map.entry(&10) {
+        match map.entry(10) {
             Occupied(_) => unreachable!(),
             Vacant(view) => {
                 assert_eq!(*view.insert(1000), 1000);
index 250411092a8e70b02fda912170d050e90583e899..7d5422290e25ad1493728a8ee646962fef94ddbf 100644 (file)
@@ -493,7 +493,7 @@ fn clone(&self) -> Node<K, V> {
 ///     // Now the handle still points at index 75, but on the small node, which has no index 75.
 ///     flag.set(true);
 ///
-///     println!("Uninitialized memory: {}", handle.into_kv());
+///     println!("Uninitialized memory: {:?}", handle.into_kv());
 /// }
 /// ```
 #[derive(Copy)]
@@ -1417,7 +1417,7 @@ pub enum TraversalItem<K, V, E> {
 /// An owning traversal over a node's entries and edges
 pub type MoveTraversal<K, V> = AbsTraversal<MoveTraversalImpl<K, V>>;
 
-
+#[old_impl_check]
 impl<K, V, E, Impl: TraversalImpl<K, V, E>> Iterator for AbsTraversal<Impl> {
     type Item = TraversalItem<K, V, E>;
 
@@ -1433,6 +1433,7 @@ fn next(&mut self) -> Option<TraversalItem<K, V, E>> {
     }
 }
 
+#[old_impl_check]
 impl<K, V, E, Impl: TraversalImpl<K, V, E>> DoubleEndedIterator for AbsTraversal<Impl> {
     fn next_back(&mut self) -> Option<TraversalItem<K, V, E>> {
         let tail_is_edge = self.tail_is_edge;
index 98f163321706041f81f7fb731f81726ba79b1303..25df4a3cc2a6fc61d168e9dbc5e1940c87aa1905 100644 (file)
@@ -556,11 +556,11 @@ fn bitor(self, rhs: &BTreeSet<T>) -> BTreeSet<T> {
 #[stable]
 impl<T: Show> Show for BTreeSet<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
+        try!(write!(f, "BTreeSet {{"));
 
         for (i, x) in self.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{}", *x));
+            try!(write!(f, "{:?}", *x));
         }
 
         write!(f, "}}")
@@ -842,9 +842,9 @@ fn test_show() {
         set.insert(1);
         set.insert(2);
 
-        let set_str = format!("{}", set);
+        let set_str = format!("{:?}", set);
 
-        assert!(set_str == "{1, 2}");
-        assert_eq!(format!("{}", empty), "{}");
+        assert_eq!(set_str, "BTreeSet {1i, 2i}");
+        assert_eq!(format!("{:?}", empty), "BTreeSet {}");
     }
 }
index 5e08f90ce1c536368aef61df7e5577e675932a1e..63ea9f7cb4322dad9e791ef710fa7b822a60673d 100644 (file)
@@ -663,11 +663,11 @@ fn clone(&self) -> DList<A> {
 #[stable]
 impl<A: fmt::Show> fmt::Show for DList<A> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "["));
+        try!(write!(f, "DList ["));
 
         for (i, e) in self.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{}", *e));
+            try!(write!(f, "{:?}", *e));
         }
 
         write!(f, "]")
@@ -924,7 +924,7 @@ fn test_mut_rev_iter() {
     #[test]
     fn test_send() {
         let n = list_from(&[1i,2,3]);
-        Thread::spawn(move || {
+        Thread::scoped(move || {
             check_links(&n);
             let a: &[_] = &[&1,&2,&3];
             assert_eq!(a, n.iter().collect::<Vec<&int>>());
@@ -1018,12 +1018,12 @@ fn test_fuzz() {
     #[test]
     fn test_show() {
         let list: DList<int> = range(0i, 10).collect();
-        assert!(list.to_string() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
+        assert_eq!(format!("{:?}", list), "DList [0i, 1i, 2i, 3i, 4i, 5i, 6i, 7i, 8i, 9i]");
 
         let list: DList<&str> = vec!["just", "one", "test", "more"].iter()
                                                                    .map(|&s| s)
                                                                    .collect();
-        assert!(list.to_string() == "[just, one, test, more]");
+        assert_eq!(format!("{:?}", list), "DList [\"just\", \"one\", \"test\", \"more\"]");
     }
 
     #[cfg(test)]
index 4b94348e87ae3c3713dd99ab97e97e8a7310bdf7..1b852d0ba680d20a07a8b29325957e2dea95287c 100644 (file)
@@ -33,13 +33,13 @@ impl<E> Copy for EnumSet<E> {}
 
 impl<E:CLike+fmt::Show> fmt::Show for EnumSet<E> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(fmt, "{{"));
+        try!(write!(fmt, "EnumSet {{"));
         let mut first = true;
         for e in self.iter() {
             if !first {
                 try!(write!(fmt, ", "));
             }
-            try!(write!(fmt, "{}", e));
+            try!(write!(fmt, "{:?}", e));
             first = false;
         }
         write!(fmt, "}}")
@@ -287,11 +287,11 @@ fn test_new() {
     #[test]
     fn test_show() {
         let mut e = EnumSet::new();
-        assert_eq!("{}", e.to_string());
+        assert!(format!("{:?}", e) == "EnumSet {}");
         e.insert(A);
-        assert_eq!("{A}", e.to_string());
+        assert!(format!("{:?}", e) == "EnumSet {A}");
         e.insert(C);
-        assert_eq!("{A, C}", e.to_string());
+        assert!(format!("{:?}", e) == "EnumSet {A, C}");
     }
 
     #[test]
index 5bf5f78af94c272381f14d4581bdb9b1946d9c00..6eab36d8844df9372b9e55c567500c007d912bf3 100644 (file)
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![allow(unknown_features)]
-#![feature(macro_rules, default_type_params, phase, globs)]
 #![feature(unsafe_destructor, slicing_syntax)]
+#![feature(old_impl_check)]
 #![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
-#![feature(associated_types)]
 #![no_std]
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate core;
-
-#[cfg(not(stage0))]
 #[macro_use]
 extern crate core;
 
 extern crate alloc;
 
 #[cfg(test)] extern crate test;
-
-#[cfg(all(test, stage0))]
-#[phase(plugin, link)]
-extern crate std;
-
-#[cfg(all(test, not(stage0)))]
-#[macro_use]
-extern crate std;
-
-#[cfg(all(test, stage0))]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(all(test, not(stage0)))]
-#[macro_use]
-extern crate log;
+#[cfg(test)] #[macro_use] extern crate std;
+#[cfg(test)] #[macro_use] extern crate log;
 
 pub use binary_heap::BinaryHeap;
 pub use bitv::Bitv;
@@ -73,8 +52,7 @@
 // Needed for the vec! macro
 pub use alloc::boxed;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod macros;
 
 pub mod binary_heap;
@@ -123,7 +101,9 @@ mod std {
     pub use core::option;   // necessary for panic!()
     pub use core::clone;    // deriving(Clone)
     pub use core::cmp;      // deriving(Eq, Ord, etc.)
-    pub use core::kinds;    // deriving(Copy)
+    #[cfg(stage0)]
+    pub use core::marker as kinds;
+    pub use core::marker;  // deriving(Copy)
     pub use core::hash;     // deriving(Hash)
 }
 
@@ -138,7 +118,7 @@ mod prelude {
     pub use core::iter::{FromIterator, Extend, IteratorExt};
     pub use core::iter::{Iterator, DoubleEndedIterator, RandomAccessIterator};
     pub use core::iter::{ExactSizeIterator};
-    pub use core::kinds::{Copy, Send, Sized, Sync};
+    pub use core::marker::{Copy, Send, Sized, Sync};
     pub use core::mem::drop;
     pub use core::ops::{Drop, Fn, FnMut, FnOnce};
     pub use core::option::Option;
index 0c5929e8661d6d22870fbab4f215118834675009..68e2482964dbb87c3152b8435e92ea02c8cd183e 100644 (file)
@@ -8,21 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-/// Creates a `std::vec::Vec` containing the arguments.
-// NOTE: remove after the next snapshot
-#[cfg(stage0)]
-macro_rules! vec {
-    ($($e:expr),*) => ({
-        // leading _ to allow empty construction without a warning.
-        let mut _temp = ::vec::Vec::new();
-        $(_temp.push($e);)*
-        _temp
-    });
-    ($($e:expr),+,) => (vec!($($e),+))
-}
-
 /// Creates a `Vec` containing the arguments.
-#[cfg(not(stage0))]
 #[macro_export]
 macro_rules! vec {
     ($($x:expr),*) => ({
index 11775f62b1c547660826fcef88d1164d00cdf0be..42c17136a0882824c6c17029ff6bd5e46f28ce42 100644 (file)
@@ -20,7 +20,7 @@
 use core::default::Default;
 use core::fmt;
 use core::iter::{self, repeat, FromIterator, RandomAccessIterator};
-use core::kinds::marker;
+use core::marker;
 use core::mem;
 use core::num::{Int, UnsignedInt};
 use core::ops::{Index, IndexMut};
@@ -525,7 +525,7 @@ pub fn iter(&self) -> Iter<T> {
     ///     *num = *num - 2;
     /// }
     /// let b: &[_] = &[&mut 3, &mut 1, &mut 2];
-    /// assert_eq!(buf.iter_mut().collect::<Vec<&mut int>>()[], b);
+    /// assert_eq!(&buf.iter_mut().collect::<Vec<&mut int>>()[], b);
     /// ```
     #[stable]
     pub fn iter_mut<'a>(&'a mut self) -> IterMut<'a, T> {
@@ -556,7 +556,7 @@ pub fn as_slices<'a>(&'a self) -> (&'a [T], &'a [T]) {
             let buf = self.buffer_as_slice();
             if contiguous {
                 let (empty, buf) = buf.split_at(0);
-                (buf[self.tail..self.head], empty)
+                (buf.index(&(self.tail..self.head)), empty)
             } else {
                 let (mid, right) = buf.split_at(self.tail);
                 let (left, _) = mid.split_at(self.head);
@@ -1613,11 +1613,11 @@ fn extend<T: Iterator<Item=A>>(&mut self, mut iterator: T) {
 #[stable]
 impl<T: fmt::Show> fmt::Show for RingBuf<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "["));
+        try!(write!(f, "RingBuf ["));
 
         for (i, e) in self.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{}", *e));
+            try!(write!(f, "{:?}", *e));
         }
 
         write!(f, "]")
@@ -1648,21 +1648,15 @@ fn test_simple() {
         assert_eq!(d.len(), 3u);
         d.push_back(137);
         assert_eq!(d.len(), 4u);
-        debug!("{}", d.front());
         assert_eq!(*d.front().unwrap(), 42);
-        debug!("{}", d.back());
         assert_eq!(*d.back().unwrap(), 137);
         let mut i = d.pop_front();
-        debug!("{}", i);
         assert_eq!(i, Some(42));
         i = d.pop_back();
-        debug!("{}", i);
         assert_eq!(i, Some(137));
         i = d.pop_back();
-        debug!("{}", i);
         assert_eq!(i, Some(137));
         i = d.pop_back();
-        debug!("{}", i);
         assert_eq!(i, Some(17));
         assert_eq!(d.len(), 0u);
         d.push_back(3);
@@ -2308,12 +2302,12 @@ fn test_ord() {
     #[test]
     fn test_show() {
         let ringbuf: RingBuf<int> = range(0i, 10).collect();
-        assert!(format!("{}", ringbuf) == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
+        assert_eq!(format!("{:?}", ringbuf), "RingBuf [0i, 1i, 2i, 3i, 4i, 5i, 6i, 7i, 8i, 9i]");
 
         let ringbuf: RingBuf<&str> = vec!["just", "one", "test", "more"].iter()
                                                                         .map(|&s| s)
                                                                         .collect();
-        assert!(format!("{}", ringbuf) == "[just, one, test, more]");
+        assert_eq!(format!("{:?}", ringbuf), "RingBuf [\"just\", \"one\", \"test\", \"more\"]");
     }
 
     #[test]
index 52e363eb67656dd7acebbc919f801505e6bc90a8..61309f0cc0fe869ab3476275fd832043c6445c0c 100644 (file)
@@ -55,7 +55,7 @@
 //! #![feature(slicing_syntax)]
 //! fn main() {
 //!     let numbers = [0i, 1i, 2i];
-//!     let last_numbers = numbers[1..3];
+//!     let last_numbers = numbers.index(&(1..3));
 //!     // last_numbers is now &[1i, 2i]
 //! }
 //! ```
 use core::cmp::{self, Ord, PartialEq};
 use core::iter::{Iterator, IteratorExt};
 use core::iter::{range, range_step, MultiplicativeIterator};
-use core::kinds::Sized;
+use core::marker::Sized;
 use core::mem::size_of;
 use core::mem;
-use core::ops::{FnMut, SliceMut};
+use core::ops::{FnMut, FullRange, Index, IndexMut};
 use core::option::Option::{self, Some, None};
 use core::ptr::PtrExt;
 use core::ptr;
@@ -1065,12 +1065,12 @@ pub fn new(length: uint) -> ElementSwaps {
 
 #[unstable = "trait is unstable"]
 impl<T> BorrowFrom<Vec<T>> for [T] {
-    fn borrow_from(owned: &Vec<T>) -> &[T] { owned[] }
+    fn borrow_from(owned: &Vec<T>) -> &[T] { owned.index(&FullRange) }
 }
 
 #[unstable = "trait is unstable"]
 impl<T> BorrowFromMut<Vec<T>> for [T] {
-    fn borrow_from_mut(owned: &mut Vec<T>) -> &mut [T] { owned.as_mut_slice_() }
+    fn borrow_from_mut(owned: &mut Vec<T>) -> &mut [T] { owned.index_mut(&FullRange) }
 }
 
 #[unstable = "trait is unstable"]
@@ -1393,15 +1393,20 @@ unsafe fn step<T>(ptr: &mut *mut T) -> *mut T {
 
 #[cfg(test)]
 mod tests {
-    use prelude::{Some, None, range, Vec, ToString, Clone, Greater, Less, Equal};
-    use prelude::{SliceExt, Iterator, IteratorExt};
-    use prelude::AsSlice;
-    use prelude::{RandomAccessIterator, Ord, SliceConcatExt};
+    use core::cmp::Ordering::{Greater, Less, Equal};
+    use core::prelude::{Some, None, range, Clone};
+    use core::prelude::{Iterator, IteratorExt};
+    use core::prelude::{AsSlice};
+    use core::prelude::{Ord, FullRange};
     use core::default::Default;
     use core::mem;
+    use core::ops::Index;
+    use std::iter::RandomAccessIterator;
     use std::rand::{Rng, thread_rng};
     use std::rc::Rc;
-    use super::ElementSwaps;
+    use string::ToString;
+    use vec::Vec;
+    use super::{ElementSwaps, SliceConcatExt, SliceExt};
 
     fn square(n: uint) -> uint { n * n }
 
@@ -1606,7 +1611,7 @@ fn test_slice() {
 
         // Test on stack.
         let vec_stack: &[_] = &[1i, 2, 3];
-        let v_b = vec_stack[1u..3u].to_vec();
+        let v_b = vec_stack.index(&(1u..3u)).to_vec();
         assert_eq!(v_b.len(), 2u);
         let v_b = v_b.as_slice();
         assert_eq!(v_b[0], 2);
@@ -1614,7 +1619,7 @@ fn test_slice() {
 
         // Test `Box<[T]>`
         let vec_unique = vec![1i, 2, 3, 4, 5, 6];
-        let v_d = vec_unique[1u..6u].to_vec();
+        let v_d = vec_unique.index(&(1u..6u)).to_vec();
         assert_eq!(v_d.len(), 5u);
         let v_d = v_d.as_slice();
         assert_eq!(v_d[0], 2);
@@ -1627,21 +1632,21 @@ fn test_slice() {
     #[test]
     fn test_slice_from() {
         let vec: &[int] = &[1, 2, 3, 4];
-        assert_eq!(vec[0..], vec);
+        assert_eq!(vec.index(&(0..)), vec);
         let b: &[int] = &[3, 4];
-        assert_eq!(vec[2..], b);
+        assert_eq!(vec.index(&(2..)), b);
         let b: &[int] = &[];
-        assert_eq!(vec[4..], b);
+        assert_eq!(vec.index(&(4..)), b);
     }
 
     #[test]
     fn test_slice_to() {
         let vec: &[int] = &[1, 2, 3, 4];
-        assert_eq!(vec[..4], vec);
+        assert_eq!(vec.index(&(0..4)), vec);
         let b: &[int] = &[1, 2];
-        assert_eq!(vec[..2], b);
+        assert_eq!(vec.index(&(0..2)), b);
         let b: &[int] = &[];
-        assert_eq!(vec[..0], b);
+        assert_eq!(vec.index(&(0..0)), b);
     }
 
 
@@ -2466,25 +2471,25 @@ fn test_show() {
         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);
+                assert_eq!(format!("{:?}", x.as_slice()), x_str);
             })
         }
         let empty: Vec<int> = vec![];
         test_show_vec!(empty, "[]");
-        test_show_vec!(vec![1i], "[1]");
-        test_show_vec!(vec![1i, 2, 3], "[1, 2, 3]");
+        test_show_vec!(vec![1i], "[1i]");
+        test_show_vec!(vec![1i, 2, 3], "[1i, 2i, 3i]");
         test_show_vec!(vec![vec![], vec![1u], vec![1u, 1u]],
-                       "[[], [1], [1, 1]]");
+                       "[[], [1u], [1u, 1u]]");
 
         let empty_mut: &mut [int] = &mut[];
         test_show_vec!(empty_mut, "[]");
         let v: &mut[int] = &mut[1];
-        test_show_vec!(v, "[1]");
+        test_show_vec!(v, "[1i]");
         let v: &mut[int] = &mut[1, 2, 3];
-        test_show_vec!(v, "[1, 2, 3]");
+        test_show_vec!(v, "[1i, 2i, 3i]");
         let v: &mut [&mut[uint]] = &mut[&mut[], &mut[1u], &mut[1u, 1u]];
-        test_show_vec!(v, "[[], [1], [1, 1]]");
+        test_show_vec!(v, "[[], [1u], [1u, 1u]]");
     }
 
     #[test]
@@ -2567,7 +2572,7 @@ fn test_iter_zero_sized() {
         }
         assert_eq!(cnt, 3);
 
-        for f in v[1..3].iter() {
+        for f in v.index(&(1..3)).iter() {
             assert!(*f == Foo);
             cnt += 1;
         }
index c0482702ccdb66c1a6ee149ebaa0811d7a66808b..09d140067f451902fe7649a84ee51df73084d8cf 100644 (file)
@@ -60,7 +60,7 @@
 use core::clone::Clone;
 use core::iter::AdditiveIterator;
 use core::iter::{range, Iterator, IteratorExt};
-use core::ops;
+use core::ops::{FullRange, Index};
 use core::option::Option::{self, Some, None};
 use core::slice::AsSlice;
 use core::str as core_str;
@@ -386,7 +386,7 @@ macro_rules! utf8_acc_cont_byte {
 
 #[unstable = "trait is unstable"]
 impl BorrowFrom<String> for str {
-    fn borrow_from(owned: &String) -> &str { owned[] }
+    fn borrow_from(owned: &String) -> &str { owned.index(&FullRange) }
 }
 
 #[unstable = "trait is unstable"]
@@ -408,7 +408,7 @@ fn to_owned(&self) -> String {
 
 /// Any string that can be represented as a slice.
 #[stable]
-pub trait StrExt: ops::Slice<uint, str> {
+pub trait StrExt: Index<FullRange, Output = str> {
     /// Escapes each char in `s` with `char::escape_default`.
     #[unstable = "return type may change to be an iterator"]
     fn escape_default(&self) -> String {
@@ -464,7 +464,7 @@ fn replace(&self, from: &str, to: &str) -> String {
     #[unstable = "this functionality may be moved to libunicode"]
     fn nfd_chars<'a>(&'a self) -> Decompositions<'a> {
         Decompositions {
-            iter: self[].chars(),
+            iter: self.index(&FullRange).chars(),
             buffer: Vec::new(),
             sorted: false,
             kind: Canonical
@@ -477,7 +477,7 @@ fn nfd_chars<'a>(&'a self) -> Decompositions<'a> {
     #[unstable = "this functionality may be moved to libunicode"]
     fn nfkd_chars<'a>(&'a self) -> Decompositions<'a> {
         Decompositions {
-            iter: self[].chars(),
+            iter: self.index(&FullRange).chars(),
             buffer: Vec::new(),
             sorted: false,
             kind: Compatible
@@ -525,7 +525,7 @@ fn nfkc_chars<'a>(&'a self) -> Recompositions<'a> {
     /// ```
     #[stable]
     fn contains(&self, pat: &str) -> bool {
-        core_str::StrExt::contains(self[], pat)
+        core_str::StrExt::contains(self.index(&FullRange), pat)
     }
 
     /// Returns true if a string contains a char pattern.
@@ -541,7 +541,7 @@ fn contains(&self, pat: &str) -> bool {
     /// ```
     #[unstable = "might get removed in favour of a more generic contains()"]
     fn contains_char<P: CharEq>(&self, pat: P) -> bool {
-        core_str::StrExt::contains_char(self[], pat)
+        core_str::StrExt::contains_char(self.index(&FullRange), pat)
     }
 
     /// An iterator over the characters of `self`. Note, this iterates
@@ -555,7 +555,7 @@ fn contains_char<P: CharEq>(&self, pat: P) -> bool {
     /// ```
     #[stable]
     fn chars(&self) -> Chars {
-        core_str::StrExt::chars(self[])
+        core_str::StrExt::chars(self.index(&FullRange))
     }
 
     /// An iterator over the bytes of `self`
@@ -568,13 +568,13 @@ fn chars(&self) -> Chars {
     /// ```
     #[stable]
     fn bytes(&self) -> Bytes {
-        core_str::StrExt::bytes(self[])
+        core_str::StrExt::bytes(self.index(&FullRange))
     }
 
     /// An iterator over the characters of `self` and their byte offsets.
     #[stable]
     fn char_indices(&self) -> CharIndices {
-        core_str::StrExt::char_indices(self[])
+        core_str::StrExt::char_indices(self.index(&FullRange))
     }
 
     /// An iterator over substrings of `self`, separated by characters
@@ -597,7 +597,7 @@ fn char_indices(&self) -> CharIndices {
     /// ```
     #[stable]
     fn split<P: CharEq>(&self, pat: P) -> Split<P> {
-        core_str::StrExt::split(self[], pat)
+        core_str::StrExt::split(self.index(&FullRange), pat)
     }
 
     /// An iterator over substrings of `self`, separated by characters
@@ -624,7 +624,7 @@ fn split<P: CharEq>(&self, pat: P) -> Split<P> {
     /// ```
     #[stable]
     fn splitn<P: CharEq>(&self, count: uint, pat: P) -> SplitN<P> {
-        core_str::StrExt::splitn(self[], count, pat)
+        core_str::StrExt::splitn(self.index(&FullRange), count, pat)
     }
 
     /// An iterator over substrings of `self`, separated by characters
@@ -653,7 +653,7 @@ fn splitn<P: CharEq>(&self, count: uint, pat: P) -> SplitN<P> {
     /// ```
     #[unstable = "might get removed"]
     fn split_terminator<P: CharEq>(&self, pat: P) -> SplitTerminator<P> {
-        core_str::StrExt::split_terminator(self[], pat)
+        core_str::StrExt::split_terminator(self.index(&FullRange), pat)
     }
 
     /// An iterator over substrings of `self`, separated by characters
@@ -674,7 +674,7 @@ fn split_terminator<P: CharEq>(&self, pat: P) -> SplitTerminator<P> {
     /// ```
     #[stable]
     fn rsplitn<P: CharEq>(&self, count: uint, pat: P) -> RSplitN<P> {
-        core_str::StrExt::rsplitn(self[], count, pat)
+        core_str::StrExt::rsplitn(self.index(&FullRange), count, pat)
     }
 
     /// An iterator over the start and end indices of the disjoint
@@ -699,7 +699,7 @@ fn rsplitn<P: CharEq>(&self, count: uint, pat: P) -> RSplitN<P> {
     /// ```
     #[unstable = "might have its iterator type changed"]
     fn match_indices<'a>(&'a self, pat: &'a str) -> MatchIndices<'a> {
-        core_str::StrExt::match_indices(self[], pat)
+        core_str::StrExt::match_indices(self.index(&FullRange), pat)
     }
 
     /// An iterator over the substrings of `self` separated by the pattern `sep`.
@@ -715,7 +715,7 @@ fn match_indices<'a>(&'a self, pat: &'a str) -> MatchIndices<'a> {
     /// ```
     #[unstable = "might get removed in the future in favor of a more generic split()"]
     fn split_str<'a>(&'a self, pat: &'a str) -> SplitStr<'a> {
-        core_str::StrExt::split_str(self[], pat)
+        core_str::StrExt::split_str(self.index(&FullRange), pat)
     }
 
     /// An iterator over the lines of a string (subsequences separated
@@ -731,7 +731,7 @@ fn split_str<'a>(&'a self, pat: &'a str) -> SplitStr<'a> {
     /// ```
     #[stable]
     fn lines(&self) -> Lines {
-        core_str::StrExt::lines(self[])
+        core_str::StrExt::lines(self.index(&FullRange))
     }
 
     /// An iterator over the lines of a string, separated by either
@@ -747,7 +747,7 @@ fn lines(&self) -> Lines {
     /// ```
     #[stable]
     fn lines_any(&self) -> LinesAny {
-        core_str::StrExt::lines_any(self[])
+        core_str::StrExt::lines_any(self.index(&FullRange))
     }
 
     /// Returns a slice of the given string from the byte range
@@ -782,7 +782,7 @@ fn lines_any(&self) -> LinesAny {
     /// ```
     #[unstable = "use slice notation [a..b] instead"]
     fn slice(&self, begin: uint, end: uint) -> &str {
-        core_str::StrExt::slice(self[], begin, end)
+        core_str::StrExt::slice(self.index(&FullRange), begin, end)
     }
 
     /// Returns a slice of the string from `begin` to its end.
@@ -795,7 +795,7 @@ fn slice(&self, begin: uint, end: uint) -> &str {
     /// See also `slice`, `slice_to` and `slice_chars`.
     #[unstable = "use slice notation [a..] instead"]
     fn slice_from(&self, begin: uint) -> &str {
-        core_str::StrExt::slice_from(self[], begin)
+        core_str::StrExt::slice_from(self.index(&FullRange), begin)
     }
 
     /// Returns a slice of the string from the beginning to byte
@@ -809,7 +809,7 @@ fn slice_from(&self, begin: uint) -> &str {
     /// See also `slice`, `slice_from` and `slice_chars`.
     #[unstable = "use slice notation [0..a] instead"]
     fn slice_to(&self, end: uint) -> &str {
-        core_str::StrExt::slice_to(self[], end)
+        core_str::StrExt::slice_to(self.index(&FullRange), end)
     }
 
     /// Returns a slice of the string from the character range
@@ -837,7 +837,7 @@ fn slice_to(&self, end: uint) -> &str {
     /// ```
     #[unstable = "may have yet to prove its worth"]
     fn slice_chars(&self, begin: uint, end: uint) -> &str {
-        core_str::StrExt::slice_chars(self[], begin, end)
+        core_str::StrExt::slice_chars(self.index(&FullRange), begin, end)
     }
 
     /// Takes a bytewise (not UTF-8) slice from a string.
@@ -848,7 +848,7 @@ fn slice_chars(&self, begin: uint, end: uint) -> &str {
     /// the entire slice as well.
     #[stable]
     unsafe fn slice_unchecked(&self, begin: uint, end: uint) -> &str {
-        core_str::StrExt::slice_unchecked(self[], begin, end)
+        core_str::StrExt::slice_unchecked(self.index(&FullRange), begin, end)
     }
 
     /// Returns true if the pattern `pat` is a prefix of the string.
@@ -860,7 +860,7 @@ unsafe fn slice_unchecked(&self, begin: uint, end: uint) -> &str {
     /// ```
     #[stable]
     fn starts_with(&self, pat: &str) -> bool {
-        core_str::StrExt::starts_with(self[], pat)
+        core_str::StrExt::starts_with(self.index(&FullRange), pat)
     }
 
     /// Returns true if the pattern `pat` is a suffix of the string.
@@ -872,7 +872,7 @@ fn starts_with(&self, pat: &str) -> bool {
     /// ```
     #[stable]
     fn ends_with(&self, pat: &str) -> bool {
-        core_str::StrExt::ends_with(self[], pat)
+        core_str::StrExt::ends_with(self.index(&FullRange), pat)
     }
 
     /// Returns a string with all pre- and suffixes that match
@@ -892,7 +892,7 @@ fn ends_with(&self, pat: &str) -> bool {
     /// ```
     #[stable]
     fn trim_matches<P: CharEq>(&self, pat: P) -> &str {
-        core_str::StrExt::trim_matches(self[], pat)
+        core_str::StrExt::trim_matches(self.index(&FullRange), pat)
     }
 
     /// Returns a string with all prefixes that match
@@ -912,7 +912,7 @@ fn trim_matches<P: CharEq>(&self, pat: P) -> &str {
     /// ```
     #[stable]
     fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str {
-        core_str::StrExt::trim_left_matches(self[], pat)
+        core_str::StrExt::trim_left_matches(self.index(&FullRange), pat)
     }
 
     /// Returns a string with all suffixes that match
@@ -932,7 +932,7 @@ fn trim_left_matches<P: CharEq>(&self, pat: P) -> &str {
     /// ```
     #[stable]
     fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str {
-        core_str::StrExt::trim_right_matches(self[], pat)
+        core_str::StrExt::trim_right_matches(self.index(&FullRange), pat)
     }
 
     /// Check that `index`-th byte lies at the start and/or end of a
@@ -960,7 +960,7 @@ fn trim_right_matches<P: CharEq>(&self, pat: P) -> &str {
     /// ```
     #[unstable = "naming is uncertain with container conventions"]
     fn is_char_boundary(&self, index: uint) -> bool {
-        core_str::StrExt::is_char_boundary(self[], index)
+        core_str::StrExt::is_char_boundary(self.index(&FullRange), index)
     }
 
     /// Pluck a character out of a string and return the index of the next
@@ -1018,7 +1018,7 @@ fn is_char_boundary(&self, index: uint) -> bool {
     /// If `i` is not the index of the beginning of a valid UTF-8 character.
     #[unstable = "naming is uncertain with container conventions"]
     fn char_range_at(&self, start: uint) -> CharRange {
-        core_str::StrExt::char_range_at(self[], start)
+        core_str::StrExt::char_range_at(self.index(&FullRange), start)
     }
 
     /// Given a byte position and a str, return the previous char and its position.
@@ -1033,7 +1033,7 @@ fn char_range_at(&self, start: uint) -> CharRange {
     /// If `i` is not an index following a valid UTF-8 character.
     #[unstable = "naming is uncertain with container conventions"]
     fn char_range_at_reverse(&self, start: uint) -> CharRange {
-        core_str::StrExt::char_range_at_reverse(self[], start)
+        core_str::StrExt::char_range_at_reverse(self.index(&FullRange), start)
     }
 
     /// Plucks the character starting at the `i`th byte of a string.
@@ -1053,7 +1053,7 @@ fn char_range_at_reverse(&self, start: uint) -> CharRange {
     /// If `i` is not the index of the beginning of a valid UTF-8 character.
     #[unstable = "naming is uncertain with container conventions"]
     fn char_at(&self, i: uint) -> char {
-        core_str::StrExt::char_at(self[], i)
+        core_str::StrExt::char_at(self.index(&FullRange), i)
     }
 
     /// Plucks the character ending at the `i`th byte of a string.
@@ -1064,7 +1064,7 @@ fn char_at(&self, i: uint) -> char {
     /// If `i` is not an index following a valid UTF-8 character.
     #[unstable = "naming is uncertain with container conventions"]
     fn char_at_reverse(&self, i: uint) -> char {
-        core_str::StrExt::char_at_reverse(self[], i)
+        core_str::StrExt::char_at_reverse(self.index(&FullRange), i)
     }
 
     /// Work with the byte buffer of a string as a byte slice.
@@ -1076,7 +1076,7 @@ fn char_at_reverse(&self, i: uint) -> char {
     /// ```
     #[stable]
     fn as_bytes(&self) -> &[u8] {
-        core_str::StrExt::as_bytes(self[])
+        core_str::StrExt::as_bytes(self.index(&FullRange))
     }
 
     /// Returns the byte index of the first character of `self` that
@@ -1104,7 +1104,7 @@ fn as_bytes(&self) -> &[u8] {
     /// ```
     #[stable]
     fn find<P: CharEq>(&self, pat: P) -> Option<uint> {
-        core_str::StrExt::find(self[], pat)
+        core_str::StrExt::find(self.index(&FullRange), pat)
     }
 
     /// Returns the byte index of the last character of `self` that
@@ -1132,7 +1132,7 @@ fn find<P: CharEq>(&self, pat: P) -> Option<uint> {
     /// ```
     #[stable]
     fn rfind<P: CharEq>(&self, pat: P) -> Option<uint> {
-        core_str::StrExt::rfind(self[], pat)
+        core_str::StrExt::rfind(self.index(&FullRange), pat)
     }
 
     /// Returns the byte index of the first matching substring
@@ -1156,7 +1156,7 @@ fn rfind<P: CharEq>(&self, pat: P) -> Option<uint> {
     /// ```
     #[unstable = "might get removed in favor of a more generic find in the future"]
     fn find_str(&self, needle: &str) -> Option<uint> {
-        core_str::StrExt::find_str(self[], needle)
+        core_str::StrExt::find_str(self.index(&FullRange), needle)
     }
 
     /// Retrieves the first character from a string slice and returns
@@ -1179,7 +1179,7 @@ fn find_str(&self, needle: &str) -> Option<uint> {
     /// ```
     #[unstable = "awaiting conventions about shifting and slices"]
     fn slice_shift_char(&self) -> Option<(char, &str)> {
-        core_str::StrExt::slice_shift_char(self[])
+        core_str::StrExt::slice_shift_char(self.index(&FullRange))
     }
 
     /// Returns the byte offset of an inner slice relative to an enclosing outer slice.
@@ -1198,7 +1198,7 @@ fn slice_shift_char(&self) -> Option<(char, &str)> {
     /// ```
     #[unstable = "awaiting convention about comparability of arbitrary slices"]
     fn subslice_offset(&self, inner: &str) -> uint {
-        core_str::StrExt::subslice_offset(self[], inner)
+        core_str::StrExt::subslice_offset(self.index(&FullRange), inner)
     }
 
     /// Return an unsafe pointer to the strings buffer.
@@ -1209,13 +1209,13 @@ fn subslice_offset(&self, inner: &str) -> uint {
     #[stable]
     #[inline]
     fn as_ptr(&self) -> *const u8 {
-        core_str::StrExt::as_ptr(self[])
+        core_str::StrExt::as_ptr(self.index(&FullRange))
     }
 
     /// Return an iterator of `u16` over the string encoded as UTF-16.
     #[unstable = "this functionality may only be provided by libunicode"]
     fn utf16_units(&self) -> Utf16Units {
-        Utf16Units { encoder: Utf16Encoder::new(self[].chars()) }
+        Utf16Units { encoder: Utf16Encoder::new(self.index(&FullRange).chars()) }
     }
 
     /// Return the number of bytes in this string
@@ -1229,7 +1229,7 @@ fn utf16_units(&self) -> Utf16Units {
     #[stable]
     #[inline]
     fn len(&self) -> uint {
-        core_str::StrExt::len(self[])
+        core_str::StrExt::len(self.index(&FullRange))
     }
 
     /// Returns true if this slice contains no bytes
@@ -1242,7 +1242,7 @@ fn len(&self) -> uint {
     #[inline]
     #[stable]
     fn is_empty(&self) -> bool {
-        core_str::StrExt::is_empty(self[])
+        core_str::StrExt::is_empty(self.index(&FullRange))
     }
 
     /// Parse this string into the specified type.
@@ -1256,7 +1256,7 @@ fn is_empty(&self) -> bool {
     #[inline]
     #[unstable = "this method was just created"]
     fn parse<F: FromStr>(&self) -> Option<F> {
-        core_str::StrExt::parse(self[])
+        core_str::StrExt::parse(self.index(&FullRange))
     }
 
     /// Returns an iterator over the
@@ -1280,7 +1280,7 @@ fn parse<F: FromStr>(&self) -> Option<F> {
     /// ```
     #[unstable = "this functionality may only be provided by libunicode"]
     fn graphemes(&self, is_extended: bool) -> Graphemes {
-        UnicodeStr::graphemes(self[], is_extended)
+        UnicodeStr::graphemes(self.index(&FullRange), is_extended)
     }
 
     /// Returns an iterator over the grapheme clusters of self and their byte offsets.
@@ -1295,7 +1295,7 @@ fn graphemes(&self, is_extended: bool) -> Graphemes {
     /// ```
     #[unstable = "this functionality may only be provided by libunicode"]
     fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices {
-        UnicodeStr::grapheme_indices(self[], is_extended)
+        UnicodeStr::grapheme_indices(self.index(&FullRange), is_extended)
     }
 
     /// An iterator over the words of a string (subsequences separated
@@ -1311,7 +1311,7 @@ fn grapheme_indices(&self, is_extended: bool) -> GraphemeIndices {
     /// ```
     #[stable]
     fn words(&self) -> Words {
-        UnicodeStr::words(self[])
+        UnicodeStr::words(self.index(&FullRange))
     }
 
     /// Returns a string's displayed width in columns, treating control
@@ -1325,25 +1325,25 @@ fn words(&self) -> Words {
     /// `is_cjk` = `false`) if the locale is unknown.
     #[unstable = "this functionality may only be provided by libunicode"]
     fn width(&self, is_cjk: bool) -> uint {
-        UnicodeStr::width(self[], is_cjk)
+        UnicodeStr::width(self.index(&FullRange), is_cjk)
     }
 
     /// Returns a string with leading and trailing whitespace removed.
     #[stable]
     fn trim(&self) -> &str {
-        UnicodeStr::trim(self[])
+        UnicodeStr::trim(self.index(&FullRange))
     }
 
     /// Returns a string with leading whitespace removed.
     #[stable]
     fn trim_left(&self) -> &str {
-        UnicodeStr::trim_left(self[])
+        UnicodeStr::trim_left(self.index(&FullRange))
     }
 
     /// Returns a string with trailing whitespace removed.
     #[stable]
     fn trim_right(&self) -> &str {
-        UnicodeStr::trim_right(self[])
+        UnicodeStr::trim_right(self.index(&FullRange))
     }
 }
 
@@ -2133,7 +2133,7 @@ fn test_chars_decoding() {
         let mut bytes = [0u8; 4];
         for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
             let len = c.encode_utf8(&mut bytes).unwrap_or(0);
-            let s = ::core::str::from_utf8(bytes[..len]).unwrap();
+            let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
             if Some(c) != s.chars().next() {
                 panic!("character {:x}={} does not decode correctly", c as u32, c);
             }
@@ -2145,7 +2145,7 @@ fn test_chars_rev_decoding() {
         let mut bytes = [0u8; 4];
         for c in range(0u32, 0x110000).filter_map(|c| ::core::char::from_u32(c)) {
             let len = c.encode_utf8(&mut bytes).unwrap_or(0);
-            let s = ::core::str::from_utf8(bytes[..len]).unwrap();
+            let s = ::core::str::from_utf8(&bytes[..len]).unwrap();
             if Some(c) != s.chars().rev().next() {
                 panic!("character {:x}={} does not decode correctly", c as u32, c);
             }
index 0bf311e4d3f6e5674bc1eb9fd32f097087bea6e4..59418f50e3c7d44b89a792a04121e97e5c783454 100644 (file)
@@ -22,7 +22,7 @@
 use core::hash;
 use core::iter::FromIterator;
 use core::mem;
-use core::ops::{self, Deref, Add};
+use core::ops::{self, Deref, Add, Index};
 use core::ptr;
 use core::raw::Slice as RawSlice;
 use unicode::str as unicode_str;
@@ -168,7 +168,7 @@ fn safe_get(xs: &[u8], i: uint, total: uint) -> u8 {
 
         if i > 0 {
             unsafe {
-                res.as_mut_vec().push_all(v[..i])
+                res.as_mut_vec().push_all(v.index(&(0..i)))
             };
         }
 
@@ -185,7 +185,7 @@ fn safe_get(xs: &[u8], i: uint, total: uint) -> u8 {
             macro_rules! error { () => ({
                 unsafe {
                     if subseqidx != i_ {
-                        res.as_mut_vec().push_all(v[subseqidx..i_]);
+                        res.as_mut_vec().push_all(v.index(&(subseqidx..i_)));
                     }
                     subseqidx = i;
                     res.as_mut_vec().push_all(REPLACEMENT);
@@ -254,7 +254,7 @@ macro_rules! error { () => ({
         }
         if subseqidx < total {
             unsafe {
-                res.as_mut_vec().push_all(v[subseqidx..total])
+                res.as_mut_vec().push_all(v.index(&(subseqidx..total)))
             };
         }
         Cow::Owned(res)
@@ -677,13 +677,25 @@ pub fn utf8_error(&self) -> Utf8Error { self.error }
 
 impl fmt::Show for FromUtf8Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.error.fmt(f)
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for FromUtf8Error {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(&self.error, f)
     }
 }
 
 impl fmt::Show for FromUtf16Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        "invalid utf-16: lone surrogate found".fmt(f)
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for FromUtf16Error {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt("invalid utf-16: lone surrogate found", f)
     }
 }
 
@@ -793,10 +805,17 @@ fn default() -> String {
     }
 }
 
-#[experimental = "waiting on Show stabilization"]
+#[experimental = "waiting on fmt stabilization"]
+impl fmt::String for String {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(&**self, f)
+    }
+}
+
+#[experimental = "waiting on fmt stabilization"]
 impl fmt::Show for String {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        (**self).fmt(f)
+        fmt::Show::fmt(&**self, f)
     }
 }
 
@@ -818,25 +837,32 @@ fn add(mut self, other: &str) -> String {
     }
 }
 
-impl ops::Slice<uint, str> for String {
+impl ops::Index<ops::Range<uint>> for String {
+    type Output = str;
     #[inline]
-    fn as_slice_<'a>(&'a self) -> &'a str {
-        unsafe { mem::transmute(self.vec.as_slice()) }
+    fn index(&self, index: &ops::Range<uint>) -> &str {
+        &self.index(&FullRange)[*index]
     }
-
+}
+impl ops::Index<ops::RangeTo<uint>> for String {
+    type Output = str;
     #[inline]
-    fn slice_from_or_fail<'a>(&'a self, from: &uint) -> &'a str {
-        self[][*from..]
+    fn index(&self, index: &ops::RangeTo<uint>) -> &str {
+        &self.index(&FullRange)[*index]
     }
-
+}
+impl ops::Index<ops::RangeFrom<uint>> for String {
+    type Output = str;
     #[inline]
-    fn slice_to_or_fail<'a>(&'a self, to: &uint) -> &'a str {
-        self[][..*to]
+    fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
+        &self.index(&FullRange)[*index]
     }
-
+}
+impl ops::Index<ops::FullRange> for String {
+    type Output = str;
     #[inline]
-    fn slice_or_fail<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
-        self[][*from..*to]
+    fn index(&self, _index: &ops::FullRange) -> &str {
+        unsafe { mem::transmute(self.vec.as_slice()) }
     }
 }
 
@@ -845,7 +871,7 @@ impl ops::Deref for String {
     type Target = str;
 
     fn deref<'a>(&'a self) -> &'a str {
-        unsafe { mem::transmute(self.vec[]) }
+        unsafe { mem::transmute(self.vec.index(&FullRange)) }
     }
 }
 
@@ -895,6 +921,7 @@ pub trait ToString {
     fn to_string(&self) -> String;
 }
 
+#[cfg(stage0)]
 impl<T: fmt::Show> ToString for T {
     fn to_string(&self) -> String {
         use core::fmt::Writer;
@@ -905,6 +932,17 @@ fn to_string(&self) -> String {
     }
 }
 
+#[cfg(not(stage0))]
+impl<T: fmt::String> ToString for T {
+    fn to_string(&self) -> String {
+        use core::fmt::Writer;
+        let mut buf = String::new();
+        let _ = buf.write_fmt(format_args!("{}", self));
+        buf.shrink_to_fit();
+        buf
+    }
+}
+
 impl IntoCow<'static, String, str> for String {
     fn into_cow(self) -> CowString<'static> {
         Cow::Owned(self)
@@ -943,6 +981,7 @@ mod tests {
     use str::Utf8Error;
     use core::iter::repeat;
     use super::{as_string, CowString};
+    use core::ops::FullRange;
 
     #[test]
     fn test_as_string() {
@@ -1224,10 +1263,10 @@ fn insert() {
     #[test]
     fn test_slicing() {
         let s = "foobar".to_string();
-        assert_eq!("foobar", s[]);
-        assert_eq!("foo", s[..3]);
-        assert_eq!("bar", s[3..]);
-        assert_eq!("oob", s[1..4]);
+        assert_eq!("foobar", &s[]);
+        assert_eq!("foo", &s[..3]);
+        assert_eq!("bar", &s[3..]);
+        assert_eq!("oob", &s[1..4]);
     }
 
     #[test]
index 99231e7253c3ce31f48baa0f8929ac9fdbcf156c..5fc3fafac9e229f3dcda6e96f2965285f86292ab 100644 (file)
@@ -55,7 +55,7 @@
 use core::fmt;
 use core::hash::{self, Hash};
 use core::iter::{repeat, FromIterator};
-use core::kinds::marker::{ContravariantLifetime, InvariantType};
+use core::marker::{ContravariantLifetime, InvariantType};
 use core::mem;
 use core::nonzero::NonZero;
 use core::num::{Int, UnsignedInt};
@@ -1178,7 +1178,7 @@ fn clone_from(&mut self, other: &Vec<T>) {
 
         // self.len <= other.len due to the truncate above, so the
         // slice here is always in-bounds.
-        let slice = other[self.len()..];
+        let slice = other.index(&(self.len()..));
         self.push_all(slice);
     }
 }
@@ -1209,48 +1209,66 @@ fn index_mut<'a>(&'a mut self, index: &uint) -> &'a mut T {
     }
 }
 
-impl<T> ops::Slice<uint, [T]> for Vec<T> {
+
+impl<T> ops::Index<ops::Range<uint>> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn as_slice_<'a>(&'a self) -> &'a [T] {
-        self.as_slice()
+    fn index(&self, index: &ops::Range<uint>) -> &[T] {
+        self.as_slice().index(index)
     }
-
+}
+impl<T> ops::Index<ops::RangeTo<uint>> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn slice_from_or_fail<'a>(&'a self, start: &uint) -> &'a [T] {
-        self.as_slice().slice_from_or_fail(start)
+    fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
+        self.as_slice().index(index)
     }
-
+}
+impl<T> ops::Index<ops::RangeFrom<uint>> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn slice_to_or_fail<'a>(&'a self, end: &uint) -> &'a [T] {
-        self.as_slice().slice_to_or_fail(end)
+    fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
+        self.as_slice().index(index)
     }
+}
+impl<T> ops::Index<ops::FullRange> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn slice_or_fail<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
-        self.as_slice().slice_or_fail(start, end)
+    fn index(&self, _index: &ops::FullRange) -> &[T] {
+        self.as_slice()
     }
 }
 
-impl<T> ops::SliceMut<uint, [T]> for Vec<T> {
+impl<T> ops::IndexMut<ops::Range<uint>> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
-        self.as_mut_slice()
+    fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
+        self.as_mut_slice().index_mut(index)
     }
-
+}
+impl<T> ops::IndexMut<ops::RangeTo<uint>> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn slice_from_or_fail_mut<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
-        self.as_mut_slice().slice_from_or_fail_mut(start)
+    fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
+        self.as_mut_slice().index_mut(index)
     }
-
+}
+impl<T> ops::IndexMut<ops::RangeFrom<uint>> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn slice_to_or_fail_mut<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
-        self.as_mut_slice().slice_to_or_fail_mut(end)
+    fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
+        self.as_mut_slice().index_mut(index)
     }
+}
+impl<T> ops::IndexMut<ops::FullRange> for Vec<T> {
+    type Output = [T];
     #[inline]
-    fn slice_or_fail_mut<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
-        self.as_mut_slice().slice_or_fail_mut(start, end)
+    fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
+        self.as_mut_slice()
     }
 }
 
+
 #[stable]
 impl<T> ops::Deref for Vec<T> {
     type Target = [T];
@@ -1430,9 +1448,25 @@ fn default() -> Vec<T> {
 }
 
 #[experimental = "waiting on Show stability"]
-impl<T:fmt::Show> fmt::Show for Vec<T> {
+impl<T: fmt::Show> fmt::Show for Vec<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::Show::fmt(self.as_slice(), f)
+    }
+}
+
+#[cfg(stage0)]
+#[experimental = "waiting on Show stability"]
+impl<T: fmt::Show> fmt::String for Vec<T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self.as_slice(), f)
+    }
+}
+
+#[cfg(not(stage0))]
+#[experimental = "waiting on Show stability"]
+impl<T: fmt::String> fmt::String for Vec<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.as_slice().fmt(f)
+        fmt::String::fmt(self.as_slice(), f)
     }
 }
 
@@ -1781,6 +1815,7 @@ mod tests {
     use prelude::*;
     use core::mem::size_of;
     use core::iter::repeat;
+    use core::ops::FullRange;
     use test::Bencher;
     use super::as_vec;
 
@@ -1918,7 +1953,7 @@ fn test_split_at_mut() {
             let (left, right) = values.split_at_mut(2);
             {
                 let left: &[_] = left;
-                assert!(left[0..left.len()] == [1, 2][]);
+                assert!(&left[..left.len()] == &[1, 2][]);
             }
             for p in left.iter_mut() {
                 *p += 1;
@@ -1926,7 +1961,7 @@ fn test_split_at_mut() {
 
             {
                 let right: &[_] = right;
-                assert!(right[0..right.len()] == [3, 4, 5][]);
+                assert!(&right[..right.len()] == &[3, 4, 5][]);
             }
             for p in right.iter_mut() {
                 *p += 2;
@@ -2097,35 +2132,35 @@ fn test_index_out_of_bounds() {
     #[should_fail]
     fn test_slice_out_of_bounds_1() {
         let x: Vec<int> = vec![1, 2, 3, 4, 5];
-        x[-1..];
+        &x[(-1)..];
     }
 
     #[test]
     #[should_fail]
     fn test_slice_out_of_bounds_2() {
         let x: Vec<int> = vec![1, 2, 3, 4, 5];
-        x[..6];
+        &x[..6];
     }
 
     #[test]
     #[should_fail]
     fn test_slice_out_of_bounds_3() {
         let x: Vec<int> = vec![1, 2, 3, 4, 5];
-        x[-1..4];
+        &x[(-1)..4];
     }
 
     #[test]
     #[should_fail]
     fn test_slice_out_of_bounds_4() {
         let x: Vec<int> = vec![1, 2, 3, 4, 5];
-        x[1..6];
+        &x[1..6];
     }
 
     #[test]
     #[should_fail]
     fn test_slice_out_of_bounds_5() {
         let x: Vec<int> = vec![1, 2, 3, 4, 5];
-        x[3..2];
+        &x[3..2];
     }
 
     #[test]
@@ -2371,7 +2406,7 @@ fn do_bench_from_slice(b: &mut Bencher, src_len: uint) {
         b.bytes = src_len as u64;
 
         b.iter(|| {
-            let dst = src.clone().as_slice().to_vec();
+            let dst = src.clone()[].to_vec();
             assert_eq!(dst.len(), src_len);
             assert!(dst.iter().enumerate().all(|(i, x)| i == *x));
         });
index cc757b656238e978512314af45b1ee05bbe2437f..4399a6fec2274bd42b8e8a5553a6490a0fcfb3f4 100644 (file)
@@ -455,7 +455,8 @@ pub fn remove(&mut self, key: &uint) -> Option<V> {
         if *key >= self.v.len() {
             return None;
         }
-        self.v[*key].take()
+        let result = &mut self.v[*key];
+        result.take()
     }
 }
 
@@ -488,11 +489,11 @@ fn cmp(&self, other: &VecMap<V>) -> Ordering {
 #[stable]
 impl<V: fmt::Show> fmt::Show for VecMap<V> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
+        try!(write!(f, "VecMap {{"));
 
         for (i, (k, v)) in self.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{}: {}", k, *v));
+            try!(write!(f, "{}: {:?}", k, *v));
         }
 
         write!(f, "}}")
@@ -928,9 +929,9 @@ fn test_show() {
         map.insert(1, 2i);
         map.insert(3, 4i);
 
-        let map_str = map.to_string();
-        assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
-        assert_eq!(format!("{}", empty), "{}");
+        let map_str = format!("{:?}", map);
+        assert!(map_str == "VecMap {1: 2i, 3: 4i}" || map_str == "{3: 4i, 1: 2i}");
+        assert_eq!(format!("{:?}", empty), "VecMap {}");
     }
 
     #[test]
index 33cb335d756451dfab847d2311ea7082bd71fb19..25007bfde93a9d6c0af0ef7604044046ec83ec52 100644 (file)
@@ -49,7 +49,7 @@
 //!             println!("String ({}): {}", as_string.len(), as_string);
 //!         }
 //!         None => {
-//!             println!("{}", value);
+//!             println!("{:?}", value);
 //!         }
 //!     }
 //! }
index ba7714ad9bc8cb321b9a1db2eb0d89eac3bf9e61..05db9e11760e38615889566361962de4f954993d 100644 (file)
@@ -17,8 +17,8 @@
 use clone::Clone;
 use cmp::{PartialEq, Eq, PartialOrd, Ord, Ordering};
 use fmt;
-use kinds::Copy;
-use ops::Deref;
+use marker::Copy;
+use ops::{Deref, FullRange, Index};
 use option::Option;
 
 // macro for implementing n-ary tuple functions and operations
@@ -35,7 +35,7 @@ macro_rules! array_impls {
             #[unstable = "waiting for Show to stabilize"]
             impl<T:fmt::Show> fmt::Show for [T; $N] {
                 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-                    fmt::Show::fmt(&self[], f)
+                    fmt::Show::fmt(&self.index(&FullRange), f)
                 }
             }
 
@@ -43,11 +43,11 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             impl<A, B> PartialEq<[B; $N]> for [A; $N] where A: PartialEq<B> {
                 #[inline]
                 fn eq(&self, other: &[B; $N]) -> bool {
-                    self[] == other[]
+                    self.index(&FullRange) == other.index(&FullRange)
                 }
                 #[inline]
                 fn ne(&self, other: &[B; $N]) -> bool {
-                    self[] != other[]
+                    self.index(&FullRange) != other.index(&FullRange)
                 }
             }
 
@@ -57,9 +57,13 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 Rhs: Deref<Target=[B]>,
             {
                 #[inline(always)]
-                fn eq(&self, other: &Rhs) -> bool { PartialEq::eq(self[], &**other) }
+                fn eq(&self, other: &Rhs) -> bool {
+                    PartialEq::eq(self.index(&FullRange), &**other)
+                }
                 #[inline(always)]
-                fn ne(&self, other: &Rhs) -> bool { PartialEq::ne(self[], &**other) }
+                fn ne(&self, other: &Rhs) -> bool {
+                    PartialEq::ne(self.index(&FullRange), &**other)
+                }
             }
 
             #[stable]
@@ -68,9 +72,13 @@ fn ne(&self, other: &Rhs) -> bool { PartialEq::ne(self[], &**other) }
                 Lhs: Deref<Target=[A]>
             {
                 #[inline(always)]
-                fn eq(&self, other: &[B; $N]) -> bool { PartialEq::eq(&**self, other[]) }
+                fn eq(&self, other: &[B; $N]) -> bool {
+                    PartialEq::eq(&**self, other.index(&FullRange))
+                }
                 #[inline(always)]
-                fn ne(&self, other: &[B; $N]) -> bool { PartialEq::ne(&**self, other[]) }
+                fn ne(&self, other: &[B; $N]) -> bool {
+                    PartialEq::ne(&**self, other.index(&FullRange))
+                }
             }
 
             #[stable]
@@ -80,23 +88,23 @@ fn ne(&self, other: &Rhs) -> bool { PartialEq::ne(self[], &**other) }
             impl<T:PartialOrd> PartialOrd for [T; $N] {
                 #[inline]
                 fn partial_cmp(&self, other: &[T; $N]) -> Option<Ordering> {
-                    PartialOrd::partial_cmp(&self[], &other[])
+                    PartialOrd::partial_cmp(&self.index(&FullRange), &other.index(&FullRange))
                 }
                 #[inline]
                 fn lt(&self, other: &[T; $N]) -> bool {
-                    PartialOrd::lt(&self[], &other[])
+                    PartialOrd::lt(&self.index(&FullRange), &other.index(&FullRange))
                 }
                 #[inline]
                 fn le(&self, other: &[T; $N]) -> bool {
-                    PartialOrd::le(&self[], &other[])
+                    PartialOrd::le(&self.index(&FullRange), &other.index(&FullRange))
                 }
                 #[inline]
                 fn ge(&self, other: &[T; $N]) -> bool {
-                    PartialOrd::ge(&self[], &other[])
+                    PartialOrd::ge(&self.index(&FullRange), &other.index(&FullRange))
                 }
                 #[inline]
                 fn gt(&self, other: &[T; $N]) -> bool {
-                    PartialOrd::gt(&self[], &other[])
+                    PartialOrd::gt(&self.index(&FullRange), &other.index(&FullRange))
                 }
             }
 
@@ -104,7 +112,7 @@ fn ne(&self, other: &Rhs) -> bool { PartialEq::ne(self[], &**other) }
             impl<T:Ord> Ord for [T; $N] {
                 #[inline]
                 fn cmp(&self, other: &[T; $N]) -> Ordering {
-                    Ord::cmp(&self[], &other[])
+                    Ord::cmp(&self.index(&FullRange), &other.index(&FullRange))
                 }
             }
         )+
index 15c20253c8bc78b1c739b28c14215e9484886455..e740a9292528cfc0a8d7ac8c0d8f66ffba64b59e 100644 (file)
@@ -50,7 +50,7 @@
 //!     let spinlock_clone = spinlock.clone();
 //!     Thread::spawn(move|| {
 //!         spinlock_clone.store(0, Ordering::SeqCst);
-//!     }).detach();
+//!     });
 //!
 //!     // Wait for the other task to release the lock
 //!     while spinlock.load(Ordering::SeqCst) != 0 {}
@@ -72,7 +72,7 @@
 
 use self::Ordering::*;
 
-use kinds::Sync;
+use marker::Sync;
 
 use intrinsics;
 use cell::UnsafeCell;
index 2c08b97635580c0504df846247a117644a491602..31631355422964cce82aec6a145a3c897f824ed4 100644 (file)
@@ -47,7 +47,7 @@
 use clone::Clone;
 use cmp::{Eq, Ord, Ordering, PartialEq, PartialOrd};
 use fmt;
-use kinds::Sized;
+use marker::Sized;
 use ops::Deref;
 use option::Option;
 use self::Cow::*;
@@ -133,6 +133,7 @@ fn to_owned(&self) -> T { self.clone() }
 ///     }
 /// }
 /// ```
+//#[deriving(Show)] NOTE(stage0): uncomment after snapshot
 pub enum Cow<'a, T, B: ?Sized + 'a> where B: ToOwned<T> {
     /// Borrowed data.
     Borrowed(&'a B),
@@ -141,6 +142,16 @@ pub enum Cow<'a, T, B: ?Sized + 'a> where B: ToOwned<T> {
     Owned(T)
 }
 
+//NOTE(stage0): replace with deriving(Show) after snapshot
+impl<'a, T, B: ?Sized> fmt::Show for Cow<'a, T, B> where
+    B: fmt::String + ToOwned<T>,
+    T: fmt::String
+{
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
 #[stable]
 impl<'a, T, B: ?Sized> Clone for Cow<'a, T, B> where B: ToOwned<T> {
     fn clone(&self) -> Cow<'a, T, B> {
@@ -237,11 +248,14 @@ fn partial_cmp(&self, other: &Cow<'a, T, B>) -> Option<Ordering> {
     }
 }
 
-impl<'a, T, B: ?Sized> fmt::Show for Cow<'a, T, B> where B: fmt::Show + ToOwned<T>, T: fmt::Show {
+impl<'a, T, B: ?Sized> fmt::String for Cow<'a, T, B> where
+    B: fmt::String + ToOwned<T>,
+    T: fmt::String,
+{
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
-            Borrowed(ref b) => fmt::Show::fmt(b, f),
-            Owned(ref o) => fmt::Show::fmt(o, f),
+            Borrowed(ref b) => fmt::String::fmt(b, f),
+            Owned(ref o) => fmt::String::fmt(o, f),
         }
     }
 }
index fd18d6ac3f3b409e389b599e5292343feccb720f..674364269f1da0bcb0573f6d05be3e12a1a36761 100644 (file)
 use clone::Clone;
 use cmp::PartialEq;
 use default::Default;
-use fmt;
-use kinds::{Copy, Send};
+use marker::{Copy, Send};
 use ops::{Deref, DerefMut, Drop};
 use option::Option;
 use option::Option::{None, Some};
@@ -364,16 +363,6 @@ fn eq(&self, other: &RefCell<T>) -> bool {
     }
 }
 
-#[unstable]
-impl<T:fmt::Show> fmt::Show for RefCell<T> {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match self.try_borrow() {
-            Some(val) => write!(f, "{}", val),
-            None => write!(f, "<borrowed RefCell>")
-        }
-    }
-}
-
 struct BorrowRef<'b> {
     _borrow: &'b Cell<BorrowFlag>,
 }
@@ -520,7 +509,7 @@ fn deref_mut<'a>(&'a mut self) -> &'a mut T {
 ///
 /// ```rust
 /// use std::cell::UnsafeCell;
-/// use std::kinds::marker;
+/// use std::marker;
 ///
 /// struct NotThreadSafe<T> {
 ///     value: UnsafeCell<T>,
index 17991659f97899c6027021eae8a8dceecccd54a6..3149247a83aed96cf4df8e6af48ef4178138febf 100644 (file)
@@ -21,7 +21,7 @@
 
 #![stable]
 
-use kinds::Sized;
+use marker::Sized;
 
 /// A common trait for cloning an object.
 #[stable]
index af5e98ed303240a9684c8207d9f4375eb208ccac..c3dfd5f51595f80b1c0e561cc4c68ca4852ad615 100644 (file)
@@ -43,7 +43,7 @@
 
 use self::Ordering::*;
 
-use kinds::Sized;
+use marker::Sized;
 use option::Option::{self, Some, None};
 
 /// Trait for equality comparisons which are [partial equivalence relations](
@@ -316,7 +316,7 @@ pub fn partial_max<T: PartialOrd>(v1: T, v2: T) -> Option<T> {
 mod impls {
     use cmp::{PartialOrd, Ord, PartialEq, Eq, Ordering};
     use cmp::Ordering::{Less, Greater, Equal};
-    use kinds::Sized;
+    use marker::Sized;
     use option::Option;
     use option::Option::{Some, None};
 
index f63242b4f859a451d9bddabff995532c9d1ec900..d833b8fed7779ff8213ca0e515dc53dc6836d53c 100644 (file)
@@ -20,7 +20,7 @@
 use iter::{IteratorExt, range};
 use num::{cast, Float, ToPrimitive};
 use num::FpCategory as Fp;
-use ops::FnOnce;
+use ops::{FnOnce, Index};
 use result::Result::Ok;
 use slice::{self, SliceExt};
 use str::{self, StrExt};
@@ -332,5 +332,5 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
         }
     }
 
-    f(unsafe { str::from_utf8_unchecked(buf[..end]) })
+    f(unsafe { str::from_utf8_unchecked(buf.index(&(0..end))) })
 }
index 951f5c29f00e8c923c5520e0bb9c0c341360f7b7..f9027f19068e435f51062e2745a642fa9db45d36 100644 (file)
 #![allow(unused_variables)]
 
 use any;
-use cell::{Cell, Ref, RefMut};
+use cell::{Cell, RefCell, Ref, RefMut};
+use char::CharExt;
 use iter::{Iterator, IteratorExt, range};
-use kinds::{Copy, Sized};
+use marker::{Copy, Sized};
 use mem;
 use option::Option;
 use option::Option::{Some, None};
-use ops::{Deref, FnOnce};
 use result::Result::Ok;
+use ops::{Deref, FnOnce, Index};
 use result;
 use slice::SliceExt;
 use slice;
 use str::{self, StrExt, Utf8Error};
 
-// NOTE: for old macros; remove after the next snapshot
-#[cfg(stage0)] use result::Result::Err;
-
 pub use self::num::radix;
 pub use self::num::Radix;
 pub use self::num::RadixFmt;
@@ -216,20 +214,33 @@ pub struct Arguments<'a> {
 }
 
 impl<'a> Show for Arguments<'a> {
+    fn fmt(&self, fmt: &mut Formatter) -> Result {
+        String::fmt(self, fmt)
+    }
+}
+
+impl<'a> String for Arguments<'a> {
     fn fmt(&self, fmt: &mut Formatter) -> Result {
         write(fmt.buf, *self)
     }
 }
 
-/// When a format is not otherwise specified, types are formatted by ascribing
-/// to this trait. There is not an explicit way of selecting this trait to be
-/// used for formatting, it is only if no other format is specified.
+/// Format trait for the `:?` format. Useful for debugging, most all types
+/// should implement this.
 #[unstable = "I/O and core have yet to be reconciled"]
 pub trait Show {
     /// Formats the value using the given formatter.
     fn fmt(&self, &mut Formatter) -> Result;
 }
 
+/// When a value can be semantically expressed as a String, this trait may be
+/// used. It corresponds to the default format, `{}`.
+#[unstable = "I/O and core have yet to be reconciled"]
+pub trait String {
+    /// Formats the value using the given formatter.
+    fn fmt(&self, &mut Formatter) -> Result;
+}
+
 
 /// Format trait for the `o` character
 #[unstable = "I/O and core have yet to be reconciled"]
@@ -413,7 +424,7 @@ pub fn pad_integral(&mut self,
             for c in sign.into_iter() {
                 let mut b = [0; 4];
                 let n = c.encode_utf8(&mut b).unwrap_or(0);
-                let b = unsafe { str::from_utf8_unchecked(b[0..n]) };
+                let b = unsafe { str::from_utf8_unchecked(b.index(&(0..n))) };
                 try!(f.buf.write_str(b));
             }
             if prefixed { f.buf.write_str(prefix) }
@@ -521,7 +532,7 @@ fn with_padding<F>(&mut self, padding: uint, default: rt::Alignment, f: F) -> Re
 
         let mut fill = [0u8; 4];
         let len = self.fill.encode_utf8(&mut fill).unwrap_or(0);
-        let fill = unsafe { str::from_utf8_unchecked(fill[..len]) };
+        let fill = unsafe { str::from_utf8_unchecked(fill.index(&(..len))) };
 
         for _ in range(0, pre_pad) {
             try!(self.buf.write_str(fill));
@@ -572,7 +583,7 @@ pub fn precision(&self) -> Option<uint> { self.precision }
 
 impl Show for Error {
     fn fmt(&self, f: &mut Formatter) -> Result {
-        "an error occurred when formatting an argument".fmt(f)
+        String::fmt("an error occurred when formatting an argument", f)
     }
 }
 
@@ -595,33 +606,86 @@ pub fn argumentuint<'a>(s: &'a uint) -> Argument<'a> {
 
 // Implementations of the core formatting traits
 
-impl<'a, T: ?Sized + Show> Show for &'a T {
-    fn fmt(&self, f: &mut Formatter) -> Result { (**self).fmt(f) }
-}
-impl<'a, T: ?Sized + Show> Show for &'a mut T {
-    fn fmt(&self, f: &mut Formatter) -> Result { (**self).fmt(f) }
+macro_rules! fmt_refs {
+    ($($tr:ident),*) => {
+        $(
+        impl<'a, T: ?Sized + $tr> $tr for &'a T {
+            fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) }
+        }
+        impl<'a, T: ?Sized + $tr> $tr for &'a mut T {
+            fn fmt(&self, f: &mut Formatter) -> Result { $tr::fmt(&**self, f) }
+        }
+        )*
+    }
 }
 
+fmt_refs! { Show, String, Octal, Binary, LowerHex, UpperHex, LowerExp, UpperExp }
+
 impl Show for bool {
     fn fmt(&self, f: &mut Formatter) -> Result {
-        Show::fmt(if *self { "true" } else { "false" }, f)
+        String::fmt(self, f)
+    }
+}
+
+impl String for bool {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        String::fmt(if *self { "true" } else { "false" }, f)
+    }
+}
+
+#[cfg(stage0)]
+//NOTE(stage0): remove impl after snapshot
+impl Show for str {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        String::fmt(self, f)
     }
 }
 
+#[cfg(not(stage0))]
+//NOTE(stage0): remove cfg after snapshot
 impl Show for str {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        try!(write!(f, "\""));
+        for c in self.chars().flat_map(|c| c.escape_default()) {
+            try!(write!(f, "{}", c));
+        }
+        write!(f, "\"")
+    }
+}
+
+impl String for str {
     fn fmt(&self, f: &mut Formatter) -> Result {
         f.pad(self)
     }
 }
 
+#[cfg(stage0)]
+//NOTE(stage0): remove impl after snapshot
+impl Show for char {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        String::fmt(self, f)
+    }
+}
+
+#[cfg(not(stage0))]
+//NOTE(stage0): remove cfg after snapshot
 impl Show for char {
     fn fmt(&self, f: &mut Formatter) -> Result {
         use char::CharExt;
+        try!(write!(f, "'"));
+        for c in self.escape_default() {
+            try!(write!(f, "{}", c));
+        }
+        write!(f, "'")
+    }
+}
 
+impl String for char {
+    fn fmt(&self, f: &mut Formatter) -> Result {
         let mut utf8 = [0u8; 4];
         let amt = self.encode_utf8(&mut utf8).unwrap_or(0);
-        let s: &str = unsafe { mem::transmute(utf8[..amt]) };
-        Show::fmt(s, f)
+        let s: &str = unsafe { mem::transmute(utf8.index(&(0..amt))) };
+        String::fmt(s, f)
     }
 }
 
@@ -653,7 +717,15 @@ fn fmt(&self, f: &mut Formatter) -> Result {
 }
 
 macro_rules! floating { ($ty:ident) => {
+
     impl Show for $ty {
+        fn fmt(&self, fmt: &mut Formatter) -> Result {
+            try!(String::fmt(self, fmt));
+            fmt.write_str(stringify!($ty))
+        }
+    }
+
+    impl String for $ty {
         fn fmt(&self, fmt: &mut Formatter) -> Result {
             use num::Float;
 
@@ -724,10 +796,15 @@ fn fmt(&self, fmt: &mut Formatter) -> Result {
 impl<T> Show for *const T {
     fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
 }
-
+impl<T> String for *const T {
+    fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
+}
 impl<T> Show for *mut T {
     fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
 }
+impl<T> String for *mut T {
+    fn fmt(&self, f: &mut Formatter) -> Result { Pointer::fmt(self, f) }
+}
 
 macro_rules! peel {
     ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
@@ -746,7 +823,7 @@ fn fmt(&self, f: &mut Formatter) -> Result {
                     if n > 0 {
                         try!(write!(f, ", "));
                     }
-                    try!(write!(f, "{}", *$name));
+                    try!(write!(f, "{:?}", *$name));
                     n += 1;
                 )*
                 if n == 1 {
@@ -766,6 +843,49 @@ fn fmt(&self, f: &mut Formatter) -> Result { f.pad("&Any") }
 }
 
 impl<T: Show> Show for [T] {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
+            try!(write!(f, "["));
+        }
+        let mut is_first = true;
+        for x in self.iter() {
+            if is_first {
+                is_first = false;
+            } else {
+                try!(write!(f, ", "));
+            }
+            try!(write!(f, "{:?}", *x))
+        }
+        if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
+            try!(write!(f, "]"));
+        }
+        Ok(())
+    }
+}
+
+#[cfg(stage0)]
+impl<T: Show> String for [T] {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
+            try!(write!(f, "["));
+        }
+        let mut is_first = true;
+        for x in self.iter() {
+            if is_first {
+                is_first = false;
+            } else {
+                try!(write!(f, ", "));
+            }
+            try!(write!(f, "{}", *x))
+        }
+        if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
+            try!(write!(f, "]"));
+        }
+        Ok(())
+    }
+}
+#[cfg(not(stage0))]
+impl<T: String> String for [T] {
     fn fmt(&self, f: &mut Formatter) -> Result {
         if f.flags & (1 << (rt::FlagAlternate as uint)) == 0 {
             try!(write!(f, "["));
@@ -792,25 +912,41 @@ fn fmt(&self, f: &mut Formatter) -> Result {
     }
 }
 
+impl String for () {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        f.pad("()")
+    }
+}
+
 impl<T: Copy + Show> Show for Cell<T> {
     fn fmt(&self, f: &mut Formatter) -> Result {
-        write!(f, "Cell {{ value: {} }}", self.get())
+        write!(f, "Cell {{ value: {:?} }}", self.get())
+    }
+}
+
+#[unstable]
+impl<T: Show> Show for RefCell<T> {
+    fn fmt(&self, f: &mut Formatter) -> Result {
+        match self.try_borrow() {
+            Some(val) => write!(f, "RefCell {{ value: {:?} }}", val),
+            None => write!(f, "RefCell {{ <borrowed> }}")
+        }
     }
 }
 
 impl<'b, T: Show> Show for Ref<'b, T> {
     fn fmt(&self, f: &mut Formatter) -> Result {
-        (**self).fmt(f)
+        Show::fmt(&**self, f)
     }
 }
 
 impl<'b, T: Show> Show for RefMut<'b, T> {
     fn fmt(&self, f: &mut Formatter) -> Result {
-        (*(self.deref())).fmt(f)
+        Show::fmt(&*(self.deref()), f)
     }
 }
 
-impl Show for Utf8Error {
+impl String for Utf8Error {
     fn fmt(&self, f: &mut Formatter) -> Result {
         match *self {
             Utf8Error::InvalidByte(n) => {
index e0724fc2da5f5dc4536357efe6587d77397a08e8..17149aed3dbab4375e652c2203c644d010b41b8e 100644 (file)
@@ -16,6 +16,7 @@
 
 use fmt;
 use iter::IteratorExt;
+use ops::Index;
 use num::{Int, cast};
 use slice::SliceExt;
 use str;
@@ -61,7 +62,7 @@ fn fmt_int<T: Int>(&self, mut x: T, f: &mut fmt::Formatter) -> fmt::Result {
                 if x == zero { break };                   // No more digits left to accumulate.
             }
         }
-        let buf = unsafe { str::from_utf8_unchecked(buf[curr..]) };
+        let buf = unsafe { str::from_utf8_unchecked(buf.index(&(curr..))) };
         f.pad_integral(is_positive, self.prefix(), buf)
     }
 }
@@ -153,8 +154,22 @@ pub fn radix<T>(x: T, base: u8) -> RadixFmt<T, Radix> {
 }
 
 macro_rules! radix_fmt {
-    ($T:ty as $U:ty, $fmt:ident) => {
+    ($T:ty as $U:ty, $fmt:ident, $S:expr) => {
+        #[cfg(stage0)]
         impl fmt::Show for RadixFmt<$T, Radix> {
+            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+                fmt::String::fmt(self, f)
+            }
+        }
+
+        #[cfg(not(stage0))]
+        impl fmt::Show for RadixFmt<$T, Radix> {
+            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+                try!(fmt::String::fmt(self, f));
+                f.write_str($S)
+            }
+        }
+        impl fmt::String for RadixFmt<$T, Radix> {
             fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 match *self { RadixFmt(ref x, radix) => radix.$fmt(*x as $U, f) }
             }
@@ -170,24 +185,48 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         }
     }
 }
+
+macro_rules! show {
+    ($T:ident with $S:expr) => {
+        #[cfg(stage0)]
+        impl fmt::Show for $T {
+            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+                fmt::String::fmt(self, f)
+            }
+        }
+
+        #[cfg(not(stage0))]
+        impl fmt::Show for $T {
+            fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+                try!(fmt::String::fmt(self, f));
+                f.write_str($S)
+            }
+        }
+    }
+}
 macro_rules! integer {
     ($Int:ident, $Uint:ident) => {
-        int_base! { Show     for $Int as $Int   -> Decimal }
+        integer! { $Int, $Uint, stringify!($Int), stringify!($Uint) }
+    };
+    ($Int:ident, $Uint:ident, $SI:expr, $SU:expr) => {
+        int_base! { String   for $Int as $Int   -> Decimal }
         int_base! { Binary   for $Int as $Uint  -> Binary }
         int_base! { Octal    for $Int as $Uint  -> Octal }
         int_base! { LowerHex for $Int as $Uint  -> LowerHex }
         int_base! { UpperHex for $Int as $Uint  -> UpperHex }
-        radix_fmt! { $Int as $Int, fmt_int }
+        radix_fmt! { $Int as $Int, fmt_int, $SI }
+        show! { $Int with $SI }
 
-        int_base! { Show     for $Uint as $Uint -> Decimal }
+        int_base! { String   for $Uint as $Uint -> Decimal }
         int_base! { Binary   for $Uint as $Uint -> Binary }
         int_base! { Octal    for $Uint as $Uint -> Octal }
         int_base! { LowerHex for $Uint as $Uint -> LowerHex }
         int_base! { UpperHex for $Uint as $Uint -> UpperHex }
-        radix_fmt! { $Uint as $Uint, fmt_int }
+        radix_fmt! { $Uint as $Uint, fmt_int, $SU }
+        show! { $Uint with $SU }
     }
 }
-integer! { int, uint }
+integer! { int, uint, "i", "u" }
 integer! { i8, u8 }
 integer! { i16, u16 }
 integer! { i32, u32 }
index 7e1359d5c12013cbe2be42332571d970c69034c7..822416a387e63405b152d460baafb786cabdc659 100644 (file)
@@ -202,7 +202,6 @@ pub struct TyDesc {
     /// crate it is invoked in.
     pub fn type_id<T: 'static>() -> TypeId;
 
-
     /// Create a value initialized to zero.
     ///
     /// `init` is unsafe because it returns a zeroed-out datum,
index e5753f6cc2e7857e6e76c3a7cc3d4eaa5e151b89..d30cfc405a1fface3eba57e663748b2f505869e4 100644 (file)
@@ -67,7 +67,7 @@
 use ops::{Add, Deref, FnMut};
 use option::Option;
 use option::Option::{Some, None};
-use std::kinds::Sized;
+use std::marker::Sized;
 use uint;
 
 /// An interface for dealing with "external iterators". These types of iterators
@@ -142,7 +142,7 @@ fn count(self) -> uint {
     /// ```
     #[inline]
     #[stable]
-    fn last(mut self) -> Option< <Self as Iterator>::Item> {
+    fn last(mut self) -> Option<Self::Item> {
         let mut last = None;
         for x in self { last = Some(x); }
         last
@@ -161,7 +161,7 @@ fn last(mut self) -> Option< <Self as Iterator>::Item> {
     /// ```
     #[inline]
     #[stable]
-    fn nth(&mut self, mut n: uint) -> Option< <Self as Iterator>::Item> {
+    fn nth(&mut self, mut n: uint) -> Option<Self::Item> {
         for x in *self {
             if n == 0 { return Some(x) }
             n -= 1;
@@ -186,7 +186,7 @@ fn nth(&mut self, mut n: uint) -> Option< <Self as Iterator>::Item> {
     #[inline]
     #[stable]
     fn chain<U>(self, other: U) -> Chain<Self, U> where
-        U: Iterator<Item=<Self as Iterator>::Item>,
+        U: Iterator<Item=Self::Item>,
     {
         Chain{a: self, b: other, flag: false}
     }
@@ -228,8 +228,8 @@ fn zip<B, U>(self, other: U) -> Zip<Self, U> where
     /// ```
     #[inline]
     #[stable]
-    fn map<B, F>(self, f: F) -> Map< <Self as Iterator>::Item, B, Self, F> where
-        F: FnMut(<Self as Iterator>::Item) -> B,
+    fn map<B, F>(self, f: F) -> Map<Self::Item, B, Self, F> where
+        F: FnMut(Self::Item) -> B,
     {
         Map{iter: self, f: f}
     }
@@ -248,8 +248,8 @@ fn map<B, F>(self, f: F) -> Map< <Self as Iterator>::Item, B, Self, F> where
     /// ```
     #[inline]
     #[stable]
-    fn filter<P>(self, predicate: P) -> Filter< <Self as Iterator>::Item, Self, P> where
-        P: FnMut(&<Self as Iterator>::Item) -> bool,
+    fn filter<P>(self, predicate: P) -> Filter<Self::Item, Self, P> where
+        P: FnMut(&Self::Item) -> bool,
     {
         Filter{iter: self, predicate: predicate}
     }
@@ -268,8 +268,8 @@ fn filter<P>(self, predicate: P) -> Filter< <Self as Iterator>::Item, Self, P> w
     /// ```
     #[inline]
     #[stable]
-    fn filter_map<B, F>(self, f: F) -> FilterMap< <Self as Iterator>::Item, B, Self, F> where
-        F: FnMut(<Self as Iterator>::Item) -> Option<B>,
+    fn filter_map<B, F>(self, f: F) -> FilterMap<Self::Item, B, Self, F> where
+        F: FnMut(Self::Item) -> Option<B>,
     {
         FilterMap { iter: self, f: f }
     }
@@ -312,7 +312,7 @@ fn enumerate(self) -> Enumerate<Self> {
     /// ```
     #[inline]
     #[stable]
-    fn peekable(self) -> Peekable< <Self as Iterator>::Item, Self> {
+    fn peekable(self) -> Peekable<Self::Item, Self> {
         Peekable{iter: self, peeked: None}
     }
 
@@ -332,8 +332,8 @@ fn peekable(self) -> Peekable< <Self as Iterator>::Item, Self> {
     /// ```
     #[inline]
     #[stable]
-    fn skip_while<P>(self, predicate: P) -> SkipWhile< <Self as Iterator>::Item, Self, P> where
-        P: FnMut(&<Self as Iterator>::Item) -> bool,
+    fn skip_while<P>(self, predicate: P) -> SkipWhile<Self::Item, Self, P> where
+        P: FnMut(&Self::Item) -> bool,
     {
         SkipWhile{iter: self, flag: false, predicate: predicate}
     }
@@ -353,8 +353,8 @@ fn skip_while<P>(self, predicate: P) -> SkipWhile< <Self as Iterator>::Item, Sel
     /// ```
     #[inline]
     #[stable]
-    fn take_while<P>(self, predicate: P) -> TakeWhile< <Self as Iterator>::Item, Self, P> where
-        P: FnMut(&<Self as Iterator>::Item) -> bool,
+    fn take_while<P>(self, predicate: P) -> TakeWhile<Self::Item, Self, P> where
+        P: FnMut(&Self::Item) -> bool,
     {
         TakeWhile{iter: self, flag: false, predicate: predicate}
     }
@@ -422,8 +422,8 @@ fn scan<St, B, F>(
         self,
         initial_state: St,
         f: F,
-    ) -> Scan< <Self as Iterator>::Item, B, Self, St, F> where
-        F: FnMut(&mut St, <Self as Iterator>::Item) -> Option<B>,
+    ) -> Scan<Self::Item, B, Self, St, F> where
+        F: FnMut(&mut St, Self::Item) -> Option<B>,
     {
         Scan{iter: self, f: f, state: initial_state}
     }
@@ -448,9 +448,9 @@ fn scan<St, B, F>(
     /// ```
     #[inline]
     #[stable]
-    fn flat_map<B, U, F>(self, f: F) -> FlatMap< <Self as Iterator>::Item, B, Self, U, F> where
+    fn flat_map<B, U, F>(self, f: F) -> FlatMap<Self::Item, B, Self, U, F> where
         U: Iterator<Item=B>,
-        F: FnMut(<Self as Iterator>::Item) -> U,
+        F: FnMut(Self::Item) -> U,
     {
         FlatMap{iter: self, f: f, frontiter: None, backiter: None }
     }
@@ -508,8 +508,8 @@ fn fuse(self) -> Fuse<Self> {
     /// ```
     #[inline]
     #[stable]
-    fn inspect<F>(self, f: F) -> Inspect< <Self as Iterator>::Item, Self, F> where
-        F: FnMut(&<Self as Iterator>::Item),
+    fn inspect<F>(self, f: F) -> Inspect<Self::Item, Self, F> where
+        F: FnMut(&Self::Item),
     {
         Inspect{iter: self, f: f}
     }
@@ -546,7 +546,7 @@ fn by_ref<'r>(&'r mut self) -> ByRef<'r, Self> {
     /// ```
     #[inline]
     #[stable]
-    fn collect<B: FromIterator< <Self as Iterator>::Item>>(self) -> B {
+    fn collect<B: FromIterator<Self::Item>>(self) -> B {
         FromIterator::from_iter(self)
     }
 
@@ -563,8 +563,8 @@ fn collect<B: FromIterator< <Self as Iterator>::Item>>(self) -> B {
     /// ```
     #[unstable = "recently added as part of collections reform"]
     fn partition<B, F>(mut self, mut f: F) -> (B, B) where
-        B: Default + Extend< <Self as Iterator>::Item>,
-        F: FnMut(&<Self as Iterator>::Item) -> bool
+        B: Default + Extend<Self::Item>,
+        F: FnMut(&Self::Item) -> bool
     {
         let mut left: B = Default::default();
         let mut right: B = Default::default();
@@ -592,7 +592,7 @@ fn partition<B, F>(mut self, mut f: F) -> (B, B) where
     #[inline]
     #[stable]
     fn fold<B, F>(mut self, init: B, mut f: F) -> B where
-        F: FnMut(B, <Self as Iterator>::Item) -> B,
+        F: FnMut(B, Self::Item) -> B,
     {
         let mut accum = init;
         for x in self {
@@ -612,7 +612,7 @@ fn fold<B, F>(mut self, init: B, mut f: F) -> B where
     /// ```
     #[inline]
     #[stable]
-    fn all<F>(mut self, mut f: F) -> bool where F: FnMut(<Self as Iterator>::Item) -> bool {
+    fn all<F>(mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
         for x in self { if !f(x) { return false; } }
         true
     }
@@ -630,7 +630,7 @@ fn all<F>(mut self, mut f: F) -> bool where F: FnMut(<Self as Iterator>::Item) -
     /// ```
     #[inline]
     #[stable]
-    fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(<Self as Iterator>::Item) -> bool {
+    fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(Self::Item) -> bool {
         for x in *self { if f(x) { return true; } }
         false
     }
@@ -640,8 +640,8 @@ fn any<F>(&mut self, mut f: F) -> bool where F: FnMut(<Self as Iterator>::Item)
     /// Does not consume the iterator past the first found element.
     #[inline]
     #[stable]
-    fn find<P>(&mut self, mut predicate: P) -> Option< <Self as Iterator>::Item> where
-        P: FnMut(&<Self as Iterator>::Item) -> bool,
+    fn find<P>(&mut self, mut predicate: P) -> Option<Self::Item> where
+        P: FnMut(&Self::Item) -> bool,
     {
         for x in *self {
             if predicate(&x) { return Some(x) }
@@ -653,7 +653,7 @@ fn find<P>(&mut self, mut predicate: P) -> Option< <Self as Iterator>::Item> whe
     #[inline]
     #[stable]
     fn position<P>(&mut self, mut predicate: P) -> Option<uint> where
-        P: FnMut(<Self as Iterator>::Item) -> bool,
+        P: FnMut(Self::Item) -> bool,
     {
         let mut i = 0;
         for x in *self {
@@ -671,7 +671,7 @@ fn position<P>(&mut self, mut predicate: P) -> Option<uint> where
     #[inline]
     #[stable]
     fn rposition<P>(&mut self, mut predicate: P) -> Option<uint> where
-        P: FnMut(<Self as Iterator>::Item) -> bool,
+        P: FnMut(Self::Item) -> bool,
         Self: ExactSizeIterator + DoubleEndedIterator
     {
         let len = self.len();
@@ -693,8 +693,7 @@ fn rposition<P>(&mut self, mut predicate: P) -> Option<uint> where
     /// ```
     #[inline]
     #[stable]
-    fn max(self) -> Option< <Self as Iterator>::Item> where
-        <Self as Iterator>::Item: Ord
+    fn max(self) -> Option<Self::Item> where Self::Item: Ord
     {
         self.fold(None, |max, x| {
             match max {
@@ -714,8 +713,7 @@ fn max(self) -> Option< <Self as Iterator>::Item> where
     /// ```
     #[inline]
     #[stable]
-    fn min(self) -> Option< <Self as Iterator>::Item> where
-        <Self as Iterator>::Item: Ord
+    fn min(self) -> Option<Self::Item> where Self::Item: Ord
     {
         self.fold(None, |min, x| {
             match min {
@@ -759,8 +757,7 @@ fn min(self) -> Option< <Self as Iterator>::Item> where
     /// assert!(v.iter().min_max() == MinMax(&1, &1));
     /// ```
     #[unstable = "return type may change"]
-    fn min_max(mut self) -> MinMaxResult< <Self as Iterator>::Item> where
-        <Self as Iterator>::Item: Ord
+    fn min_max(mut self) -> MinMaxResult<Self::Item> where Self::Item: Ord
     {
         let (mut min, mut max) = match self.next() {
             None => return NoElements,
@@ -817,10 +814,10 @@ fn min_max(mut self) -> MinMaxResult< <Self as Iterator>::Item> where
     /// ```
     #[inline]
     #[unstable = "may want to produce an Ordering directly; see #15311"]
-    fn max_by<B: Ord, F>(self, mut f: F) -> Option< <Self as Iterator>::Item> where
-        F: FnMut(&<Self as Iterator>::Item) -> B,
+    fn max_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
+        F: FnMut(&Self::Item) -> B,
     {
-        self.fold(None, |max: Option<(<Self as Iterator>::Item, B)>, x| {
+        self.fold(None, |max: Option<(Self::Item, B)>, x| {
             let x_val = f(&x);
             match max {
                 None             => Some((x, x_val)),
@@ -846,10 +843,10 @@ fn max_by<B: Ord, F>(self, mut f: F) -> Option< <Self as Iterator>::Item> where
     /// ```
     #[inline]
     #[unstable = "may want to produce an Ordering directly; see #15311"]
-    fn min_by<B: Ord, F>(self, mut f: F) -> Option< <Self as Iterator>::Item> where
-        F: FnMut(&<Self as Iterator>::Item) -> B,
+    fn min_by<B: Ord, F>(self, mut f: F) -> Option<Self::Item> where
+        F: FnMut(&Self::Item) -> B,
     {
-        self.fold(None, |min: Option<(<Self as Iterator>::Item, B)>, x| {
+        self.fold(None, |min: Option<(Self::Item, B)>, x| {
             let x_val = f(&x);
             match min {
                 None             => Some((x, x_val)),
@@ -968,7 +965,7 @@ impl<I> IteratorExt for I where I: Iterator {}
 #[stable]
 pub trait DoubleEndedIterator: Iterator {
     /// Yield an element from the end of the range, returning `None` if the range is empty.
-    fn next_back(&mut self) -> Option< <Self as Iterator>::Item>;
+    fn next_back(&mut self) -> Option<Self::Item>;
 }
 
 /// An object implementing random access indexing by `uint`
@@ -984,7 +981,7 @@ pub trait RandomAccessIterator: Iterator {
     fn indexable(&self) -> uint;
 
     /// Return an element at an index, or `None` if the index is out of bounds
-    fn idx(&mut self, index: uint) -> Option< <Self as Iterator>::Item>;
+    fn idx(&mut self, index: uint) -> Option<Self::Item>;
 }
 
 /// An iterator that knows its exact length
@@ -1015,14 +1012,14 @@ fn len(&self) -> uint {
 impl<I> ExactSizeIterator for Enumerate<I> where I: ExactSizeIterator {}
 #[stable]
 impl<A, I, F> ExactSizeIterator for Inspect<A, I, F> where
-    I: ExactSizeIterator + Iterator<Item=A>,
+    I: ExactSizeIterator<Item=A>,
     F: FnMut(&A),
 {}
 #[stable]
 impl<I> ExactSizeIterator for Rev<I> where I: ExactSizeIterator + DoubleEndedIterator {}
 #[stable]
 impl<A, B, I, F> ExactSizeIterator for Map<A, B, I, F> where
-    I: ExactSizeIterator + Iterator<Item=A>,
+    I: ExactSizeIterator<Item=A>,
     F: FnMut(A) -> B,
 {}
 #[stable]
@@ -1041,7 +1038,7 @@ impl<I> Iterator for Rev<I> where I: DoubleEndedIterator {
     type Item = <I as Iterator>::Item;
 
     #[inline]
-    fn next(&mut self) -> Option< <I as Iterator>::Item> { self.iter.next_back() }
+    fn next(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next_back() }
     #[inline]
     fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
 }
@@ -1049,7 +1046,7 @@ fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
 #[stable]
 impl<I> DoubleEndedIterator for Rev<I> where I: DoubleEndedIterator {
     #[inline]
-    fn next_back(&mut self) -> Option< <I as Iterator>::Item> { self.iter.next() }
+    fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next() }
 }
 
 #[experimental = "trait is experimental"]
@@ -1057,7 +1054,7 @@ impl<I> RandomAccessIterator for Rev<I> where I: DoubleEndedIterator + RandomAcc
     #[inline]
     fn indexable(&self) -> uint { self.iter.indexable() }
     #[inline]
-    fn idx(&mut self, index: uint) -> Option< <I as Iterator>::Item> {
+    fn idx(&mut self, index: uint) -> Option<<I as Iterator>::Item> {
         let amt = self.indexable();
         self.iter.idx(amt - index - 1)
     }
@@ -1075,7 +1072,7 @@ impl<'a, I> Iterator for ByRef<'a, I> where I: 'a + Iterator {
     type Item = <I as Iterator>::Item;
 
     #[inline]
-    fn next(&mut self) -> Option< <I as Iterator>::Item> { self.iter.next() }
+    fn next(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next() }
     #[inline]
     fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
 }
@@ -1083,7 +1080,7 @@ fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
 #[stable]
 impl<'a, I> DoubleEndedIterator for ByRef<'a, I> where I: 'a + DoubleEndedIterator {
     #[inline]
-    fn next_back(&mut self) -> Option< <I as Iterator>::Item> { self.iter.next_back() }
+    fn next_back(&mut self) -> Option<<I as Iterator>::Item> { self.iter.next_back() }
 }
 
 /// A trait for iterators over elements which can be added together
@@ -1244,7 +1241,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 impl<T, D, I> DoubleEndedIterator for Cloned<I> where
     T: Clone,
     D: Deref<Target=T>,
-    I: DoubleEndedIterator + Iterator<Item=D>,
+    I: DoubleEndedIterator<Item=D>,
 {
     fn next_back(&mut self) -> Option<T> {
         self.it.next_back().cloned()
@@ -1255,7 +1252,7 @@ fn next_back(&mut self) -> Option<T> {
 impl<T, D, I> ExactSizeIterator for Cloned<I> where
     T: Clone,
     D: Deref<Target=T>,
-    I: ExactSizeIterator + Iterator<Item=D>,
+    I: ExactSizeIterator<Item=D>,
 {}
 
 /// An iterator that repeats endlessly
@@ -1272,7 +1269,7 @@ impl<I> Iterator for Cycle<I> where I: Clone + Iterator {
     type Item = <I as Iterator>::Item;
 
     #[inline]
-    fn next(&mut self) -> Option< <I as Iterator>::Item> {
+    fn next(&mut self) -> Option<<I as Iterator>::Item> {
         match self.iter.next() {
             None => { self.iter = self.orig.clone(); self.iter.next() }
             y => y
@@ -1304,7 +1301,7 @@ fn indexable(&self) -> uint {
     }
 
     #[inline]
-    fn idx(&mut self, index: uint) -> Option< <I as Iterator>::Item> {
+    fn idx(&mut self, index: uint) -> Option<<I as Iterator>::Item> {
         let liter = self.iter.indexable();
         let lorig = self.orig.indexable();
         if lorig == 0 {
@@ -1363,8 +1360,8 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 
 #[stable]
 impl<T, A, B> DoubleEndedIterator for Chain<A, B> where
-    A: DoubleEndedIterator + Iterator<Item=T>,
-    B: DoubleEndedIterator + Iterator<Item=T>,
+    A: DoubleEndedIterator<Item=T>,
+    B: DoubleEndedIterator<Item=T>,
 {
     #[inline]
     fn next_back(&mut self) -> Option<T> {
@@ -1377,8 +1374,8 @@ fn next_back(&mut self) -> Option<T> {
 
 #[experimental = "trait is experimental"]
 impl<T, A, B> RandomAccessIterator for Chain<A, B> where
-    A: RandomAccessIterator + Iterator<Item=T>,
-    B: RandomAccessIterator + Iterator<Item=T>,
+    A: RandomAccessIterator<Item=T>,
+    B: RandomAccessIterator<Item=T>,
 {
     #[inline]
     fn indexable(&self) -> uint {
@@ -1444,8 +1441,8 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 
 #[stable]
 impl<T, U, A, B> DoubleEndedIterator for Zip<A, B> where
-    A: ExactSizeIterator + Iterator<Item=T> + DoubleEndedIterator,
-    B: ExactSizeIterator + Iterator<Item=U> + DoubleEndedIterator,
+    A: DoubleEndedIterator + ExactSizeIterator<Item=T>,
+    B: DoubleEndedIterator + ExactSizeIterator<Item=U>,
 {
     #[inline]
     fn next_back(&mut self) -> Option<(T, U)> {
@@ -1469,8 +1466,8 @@ fn next_back(&mut self) -> Option<(T, U)> {
 
 #[experimental = "trait is experimental"]
 impl<T, U, A, B> RandomAccessIterator for Zip<A, B> where
-    A: RandomAccessIterator + Iterator<Item=T>,
-    B: RandomAccessIterator + Iterator<Item=U>,
+    A: RandomAccessIterator<Item=T>,
+    B: RandomAccessIterator<Item=U>,
 {
     #[inline]
     fn indexable(&self) -> uint {
@@ -1539,7 +1536,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 
 #[stable]
 impl<A, B, I, F> DoubleEndedIterator for Map<A, B, I, F> where
-    I: DoubleEndedIterator + Iterator<Item=A>,
+    I: DoubleEndedIterator<Item=A>,
     F: FnMut(A) -> B,
 {
     #[inline]
@@ -1551,7 +1548,7 @@ fn next_back(&mut self) -> Option<B> {
 
 #[experimental = "trait is experimental"]
 impl<A, B, I, F> RandomAccessIterator for Map<A, B, I, F> where
-    I: RandomAccessIterator + Iterator<Item=A>,
+    I: RandomAccessIterator<Item=A>,
     F: FnMut(A) -> B,
 {
     #[inline]
@@ -1613,7 +1610,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 
 #[stable]
 impl<A, I, P> DoubleEndedIterator for Filter<A, I, P> where
-    I: DoubleEndedIterator + Iterator<Item=A>,
+    I: DoubleEndedIterator<Item=A>,
     P: FnMut(&A) -> bool,
 {
     #[inline]
@@ -1676,7 +1673,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 
 #[stable]
 impl<A, B, I, F> DoubleEndedIterator for FilterMap<A, B, I, F> where
-    I: DoubleEndedIterator + Iterator<Item=A>,
+    I: DoubleEndedIterator<Item=A>,
     F: FnMut(A) -> Option<B>,
 {
     #[inline]
@@ -1925,7 +1922,7 @@ impl<I> Iterator for Skip<I> where I: Iterator {
     type Item = <I as Iterator>::Item;
 
     #[inline]
-    fn next(&mut self) -> Option< <I as Iterator>::Item> {
+    fn next(&mut self) -> Option<<I as Iterator>::Item> {
         let mut next = self.iter.next();
         if self.n == 0 {
             next
@@ -1972,7 +1969,7 @@ fn indexable(&self) -> uint {
     }
 
     #[inline]
-    fn idx(&mut self, index: uint) -> Option< <I as Iterator>::Item> {
+    fn idx(&mut self, index: uint) -> Option<<I as Iterator>::Item> {
         if index >= self.indexable() {
             None
         } else {
@@ -1995,7 +1992,7 @@ impl<I> Iterator for Take<I> where I: Iterator{
     type Item = <I as Iterator>::Item;
 
     #[inline]
-    fn next(&mut self) -> Option< <I as Iterator>::Item> {
+    fn next(&mut self) -> Option<<I as Iterator>::Item> {
         if self.n != 0 {
             self.n -= 1;
             self.iter.next()
@@ -2027,7 +2024,7 @@ fn indexable(&self) -> uint {
     }
 
     #[inline]
-    fn idx(&mut self, index: uint) -> Option< <I as Iterator>::Item> {
+    fn idx(&mut self, index: uint) -> Option<<I as Iterator>::Item> {
         if index >= self.n {
             None
         } else {
@@ -2153,8 +2150,8 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 
 #[stable]
 impl<A, B, I, U, F> DoubleEndedIterator for FlatMap<A, B, I, U, F> where
-    I: DoubleEndedIterator + Iterator<Item=A>,
-    U: DoubleEndedIterator + Iterator<Item=B>,
+    I: DoubleEndedIterator<Item=A>,
+    U: DoubleEndedIterator<Item=B>,
     F: FnMut(A) -> U,
 {
     #[inline]
@@ -2189,7 +2186,7 @@ impl<I> Iterator for Fuse<I> where I: Iterator {
     type Item = <I as Iterator>::Item;
 
     #[inline]
-    fn next(&mut self) -> Option< <I as Iterator>::Item> {
+    fn next(&mut self) -> Option<<I as Iterator>::Item> {
         if self.done {
             None
         } else {
@@ -2216,7 +2213,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 #[stable]
 impl<I> DoubleEndedIterator for Fuse<I> where I: DoubleEndedIterator {
     #[inline]
-    fn next_back(&mut self) -> Option< <I as Iterator>::Item> {
+    fn next_back(&mut self) -> Option<<I as Iterator>::Item> {
         if self.done {
             None
         } else {
@@ -2240,7 +2237,7 @@ fn indexable(&self) -> uint {
     }
 
     #[inline]
-    fn idx(&mut self, index: uint) -> Option< <I as Iterator>::Item> {
+    fn idx(&mut self, index: uint) -> Option<<I as Iterator>::Item> {
         self.iter.idx(index)
     }
 }
@@ -2308,7 +2305,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 
 #[stable]
 impl<A, I, F> DoubleEndedIterator for Inspect<A, I, F> where
-    I: DoubleEndedIterator + Iterator<Item=A>,
+    I: DoubleEndedIterator<Item=A>,
     F: FnMut(&A),
 {
     #[inline]
@@ -2320,7 +2317,7 @@ fn next_back(&mut self) -> Option<A> {
 
 #[experimental = "trait is experimental"]
 impl<A, I, F> RandomAccessIterator for Inspect<A, I, F> where
-    I: RandomAccessIterator + Iterator<Item=A>,
+    I: RandomAccessIterator<Item=A>,
     F: FnMut(&A),
 {
     #[inline]
diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs
deleted file mode 100644 (file)
index 5d69938..0000000
+++ /dev/null
@@ -1,298 +0,0 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
-// 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.
-
-//! Primitive traits representing basic 'kinds' of types
-//!
-//! Rust types can be classified in various useful ways according to
-//! intrinsic properties of the type. These classifications, often called
-//! 'kinds', are represented as traits.
-//!
-//! They cannot be implemented by user code, but are instead implemented
-//! by the compiler automatically for the types to which they apply.
-
-/// Types able to be transferred across task boundaries.
-#[lang="send"]
-pub unsafe trait Send : 'static {
-    // empty.
-}
-
-/// Types with a constant size known at compile-time.
-#[lang="sized"]
-pub trait Sized {
-    // Empty.
-}
-
-/// Types that can be copied by simply copying bits (i.e. `memcpy`).
-#[lang="copy"]
-pub trait Copy {
-    // Empty.
-}
-
-/// Types that can be safely shared between tasks when aliased.
-///
-/// The precise definition is: a type `T` is `Sync` if `&T` is
-/// thread-safe. In other words, there is no possibility of data races
-/// when passing `&T` references between tasks.
-///
-/// As one would expect, primitive types like `u8` and `f64` are all
-/// `Sync`, and so are simple aggregate types containing them (like
-/// tuples, structs and enums). More instances of basic `Sync` types
-/// include "immutable" types like `&T` and those with simple
-/// inherited mutability, such as `Box<T>`, `Vec<T>` and most other
-/// collection types. (Generic parameters need to be `Sync` for their
-/// container to be `Sync`.)
-///
-/// A somewhat surprising consequence of the definition is `&mut T` is
-/// `Sync` (if `T` is `Sync`) even though it seems that it might
-/// provide unsynchronised mutation. The trick is a mutable reference
-/// stored in an aliasable reference (that is, `& &mut T`) becomes
-/// read-only, as if it were a `& &T`, hence there is no risk of a data
-/// race.
-///
-/// Types that are not `Sync` are those that have "interior
-/// mutability" in a non-thread-safe way, such as `Cell` and `RefCell`
-/// in `std::cell`. These types allow for mutation of their contents
-/// even when in an immutable, aliasable slot, e.g. the contents of
-/// `&Cell<T>` can be `.set`, and do not ensure data races are
-/// impossible, hence they cannot be `Sync`. A higher level example
-/// of a non-`Sync` type is the reference counted pointer
-/// `std::rc::Rc`, because any reference `&Rc<T>` can clone a new
-/// reference, which modifies the reference counts in a non-atomic
-/// way.
-///
-/// For cases when one does need thread-safe interior mutability,
-/// types like the atomics in `std::sync` and `Mutex` & `RWLock` in
-/// the `sync` crate do ensure that any mutation cannot cause data
-/// races.  Hence these types are `Sync`.
-///
-/// Users writing their own types with interior mutability (or anything
-/// else that is not thread-safe) should use the `NoSync` marker type
-/// (from `std::kinds::marker`) to ensure that the compiler doesn't
-/// consider the user-defined type to be `Sync`.  Any types with
-/// interior mutability must also use the `std::cell::UnsafeCell` wrapper
-/// around the value(s) which can be mutated when behind a `&`
-/// reference; not doing this is undefined behaviour (for example,
-/// `transmute`-ing from `&T` to `&mut T` is illegal).
-#[lang="sync"]
-pub unsafe trait Sync {
-    // Empty
-}
-
-/// Marker types are special types that are used with unsafe code to
-/// inform the compiler of special constraints. Marker types should
-/// only be needed when you are creating an abstraction that is
-/// implemented using unsafe code. In that case, you may want to embed
-/// some of the marker types below into your type.
-pub mod marker {
-    use super::{Copy,Sized};
-    use clone::Clone;
-
-    /// A marker type whose type parameter `T` is considered to be
-    /// covariant with respect to the type itself. This is (typically)
-    /// used to indicate that an instance of the type `T` is being stored
-    /// into memory and read from, even though that may not be apparent.
-    ///
-    /// For more information about variance, refer to this Wikipedia
-    /// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-    ///
-    /// *Note:* It is very unusual to have to add a covariant constraint.
-    /// If you are not sure, you probably want to use `InvariantType`.
-    ///
-    /// # Example
-    ///
-    /// Given a struct `S` that includes a type parameter `T`
-    /// but does not actually *reference* that type parameter:
-    ///
-    /// ```ignore
-    /// use std::mem;
-    ///
-    /// struct S<T> { x: *() }
-    /// fn get<T>(s: &S<T>) -> T {
-    ///    unsafe {
-    ///        let x: *T = mem::transmute(s.x);
-    ///        *x
-    ///    }
-    /// }
-    /// ```
-    ///
-    /// The type system would currently infer that the value of
-    /// the type parameter `T` is irrelevant, and hence a `S<int>` is
-    /// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
-    /// any `U`). But this is incorrect because `get()` converts the
-    /// `*()` into a `*T` and reads from it. Therefore, we should include the
-    /// a marker field `CovariantType<T>` to inform the type checker that
-    /// `S<T>` is a subtype of `S<U>` if `T` is a subtype of `U`
-    /// (for example, `S<&'static int>` is a subtype of `S<&'a int>`
-    /// for some lifetime `'a`, but not the other way around).
-    #[lang="covariant_type"]
-    #[derive(PartialEq, Eq, PartialOrd, Ord)]
-    pub struct CovariantType<T: ?Sized>;
-
-    impl<T: ?Sized> Copy for CovariantType<T> {}
-    impl<T: ?Sized> Clone for CovariantType<T> {
-        fn clone(&self) -> CovariantType<T> { *self }
-    }
-
-    /// A marker type whose type parameter `T` is considered to be
-    /// contravariant with respect to the type itself. This is (typically)
-    /// used to indicate that an instance of the type `T` will be consumed
-    /// (but not read from), even though that may not be apparent.
-    ///
-    /// For more information about variance, refer to this Wikipedia
-    /// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-    ///
-    /// *Note:* It is very unusual to have to add a contravariant constraint.
-    /// If you are not sure, you probably want to use `InvariantType`.
-    ///
-    /// # Example
-    ///
-    /// Given a struct `S` that includes a type parameter `T`
-    /// but does not actually *reference* that type parameter:
-    ///
-    /// ```
-    /// use std::mem;
-    ///
-    /// struct S<T> { x: *const () }
-    /// fn get<T>(s: &S<T>, v: T) {
-    ///    unsafe {
-    ///        let x: fn(T) = mem::transmute(s.x);
-    ///        x(v)
-    ///    }
-    /// }
-    /// ```
-    ///
-    /// The type system would currently infer that the value of
-    /// the type parameter `T` is irrelevant, and hence a `S<int>` is
-    /// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
-    /// any `U`). But this is incorrect because `get()` converts the
-    /// `*()` into a `fn(T)` and then passes a value of type `T` to it.
-    ///
-    /// Supplying a `ContravariantType` marker would correct the
-    /// problem, because it would mark `S` so that `S<T>` is only a
-    /// subtype of `S<U>` if `U` is a subtype of `T`; given that the
-    /// function requires arguments of type `T`, it must also accept
-    /// arguments of type `U`, hence such a conversion is safe.
-    #[lang="contravariant_type"]
-    #[derive(PartialEq, Eq, PartialOrd, Ord)]
-    pub struct ContravariantType<T: ?Sized>;
-
-    impl<T: ?Sized> Copy for ContravariantType<T> {}
-    impl<T: ?Sized> Clone for ContravariantType<T> {
-        fn clone(&self) -> ContravariantType<T> { *self }
-    }
-
-    /// A marker type whose type parameter `T` is considered to be
-    /// invariant with respect to the type itself. This is (typically)
-    /// used to indicate that instances of the type `T` may be read or
-    /// written, even though that may not be apparent.
-    ///
-    /// For more information about variance, refer to this Wikipedia
-    /// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-    ///
-    /// # Example
-    ///
-    /// The Cell type is an example which uses unsafe code to achieve
-    /// "interior" mutability:
-    ///
-    /// ```
-    /// pub struct Cell<T> { value: T }
-    /// # fn main() {}
-    /// ```
-    ///
-    /// The type system would infer that `value` is only read here and
-    /// never written, but in fact `Cell` uses unsafe code to achieve
-    /// interior mutability.
-    #[lang="invariant_type"]
-    #[derive(PartialEq, Eq, PartialOrd, Ord)]
-    pub struct InvariantType<T: ?Sized>;
-
-    impl<T: ?Sized> Copy for InvariantType<T> {}
-    impl<T: ?Sized> Clone for InvariantType<T> {
-        fn clone(&self) -> InvariantType<T> { *self }
-    }
-
-    /// As `CovariantType`, but for lifetime parameters. Using
-    /// `CovariantLifetime<'a>` indicates that it is ok to substitute
-    /// a *longer* lifetime for `'a` than the one you originally
-    /// started with (e.g., you could convert any lifetime `'foo` to
-    /// `'static`). You almost certainly want `ContravariantLifetime`
-    /// instead, or possibly `InvariantLifetime`. The only case where
-    /// it would be appropriate is that you have a (type-casted, and
-    /// hence hidden from the type system) function pointer with a
-    /// signature like `fn(&'a T)` (and no other uses of `'a`). In
-    /// this case, it is ok to substitute a larger lifetime for `'a`
-    /// (e.g., `fn(&'static T)`), because the function is only
-    /// becoming more selective in terms of what it accepts as
-    /// argument.
-    ///
-    /// For more information about variance, refer to this Wikipedia
-    /// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-    #[lang="covariant_lifetime"]
-    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-    pub struct CovariantLifetime<'a>;
-
-    /// As `ContravariantType`, but for lifetime parameters. Using
-    /// `ContravariantLifetime<'a>` indicates that it is ok to
-    /// substitute a *shorter* lifetime for `'a` than the one you
-    /// originally started with (e.g., you could convert `'static` to
-    /// any lifetime `'foo`). This is appropriate for cases where you
-    /// have an unsafe pointer that is actually a pointer into some
-    /// memory with lifetime `'a`, and thus you want to limit the
-    /// lifetime of your data structure to `'a`. An example of where
-    /// this is used is the iterator for vectors.
-    ///
-    /// For more information about variance, refer to this Wikipedia
-    /// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
-    #[lang="contravariant_lifetime"]
-    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-    pub struct ContravariantLifetime<'a>;
-
-    /// As `InvariantType`, but for lifetime parameters. Using
-    /// `InvariantLifetime<'a>` indicates that it is not ok to
-    /// substitute any other lifetime for `'a` besides its original
-    /// value. This is appropriate for cases where you have an unsafe
-    /// pointer that is actually a pointer into memory with lifetime `'a`,
-    /// and this pointer is itself stored in an inherently mutable
-    /// location (such as a `Cell`).
-    #[lang="invariant_lifetime"]
-    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-    pub struct InvariantLifetime<'a>;
-
-    /// A type which is considered "not sendable", meaning that it cannot
-    /// be safely sent between tasks, even if it is owned. This is
-    /// typically embedded in other types, such as `Gc`, to ensure that
-    /// their instances remain thread-local.
-    #[lang="no_send_bound"]
-    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-    pub struct NoSend;
-
-    /// A type which is considered "not POD", meaning that it is not
-    /// implicitly copyable. This is typically embedded in other types to
-    /// ensure that they are never copied, even if they lack a destructor.
-    #[lang="no_copy_bound"]
-    #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
-    #[allow(missing_copy_implementations)]
-    pub struct NoCopy;
-
-    /// A type which is considered "not sync", meaning that
-    /// its contents are not threadsafe, hence they cannot be
-    /// shared between tasks.
-    #[lang="no_sync_bound"]
-    #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
-    pub struct NoSync;
-
-    /// A type which is considered managed by the GC. This is typically
-    /// embedded in other types.
-    #[lang="managed_bound"]
-    #[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
-    #[allow(missing_copy_implementations)]
-    pub struct Managed;
-}
-
index aff0065c52744d8d8430b8d7b9c69ef9125213cd..a7e3b61b0d42bd6ac7be7c94e90af53a216265d0 100644 (file)
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![no_std]
-#![allow(unknown_features, raw_pointer_deriving)]
-#![feature(globs, intrinsics, lang_items, macro_rules, phase)]
+#![allow(unknown_features, raw_pointer_derive)]
+#![feature(intrinsics, lang_items)]
 #![feature(simd, unsafe_destructor, slicing_syntax)]
-#![feature(default_type_params, unboxed_closures, associated_types)]
+#![feature(unboxed_closures)]
 #![deny(missing_docs)]
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod macros;
 
 #[path = "num/float_macros.rs"]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod float_macros;
 
 #[path = "num/int_macros.rs"]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod int_macros;
 
 #[path = "num/uint_macros.rs"]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod uint_macros;
 
 #[path = "num/int.rs"]  pub mod int;
 
 /* Core language traits */
 
-pub mod kinds;
+pub mod marker;
 pub mod ops;
 pub mod cmp;
 pub mod clone;
@@ -150,7 +146,9 @@ mod core {
 mod std {
     pub use clone;
     pub use cmp;
-    pub use kinds;
+    #[cfg(stage0)]
+    pub use marker as kinds;
+    pub use marker;
     pub use option;
     pub use fmt;
     pub use hash;
index a579f9db4161c3a8f04b1742a1f53d1602a7e96a..bfe88fff22fb1ff2290652809227e9aa4fa09302 100644 (file)
@@ -83,7 +83,7 @@ macro_rules! assert_eq {
                 if !((*left_val == *right_val) &&
                      (*right_val == *left_val)) {
                     panic!("assertion failed: `(left == right) && (right == left)` \
-                           (left: `{}`, right: `{}`)", *left_val, *right_val)
+                           (left: `{:?}`, right: `{:?}`)", *left_val, *right_val)
                 }
             }
         }
@@ -142,16 +142,9 @@ macro_rules! debug_assert_eq {
     ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert_eq!($($arg)*); })
 }
 
-#[cfg(stage0)]
-#[macro_export]
-macro_rules! try {
-    ($e:expr) => (match $e { Ok(e) => e, Err(e) => return Err(e) })
-}
-
 /// Short circuiting evaluation on Err
 ///
 /// `libstd` contains a more general `try!` macro that uses `FromError`.
-#[cfg(not(stage0))]
 #[macro_export]
 macro_rules! try {
     ($e:expr) => ({
@@ -186,9 +179,12 @@ macro_rules! write {
 #[macro_export]
 #[stable]
 macro_rules! writeln {
-    ($dst:expr, $fmt:expr $($arg:tt)*) => (
-        write!($dst, concat!($fmt, "\n") $($arg)*)
-    )
+    ($dst:expr, $fmt:expr) => (
+        write!($dst, concat!($fmt, "\n"))
+    );
+    ($dst:expr, $fmt:expr, $($arg:tt)*) => (
+        write!($dst, concat!($fmt, "\n"), $($arg)*)
+    );
 }
 
 /// A utility macro for indicating unreachable code.
diff --git a/src/libcore/marker.rs b/src/libcore/marker.rs
new file mode 100644 (file)
index 0000000..d400cb4
--- /dev/null
@@ -0,0 +1,314 @@
+// Copyright 2012-2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+//! Primitive traits and marker types representing basic 'kinds' of types.
+//!
+//! Rust types can be classified in various useful ways according to
+//! intrinsic properties of the type. These classifications, often called
+//! 'kinds', are represented as traits.
+//!
+//! They cannot be implemented by user code, but are instead implemented
+//! by the compiler automatically for the types to which they apply.
+//!
+//! Marker types are special types that are used with unsafe code to
+//! inform the compiler of special constraints. Marker types should
+//! only be needed when you are creating an abstraction that is
+//! implemented using unsafe code. In that case, you may want to embed
+//! some of the marker types below into your type.
+
+#![stable]
+
+use clone::Clone;
+
+/// Types able to be transferred across task boundaries.
+#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
+#[lang="send"]
+pub unsafe trait Send: 'static {
+    // empty.
+}
+
+/// Types with a constant size known at compile-time.
+#[stable]
+#[lang="sized"]
+pub trait Sized {
+    // Empty.
+}
+
+/// Types that can be copied by simply copying bits (i.e. `memcpy`).
+#[stable]
+#[lang="copy"]
+pub trait Copy {
+    // Empty.
+}
+
+/// Types that can be safely shared between tasks when aliased.
+///
+/// The precise definition is: a type `T` is `Sync` if `&T` is
+/// thread-safe. In other words, there is no possibility of data races
+/// when passing `&T` references between tasks.
+///
+/// As one would expect, primitive types like `u8` and `f64` are all
+/// `Sync`, and so are simple aggregate types containing them (like
+/// tuples, structs and enums). More instances of basic `Sync` types
+/// include "immutable" types like `&T` and those with simple
+/// inherited mutability, such as `Box<T>`, `Vec<T>` and most other
+/// collection types. (Generic parameters need to be `Sync` for their
+/// container to be `Sync`.)
+///
+/// A somewhat surprising consequence of the definition is `&mut T` is
+/// `Sync` (if `T` is `Sync`) even though it seems that it might
+/// provide unsynchronised mutation. The trick is a mutable reference
+/// stored in an aliasable reference (that is, `& &mut T`) becomes
+/// read-only, as if it were a `& &T`, hence there is no risk of a data
+/// race.
+///
+/// Types that are not `Sync` are those that have "interior
+/// mutability" in a non-thread-safe way, such as `Cell` and `RefCell`
+/// in `std::cell`. These types allow for mutation of their contents
+/// even when in an immutable, aliasable slot, e.g. the contents of
+/// `&Cell<T>` can be `.set`, and do not ensure data races are
+/// impossible, hence they cannot be `Sync`. A higher level example
+/// of a non-`Sync` type is the reference counted pointer
+/// `std::rc::Rc`, because any reference `&Rc<T>` can clone a new
+/// reference, which modifies the reference counts in a non-atomic
+/// way.
+///
+/// For cases when one does need thread-safe interior mutability,
+/// types like the atomics in `std::sync` and `Mutex` & `RWLock` in
+/// the `sync` crate do ensure that any mutation cannot cause data
+/// races.  Hence these types are `Sync`.
+///
+/// Users writing their own types with interior mutability (or anything
+/// else that is not thread-safe) should use the `NoSync` marker type
+/// (from `std::marker`) to ensure that the compiler doesn't
+/// consider the user-defined type to be `Sync`.  Any types with
+/// interior mutability must also use the `std::cell::UnsafeCell` wrapper
+/// around the value(s) which can be mutated when behind a `&`
+/// reference; not doing this is undefined behaviour (for example,
+/// `transmute`-ing from `&T` to `&mut T` is illegal).
+#[unstable = "will be overhauled with new lifetime rules; see RFC 458"]
+#[lang="sync"]
+pub unsafe trait Sync {
+    // Empty
+}
+
+
+/// A marker type whose type parameter `T` is considered to be
+/// covariant with respect to the type itself. This is (typically)
+/// used to indicate that an instance of the type `T` is being stored
+/// into memory and read from, even though that may not be apparent.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+///
+/// *Note:* It is very unusual to have to add a covariant constraint.
+/// If you are not sure, you probably want to use `InvariantType`.
+///
+/// # Example
+///
+/// Given a struct `S` that includes a type parameter `T`
+/// but does not actually *reference* that type parameter:
+///
+/// ```ignore
+/// use std::mem;
+///
+/// struct S<T> { x: *() }
+/// fn get<T>(s: &S<T>) -> T {
+///    unsafe {
+///        let x: *T = mem::transmute(s.x);
+///        *x
+///    }
+/// }
+/// ```
+///
+/// The type system would currently infer that the value of
+/// the type parameter `T` is irrelevant, and hence a `S<int>` is
+/// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
+/// any `U`). But this is incorrect because `get()` converts the
+/// `*()` into a `*T` and reads from it. Therefore, we should include the
+/// a marker field `CovariantType<T>` to inform the type checker that
+/// `S<T>` is a subtype of `S<U>` if `T` is a subtype of `U`
+/// (for example, `S<&'static int>` is a subtype of `S<&'a int>`
+/// for some lifetime `'a`, but not the other way around).
+#[unstable = "likely to change with new variance strategy"]
+#[lang="covariant_type"]
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+pub struct CovariantType<T: ?Sized>;
+
+impl<T: ?Sized> Copy for CovariantType<T> {}
+impl<T: ?Sized> Clone for CovariantType<T> {
+    fn clone(&self) -> CovariantType<T> { *self }
+}
+
+/// A marker type whose type parameter `T` is considered to be
+/// contravariant with respect to the type itself. This is (typically)
+/// used to indicate that an instance of the type `T` will be consumed
+/// (but not read from), even though that may not be apparent.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+///
+/// *Note:* It is very unusual to have to add a contravariant constraint.
+/// If you are not sure, you probably want to use `InvariantType`.
+///
+/// # Example
+///
+/// Given a struct `S` that includes a type parameter `T`
+/// but does not actually *reference* that type parameter:
+///
+/// ```
+/// use std::mem;
+///
+/// struct S<T> { x: *const () }
+/// fn get<T>(s: &S<T>, v: T) {
+///    unsafe {
+///        let x: fn(T) = mem::transmute(s.x);
+///        x(v)
+///    }
+/// }
+/// ```
+///
+/// The type system would currently infer that the value of
+/// the type parameter `T` is irrelevant, and hence a `S<int>` is
+/// a subtype of `S<Box<int>>` (or, for that matter, `S<U>` for
+/// any `U`). But this is incorrect because `get()` converts the
+/// `*()` into a `fn(T)` and then passes a value of type `T` to it.
+///
+/// Supplying a `ContravariantType` marker would correct the
+/// problem, because it would mark `S` so that `S<T>` is only a
+/// subtype of `S<U>` if `U` is a subtype of `T`; given that the
+/// function requires arguments of type `T`, it must also accept
+/// arguments of type `U`, hence such a conversion is safe.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="contravariant_type"]
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+pub struct ContravariantType<T: ?Sized>;
+
+impl<T: ?Sized> Copy for ContravariantType<T> {}
+impl<T: ?Sized> Clone for ContravariantType<T> {
+    fn clone(&self) -> ContravariantType<T> { *self }
+}
+
+/// A marker type whose type parameter `T` is considered to be
+/// invariant with respect to the type itself. This is (typically)
+/// used to indicate that instances of the type `T` may be read or
+/// written, even though that may not be apparent.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+///
+/// # Example
+///
+/// The Cell type is an example which uses unsafe code to achieve
+/// "interior" mutability:
+///
+/// ```
+/// pub struct Cell<T> { value: T }
+/// # fn main() {}
+/// ```
+///
+/// The type system would infer that `value` is only read here and
+/// never written, but in fact `Cell` uses unsafe code to achieve
+/// interior mutability.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="invariant_type"]
+#[derive(PartialEq, Eq, PartialOrd, Ord)]
+pub struct InvariantType<T: ?Sized>;
+
+#[unstable = "likely to change with new variance strategy"]
+impl<T: ?Sized> Copy for InvariantType<T> {}
+#[unstable = "likely to change with new variance strategy"]
+impl<T: ?Sized> Clone for InvariantType<T> {
+    fn clone(&self) -> InvariantType<T> { *self }
+}
+
+/// As `CovariantType`, but for lifetime parameters. Using
+/// `CovariantLifetime<'a>` indicates that it is ok to substitute
+/// a *longer* lifetime for `'a` than the one you originally
+/// started with (e.g., you could convert any lifetime `'foo` to
+/// `'static`). You almost certainly want `ContravariantLifetime`
+/// instead, or possibly `InvariantLifetime`. The only case where
+/// it would be appropriate is that you have a (type-casted, and
+/// hence hidden from the type system) function pointer with a
+/// signature like `fn(&'a T)` (and no other uses of `'a`). In
+/// this case, it is ok to substitute a larger lifetime for `'a`
+/// (e.g., `fn(&'static T)`), because the function is only
+/// becoming more selective in terms of what it accepts as
+/// argument.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="covariant_lifetime"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct CovariantLifetime<'a>;
+
+/// As `ContravariantType`, but for lifetime parameters. Using
+/// `ContravariantLifetime<'a>` indicates that it is ok to
+/// substitute a *shorter* lifetime for `'a` than the one you
+/// originally started with (e.g., you could convert `'static` to
+/// any lifetime `'foo`). This is appropriate for cases where you
+/// have an unsafe pointer that is actually a pointer into some
+/// memory with lifetime `'a`, and thus you want to limit the
+/// lifetime of your data structure to `'a`. An example of where
+/// this is used is the iterator for vectors.
+///
+/// For more information about variance, refer to this Wikipedia
+/// article <http://en.wikipedia.org/wiki/Variance_%28computer_science%29>.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="contravariant_lifetime"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct ContravariantLifetime<'a>;
+
+/// As `InvariantType`, but for lifetime parameters. Using
+/// `InvariantLifetime<'a>` indicates that it is not ok to
+/// substitute any other lifetime for `'a` besides its original
+/// value. This is appropriate for cases where you have an unsafe
+/// pointer that is actually a pointer into memory with lifetime `'a`,
+/// and this pointer is itself stored in an inherently mutable
+/// location (such as a `Cell`).
+#[unstable = "likely to change with new variance strategy"]
+#[lang="invariant_lifetime"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct InvariantLifetime<'a>;
+
+/// A type which is considered "not sendable", meaning that it cannot
+/// be safely sent between tasks, even if it is owned. This is
+/// typically embedded in other types, such as `Gc`, to ensure that
+/// their instances remain thread-local.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="no_send_bound"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct NoSend;
+
+/// A type which is considered "not POD", meaning that it is not
+/// implicitly copyable. This is typically embedded in other types to
+/// ensure that they are never copied, even if they lack a destructor.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="no_copy_bound"]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
+#[allow(missing_copy_implementations)]
+pub struct NoCopy;
+
+/// A type which is considered "not sync", meaning that
+/// its contents are not threadsafe, hence they cannot be
+/// shared between tasks.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="no_sync_bound"]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+pub struct NoSync;
+
+/// A type which is considered managed by the GC. This is typically
+/// embedded in other types.
+#[unstable = "likely to change with new variance strategy"]
+#[lang="managed_bound"]
+#[derive(Clone, PartialEq, Eq, PartialOrd, Ord)]
+#[allow(missing_copy_implementations)]
+pub struct Managed;
index c60569161213f68949bed4524688bc4978982d93..8438c9b206ee7132ac9331b94c7c6a127e746ffc 100644 (file)
@@ -15,7 +15,7 @@
 
 #![stable]
 
-use kinds::Sized;
+use marker::Sized;
 use intrinsics;
 use ptr;
 
index 192d6063f6bbc520b72256c601523b98230bcd59..490d8111f463ad3d14e319969734b5a21003c9b8 100644 (file)
 use cmp::{PartialOrd, Ord};
 use intrinsics;
 use iter::IteratorExt;
-use kinds::Copy;
+use marker::Copy;
 use mem::size_of;
 use ops::{Add, Sub, Mul, Div, Rem, Neg};
-use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr};
+use ops::{Not, BitAnd, BitOr, BitXor, Shl, Shr, Index};
 use option::Option;
 use option::Option::{Some, None};
 use str::{FromStr, StrExt};
@@ -992,7 +992,7 @@ fn to_f64(&self) -> Option<f64> { impl_to_primitive_float_to_float!($T, f64, *se
 
 /// A generic trait for converting a number to a value.
 #[experimental = "trait is likely to be removed"]
-pub trait FromPrimitive : ::kinds::Sized {
+pub trait FromPrimitive : ::marker::Sized {
     /// Convert an `int` to return an optional value of this type. If the
     /// value cannot be represented by this value, the `None` is returned.
     #[inline]
@@ -1577,7 +1577,7 @@ fn from_str_radix(src: &str, radix: uint) -> Option<$T> {
                         };
 
                         // Parse the exponent as decimal integer
-                        let src = src[offset..];
+                        let src = src.index(&(offset..));
                         let (is_positive, exp) = match src.slice_shift_char() {
                             Some(('-', src)) => (false, src.parse::<uint>()),
                             Some(('+', src)) => (true,  src.parse::<uint>()),
index 97d94e73bb33a0625764ba677ebdf97e49f8fe6f..4debab91739c1951765512e470095edd38b479be 100644 (file)
@@ -51,8 +51,8 @@
 //!     }
 //! }
 //! fn main() {
-//!     println!("{}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
-//!     println!("{}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
+//!     println!("{:?}", Point {x: 1, y: 0} + Point {x: 2, y: 3});
+//!     println!("{:?}", Point {x: 1, y: 0} - Point {x: 2, y: 3});
 //! }
 //! ```
 //!
@@ -63,7 +63,7 @@
 
 use clone::Clone;
 use iter::{Step, Iterator,DoubleEndedIterator,ExactSizeIterator};
-use kinds::Sized;
+use marker::Sized;
 use option::Option::{self, Some, None};
 
 /// The `Drop` trait is used to run some code when a value goes out of scope. This
@@ -846,105 +846,6 @@ pub trait IndexMut<Index: ?Sized> {
     fn index_mut<'a>(&'a mut self, index: &Index) -> &'a mut Self::Output;
 }
 
-/// The `Slice` trait is used to specify the functionality of slicing operations
-/// like `arr[from..to]` when used in an immutable context.
-///
-/// # Example
-///
-/// A trivial implementation of `Slice`. When `Foo[..Foo]` happens, it ends up
-/// calling `slice_to`, and therefore, `main` prints `Slicing!`.
-///
-/// ```ignore
-/// use std::ops::Slice;
-///
-/// #[derive(Copy)]
-/// struct Foo;
-///
-/// impl Slice<Foo, Foo> for Foo {
-///     fn as_slice_<'a>(&'a self) -> &'a Foo {
-///         println!("Slicing!");
-///         self
-///     }
-///     fn slice_from_or_fail<'a>(&'a self, _from: &Foo) -> &'a Foo {
-///         println!("Slicing!");
-///         self
-///     }
-///     fn slice_to_or_fail<'a>(&'a self, _to: &Foo) -> &'a Foo {
-///         println!("Slicing!");
-///         self
-///     }
-///     fn slice_or_fail<'a>(&'a self, _from: &Foo, _to: &Foo) -> &'a Foo {
-///         println!("Slicing!");
-///         self
-///     }
-/// }
-///
-/// fn main() {
-///     Foo[..Foo];
-/// }
-/// ```
-#[lang="slice"]
-pub trait Slice<Idx: ?Sized, Result: ?Sized> {
-    /// The method for the slicing operation foo[]
-    fn as_slice_<'a>(&'a self) -> &'a Result;
-    /// The method for the slicing operation foo[from..]
-    fn slice_from_or_fail<'a>(&'a self, from: &Idx) -> &'a Result;
-    /// The method for the slicing operation foo[..to]
-    fn slice_to_or_fail<'a>(&'a self, to: &Idx) -> &'a Result;
-    /// The method for the slicing operation foo[from..to]
-    fn slice_or_fail<'a>(&'a self, from: &Idx, to: &Idx) -> &'a Result;
-}
-
-/// The `SliceMut` trait is used to specify the functionality of slicing
-/// operations like `arr[from..to]`, when used in a mutable context.
-///
-/// # Example
-///
-/// A trivial implementation of `SliceMut`. When `Foo[Foo..]` happens, it ends up
-/// calling `slice_from_mut`, and therefore, `main` prints `Slicing!`.
-///
-/// ```ignore
-/// use std::ops::SliceMut;
-///
-/// #[derive(Copy)]
-/// struct Foo;
-///
-/// impl SliceMut<Foo, Foo> for Foo {
-///     fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo {
-///         println!("Slicing!");
-///         self
-///     }
-///     fn slice_from_or_fail_mut<'a>(&'a mut self, _from: &Foo) -> &'a mut Foo {
-///         println!("Slicing!");
-///         self
-///     }
-///     fn slice_to_or_fail_mut<'a>(&'a mut self, _to: &Foo) -> &'a mut Foo {
-///         println!("Slicing!");
-///         self
-///     }
-///     fn slice_or_fail_mut<'a>(&'a mut self, _from: &Foo, _to: &Foo) -> &'a mut Foo {
-///         println!("Slicing!");
-///         self
-///     }
-/// }
-///
-/// pub fn main() {
-///     Foo[mut Foo..];
-/// }
-/// ```
-#[lang="slice_mut"]
-pub trait SliceMut<Idx: ?Sized, Result: ?Sized> {
-    /// The method for the slicing operation foo[]
-    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Result;
-    /// The method for the slicing operation foo[from..]
-    fn slice_from_or_fail_mut<'a>(&'a mut self, from: &Idx) -> &'a mut Result;
-    /// The method for the slicing operation foo[..to]
-    fn slice_to_or_fail_mut<'a>(&'a mut self, to: &Idx) -> &'a mut Result;
-    /// The method for the slicing operation foo[from..to]
-    fn slice_or_fail_mut<'a>(&'a mut self, from: &Idx, to: &Idx) -> &'a mut Result;
-}
-
-
 /// An unbounded range.
 #[derive(Copy)]
 #[lang="full_range"]
@@ -962,8 +863,6 @@ pub struct Range<Idx> {
     pub end: Idx,
 }
 
-// FIXME(#19391) needs a snapshot
-//impl<Idx: Clone + Step<T=uint>> Iterator<Idx> for Range<Idx> {
 #[unstable = "API still in development"]
 impl<Idx: Clone + Step> Iterator for Range<Idx> {
     type Item = Idx;
@@ -1134,7 +1033,7 @@ fn deref(&self) -> &T { *self }
 pub trait DerefMut: Deref {
     /// The method called to mutably dereference a value
     #[stable]
-    fn deref_mut<'a>(&'a mut self) -> &'a mut <Self as Deref>::Target;
+    fn deref_mut<'a>(&'a mut self) -> &'a mut Self::Target;
 }
 
 #[stable]
index 39d0f024d4d4143f63c1419065d42481b8b5beb8..272570a0d5bb93e0e48256625bd4ed76400c88c4 100644 (file)
@@ -238,7 +238,7 @@ pub fn is_none(&self) -> bool {
     /// // First, cast `Option<String>` to `Option<&String>` with `as_ref`,
     /// // then consume *that* with `map`, leaving `num_as_str` on the stack.
     /// let num_as_int: Option<uint> = num_as_str.as_ref().map(|n| n.len());
-    /// println!("still can print num_as_str: {}", num_as_str);
+    /// println!("still can print num_as_str: {:?}", num_as_str);
     /// ```
     #[inline]
     #[stable]
index e88cb73c8a9b7f6f8d7b6f1a0a6c1207febc3f0d..c3bb9c91557f334da2485f25d9b896abecfc2ae7 100644 (file)
@@ -29,8 +29,8 @@
 //! ```
 
 // Reexported core operators
-pub use kinds::{Copy, Send, Sized, Sync};
-pub use ops::{Drop, Fn, FnMut, FnOnce};
+pub use marker::{Copy, Send, Sized, Sync};
+pub use ops::{Drop, Fn, FnMut, FnOnce, FullRange};
 
 // Reexported functions
 pub use iter::range;
index e8c92649634dc2d33008c241d5f6fe17abf880a7..20305c3191a098f24f73e1503f7e3a68595b4208 100644 (file)
@@ -92,7 +92,7 @@
 use clone::Clone;
 use intrinsics;
 use option::Option::{self, Some, None};
-use kinds::{Send, Sized, Sync};
+use marker::{Send, Sized, Sync};
 
 use cmp::{PartialEq, Eq, Ord, PartialOrd};
 use cmp::Ordering::{self, Less, Equal, Greater};
index 5ef6f6b2623aa7c97ff6ba49d443a313a8e3b9e8..1ad6d43f76f0919308996a5034f230e7929fc78e 100644 (file)
@@ -18,7 +18,7 @@
 //!
 //! Their definition should always match the ABI defined in `rustc::back::abi`.
 
-use kinds::Copy;
+use marker::Copy;
 use mem;
 
 /// The representation of a Rust slice
index 8e9bf5487e3ed1faa974a1a3e04a6d8944af98a3..95ae6ebfb68c30b9ad26a0cb1fd2b7fa5d75d588 100644 (file)
 //! let version = parse_version(&[1, 2, 3, 4]);
 //! match version {
 //!     Ok(v) => {
-//!         println!("working with version: {}", v);
+//!         println!("working with version: {:?}", v);
 //!     }
 //!     Err(e) => {
-//!         println!("error parsing header: {}", e);
+//!         println!("error parsing header: {:?}", e);
 //!     }
 //! }
 //! ```
@@ -743,7 +743,7 @@ pub fn unwrap(self) -> T {
         match self {
             Ok(t) => t,
             Err(e) =>
-                panic!("called `Result::unwrap()` on an `Err` value: {}", e)
+                panic!("called `Result::unwrap()` on an `Err` value: {:?}", e)
         }
     }
 }
@@ -773,7 +773,7 @@ impl<T: Show, E> Result<T, E> {
     pub fn unwrap_err(self) -> E {
         match self {
             Ok(t) =>
-                panic!("called `Result::unwrap_err()` on an `Ok` value: {}", t),
+                panic!("called `Result::unwrap_err()` on an `Ok` value: {:?}", t),
             Err(e) => e
         }
     }
index 66b29bab98c24326c96967b6b5c1c5cf448e3d4c..1f9aebb91beab0189faf4ed3a53d7a6ccc3447c4 100644 (file)
@@ -25,7 +25,7 @@
 //!     use std::simd::f32x4;
 //!     let a = f32x4(40.0, 41.0, 42.0, 43.0);
 //!     let b = f32x4(1.0, 1.1, 3.4, 9.8);
-//!     println!("{}", a + b);
+//!     println!("{:?}", a + b);
 //! }
 //! ```
 //!
index 093ed0b242f5f4d5583f839a7534ee8e697d9912..bf2df465370084df2bb62cbd87fbf4be80484e40 100644 (file)
@@ -41,9 +41,9 @@
 use cmp;
 use default::Default;
 use iter::*;
-use kinds::Copy;
+use marker::Copy;
 use num::Int;
-use ops::{FnMut, self};
+use ops::{FnMut, self, Index};
 use option::Option;
 use option::Option::{None, Some};
 use result::Result;
@@ -52,7 +52,7 @@
 use ptr::PtrExt;
 use mem;
 use mem::size_of;
-use kinds::{Sized, marker};
+use marker::{Sized, self};
 use raw::Repr;
 // Avoid conflicts with *both* the Slice trait (buggy) and the `slice::raw` module.
 use raw::Slice as RawSlice;
@@ -159,7 +159,7 @@ fn slice_to(&self, end: uint) -> &[T] {
 
     #[inline]
     fn split_at(&self, mid: uint) -> (&[T], &[T]) {
-        (self[..mid], self[mid..])
+        (self.index(&(0..mid)), self.index(&(mid..)))
     }
 
     #[inline]
@@ -236,11 +236,11 @@ fn first(&self) -> Option<&T> {
     }
 
     #[inline]
-    fn tail(&self) -> &[T] { self[1..] }
+    fn tail(&self) -> &[T] { self.index(&(1..)) }
 
     #[inline]
     fn init(&self) -> &[T] {
-        self[..self.len() - 1]
+        self.index(&(0..(self.len() - 1)))
     }
 
     #[inline]
@@ -292,17 +292,17 @@ fn get_mut(&mut self, index: uint) -> Option<&mut T> {
     fn as_mut_slice(&mut self) -> &mut [T] { self }
 
     fn slice_mut(&mut self, start: uint, end: uint) -> &mut [T] {
-        ops::SliceMut::slice_or_fail_mut(self, &start, &end)
+        ops::IndexMut::index_mut(self, &ops::Range { start: start, end: end } )
     }
 
     #[inline]
     fn slice_from_mut(&mut self, start: uint) -> &mut [T] {
-        ops::SliceMut::slice_from_or_fail_mut(self, &start)
+        ops::IndexMut::index_mut(self, &ops::RangeFrom { start: start } )
     }
 
     #[inline]
     fn slice_to_mut(&mut self, end: uint) -> &mut [T] {
-        ops::SliceMut::slice_to_or_fail_mut(self, &end)
+        ops::IndexMut::index_mut(self, &ops::RangeTo { end: end } )
     }
 
     #[inline]
@@ -310,8 +310,8 @@ fn split_at_mut(&mut self, mid: uint) -> (&mut [T], &mut [T]) {
         unsafe {
             let self2: &mut [T] = mem::transmute_copy(&self);
 
-            (ops::SliceMut::slice_to_or_fail_mut(self, &mid),
-             ops::SliceMut::slice_from_or_fail_mut(self2, &mid))
+            (ops::IndexMut::index_mut(self, &ops::RangeTo { end: mid } ),
+             ops::IndexMut::index_mut(self2, &ops::RangeFrom { start: mid } ))
         }
     }
 
@@ -443,13 +443,13 @@ fn contains(&self, x: &T) -> bool where T: PartialEq {
     #[inline]
     fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq {
         let n = needle.len();
-        self.len() >= n && needle == self[..n]
+        self.len() >= n && needle == self.index(&(0..n))
     }
 
     #[inline]
     fn ends_with(&self, needle: &[T]) -> bool where T: PartialEq {
         let (m, n) = (self.len(), needle.len());
-        m >= n && needle == self[m-n..]
+        m >= n && needle == self.index(&((m-n)..))
     }
 
     #[unstable]
@@ -551,62 +551,79 @@ fn index_mut(&mut self, &index: &uint) -> &mut T {
     }
 }
 
-impl<T> ops::Slice<uint, [T]> for [T] {
+impl<T> ops::Index<ops::Range<uint>> for [T] {
+    type Output = [T];
     #[inline]
-    fn as_slice_<'a>(&'a self) -> &'a [T] {
-        self
-    }
-
-    #[inline]
-    fn slice_from_or_fail<'a>(&'a self, start: &uint) -> &'a [T] {
-        self.slice_or_fail(start, &self.len())
-    }
-
-    #[inline]
-    fn slice_to_or_fail<'a>(&'a self, end: &uint) -> &'a [T] {
-        self.slice_or_fail(&0, end)
-    }
-    #[inline]
-    fn slice_or_fail<'a>(&'a self, start: &uint, end: &uint) -> &'a [T] {
-        assert!(*start <= *end);
-        assert!(*end <= self.len());
+    fn index(&self, index: &ops::Range<uint>) -> &[T] {
+        assert!(index.start <= index.end);
+        assert!(index.end <= self.len());
         unsafe {
             transmute(RawSlice {
-                    data: self.as_ptr().offset(*start as int),
-                    len: (*end - *start)
+                    data: self.as_ptr().offset(index.start as int),
+                    len: index.end - index.start
                 })
         }
     }
 }
-
-impl<T> ops::SliceMut<uint, [T]> for [T] {
+impl<T> ops::Index<ops::RangeTo<uint>> for [T] {
+    type Output = [T];
     #[inline]
-    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut [T] {
-        self
+    fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
+        self.index(&ops::Range{ start: 0, end: index.end })
     }
-
+}
+impl<T> ops::Index<ops::RangeFrom<uint>> for [T] {
+    type Output = [T];
     #[inline]
-    fn slice_from_or_fail_mut<'a>(&'a mut self, start: &uint) -> &'a mut [T] {
-        let len = &self.len();
-        self.slice_or_fail_mut(start, len)
+    fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
+        self.index(&ops::Range{ start: index.start, end: self.len() })
     }
-
+}
+impl<T> ops::Index<ops::FullRange> for [T] {
+    type Output = [T];
     #[inline]
-    fn slice_to_or_fail_mut<'a>(&'a mut self, end: &uint) -> &'a mut [T] {
-        self.slice_or_fail_mut(&0, end)
+    fn index(&self, _index: &ops::FullRange) -> &[T] {
+        self
     }
+}
+
+impl<T> ops::IndexMut<ops::Range<uint>> for [T] {
+    type Output = [T];
     #[inline]
-    fn slice_or_fail_mut<'a>(&'a mut self, start: &uint, end: &uint) -> &'a mut [T] {
-        assert!(*start <= *end);
-        assert!(*end <= self.len());
+    fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
+        assert!(index.start <= index.end);
+        assert!(index.end <= self.len());
         unsafe {
             transmute(RawSlice {
-                    data: self.as_ptr().offset(*start as int),
-                    len: (*end - *start)
+                    data: self.as_ptr().offset(index.start as int),
+                    len: index.end - index.start
                 })
         }
     }
 }
+impl<T> ops::IndexMut<ops::RangeTo<uint>> for [T] {
+    type Output = [T];
+    #[inline]
+    fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
+        self.index_mut(&ops::Range{ start: 0, end: index.end })
+    }
+}
+impl<T> ops::IndexMut<ops::RangeFrom<uint>> for [T] {
+    type Output = [T];
+    #[inline]
+    fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
+        let len = self.len();
+        self.index_mut(&ops::Range{ start: index.start, end: len })
+    }
+}
+impl<T> ops::IndexMut<ops::FullRange> for [T] {
+    type Output = [T];
+    #[inline]
+    fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
+        self
+    }
+}
+
 
 ////////////////////////////////////////////////////////////////////////////////
 // Common traits
@@ -716,7 +733,7 @@ fn next_back(&mut self) -> Option<$elem> {
 }
 
 macro_rules! make_slice {
-    ($t: ty -> $result: ty: $start: expr, $end: expr) => {{
+    ($t: ty => $result: ty: $start: expr, $end: expr) => {{
         let diff = $end as uint - $start as uint;
         let len = if mem::size_of::<T>() == 0 {
             diff
@@ -738,21 +755,38 @@ pub struct Iter<'a, T: 'a> {
 }
 
 #[experimental]
-impl<'a, T> ops::Slice<uint, [T]> for Iter<'a, T> {
-    fn as_slice_(&self) -> &[T] {
-        self.as_slice()
+impl<'a, T> ops::Index<ops::Range<uint>> for Iter<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, index: &ops::Range<uint>) -> &[T] {
+        self.as_slice().index(index)
     }
-    fn slice_from_or_fail<'b>(&'b self, from: &uint) -> &'b [T] {
-        use ops::Slice;
-        self.as_slice().slice_from_or_fail(from)
+}
+
+#[experimental]
+impl<'a, T> ops::Index<ops::RangeTo<uint>> for Iter<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
+        self.as_slice().index(index)
     }
-    fn slice_to_or_fail<'b>(&'b self, to: &uint) -> &'b [T] {
-        use ops::Slice;
-        self.as_slice().slice_to_or_fail(to)
+}
+
+#[experimental]
+impl<'a, T> ops::Index<ops::RangeFrom<uint>> for Iter<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
+        self.as_slice().index(index)
     }
-    fn slice_or_fail<'b>(&'b self, from: &uint, to: &uint) -> &'b [T] {
-        use ops::Slice;
-        self.as_slice().slice_or_fail(from, to)
+}
+
+#[experimental]
+impl<'a, T> ops::Index<ops::FullRange> for Iter<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, _index: &ops::FullRange) -> &[T] {
+        self.as_slice()
     }
 }
 
@@ -763,7 +797,7 @@ impl<'a, T> Iter<'a, T> {
     /// iterator can continue to be used while this exists.
     #[experimental]
     pub fn as_slice(&self) -> &'a [T] {
-        make_slice!(T -> &'a [T]: self.ptr, self.end)
+        make_slice!(T => &'a [T]: self.ptr, self.end)
     }
 }
 
@@ -812,44 +846,74 @@ pub struct IterMut<'a, T: 'a> {
     marker: marker::ContravariantLifetime<'a>,
 }
 
+
 #[experimental]
-impl<'a, T> ops::Slice<uint, [T]> for IterMut<'a, T> {
-    fn as_slice_<'b>(&'b self) -> &'b [T] {
-        make_slice!(T -> &'b [T]: self.ptr, self.end)
+impl<'a, T> ops::Index<ops::Range<uint>> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, index: &ops::Range<uint>) -> &[T] {
+        self.index(&ops::FullRange).index(index)
     }
-    fn slice_from_or_fail<'b>(&'b self, from: &uint) -> &'b [T] {
-        use ops::Slice;
-        self.as_slice_().slice_from_or_fail(from)
+}
+#[experimental]
+impl<'a, T> ops::Index<ops::RangeTo<uint>> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, index: &ops::RangeTo<uint>) -> &[T] {
+        self.index(&ops::FullRange).index(index)
     }
-    fn slice_to_or_fail<'b>(&'b self, to: &uint) -> &'b [T] {
-        use ops::Slice;
-        self.as_slice_().slice_to_or_fail(to)
+}
+#[experimental]
+impl<'a, T> ops::Index<ops::RangeFrom<uint>> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, index: &ops::RangeFrom<uint>) -> &[T] {
+        self.index(&ops::FullRange).index(index)
     }
-    fn slice_or_fail<'b>(&'b self, from: &uint, to: &uint) -> &'b [T] {
-        use ops::Slice;
-        self.as_slice_().slice_or_fail(from, to)
+}
+#[experimental]
+impl<'a, T> ops::Index<ops::FullRange> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index(&self, _index: &ops::FullRange) -> &[T] {
+        make_slice!(T => &[T]: self.ptr, self.end)
     }
 }
 
 #[experimental]
-impl<'a, T> ops::SliceMut<uint, [T]> for IterMut<'a, T> {
-    fn as_mut_slice_<'b>(&'b mut self) -> &'b mut [T] {
-        make_slice!(T -> &'b mut [T]: self.ptr, self.end)
+impl<'a, T> ops::IndexMut<ops::Range<uint>> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index_mut(&mut self, index: &ops::Range<uint>) -> &mut [T] {
+        self.index_mut(&ops::FullRange).index_mut(index)
     }
-    fn slice_from_or_fail_mut<'b>(&'b mut self, from: &uint) -> &'b mut [T] {
-        use ops::SliceMut;
-        self.as_mut_slice_().slice_from_or_fail_mut(from)
+}
+#[experimental]
+impl<'a, T> ops::IndexMut<ops::RangeTo<uint>> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index_mut(&mut self, index: &ops::RangeTo<uint>) -> &mut [T] {
+        self.index_mut(&ops::FullRange).index_mut(index)
     }
-    fn slice_to_or_fail_mut<'b>(&'b mut self, to: &uint) -> &'b mut [T] {
-        use ops::SliceMut;
-        self.as_mut_slice_().slice_to_or_fail_mut(to)
+}
+#[experimental]
+impl<'a, T> ops::IndexMut<ops::RangeFrom<uint>> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index_mut(&mut self, index: &ops::RangeFrom<uint>) -> &mut [T] {
+        self.index_mut(&ops::FullRange).index_mut(index)
     }
-    fn slice_or_fail_mut<'b>(&'b mut self, from: &uint, to: &uint) -> &'b mut [T] {
-        use ops::SliceMut;
-        self.as_mut_slice_().slice_or_fail_mut(from, to)
+}
+#[experimental]
+impl<'a, T> ops::IndexMut<ops::FullRange> for IterMut<'a, T> {
+    type Output = [T];
+    #[inline]
+    fn index_mut(&mut self, _index: &ops::FullRange) -> &mut [T] {
+        make_slice!(T => &mut [T]: self.ptr, self.end)
     }
 }
 
+
 impl<'a, T> IterMut<'a, T> {
     /// View the underlying data as a subslice of the original data.
     ///
@@ -859,7 +923,7 @@ impl<'a, T> IterMut<'a, T> {
     /// restricted lifetimes that do not consume the iterator.
     #[experimental]
     pub fn into_slice(self) -> &'a mut [T] {
-        make_slice!(T -> &'a mut [T]: self.ptr, self.end)
+        make_slice!(T => &'a mut [T]: self.ptr, self.end)
     }
 }
 
@@ -873,7 +937,7 @@ impl<'a, T> ExactSizeIterator for IterMut<'a, T> {}
 trait SplitIter: DoubleEndedIterator {
     /// Mark the underlying iterator as complete, extracting the remaining
     /// portion of the slice.
-    fn finish(&mut self) -> Option< <Self as Iterator>::Item>;
+    fn finish(&mut self) -> Option<Self::Item>;
 }
 
 /// An iterator over subslices separated by elements that match a predicate
@@ -908,8 +972,8 @@ fn next(&mut self) -> Option<&'a [T]> {
         match self.v.iter().position(|x| (self.pred)(x)) {
             None => self.finish(),
             Some(idx) => {
-                let ret = Some(self.v[..idx]);
-                self.v = self.v[idx + 1..];
+                let ret = Some(self.v.index(&(0..idx)));
+                self.v = self.v.index(&((idx + 1)..));
                 ret
             }
         }
@@ -934,8 +998,8 @@ fn next_back(&mut self) -> Option<&'a [T]> {
         match self.v.iter().rposition(|x| (self.pred)(x)) {
             None => self.finish(),
             Some(idx) => {
-                let ret = Some(self.v[idx + 1..]);
-                self.v = self.v[..idx];
+                let ret = Some(self.v.index(&((idx + 1)..)));
+                self.v = self.v.index(&(0..idx));
                 ret
             }
         }
@@ -1038,7 +1102,7 @@ struct GenericSplitN<I> {
     invert: bool
 }
 
-impl<T, I: SplitIter + Iterator<Item=T>> Iterator for GenericSplitN<I> {
+impl<T, I: SplitIter<Item=T>> Iterator for GenericSplitN<I> {
     type Item = T;
 
     #[inline]
@@ -1131,8 +1195,8 @@ fn next(&mut self) -> Option<&'a [T]> {
         if self.size > self.v.len() {
             None
         } else {
-            let ret = Some(self.v[..self.size]);
-            self.v = self.v[1..];
+            let ret = Some(self.v.index(&(0..self.size)));
+            self.v = self.v.index(&(1..));
             ret
         }
     }
@@ -1219,7 +1283,7 @@ fn idx(&mut self, index: uint) -> Option<&'a [T]> {
             let mut hi = lo + self.size;
             if hi < lo || hi > self.v.len() { hi = self.v.len(); }
 
-            Some(self.v[lo..hi])
+            Some(self.v.index(&(lo..hi)))
         } else {
             None
         }
index a39787b8207b5161c2fcbdb54c899d0829a93e11..3f8ce000e214cffde43574336ce829fde9e47ec7 100644 (file)
 use iter::range;
 use iter::ExactSizeIterator;
 use iter::{Map, Iterator, IteratorExt, DoubleEndedIterator};
-use kinds::Sized;
+use marker::Sized;
 use mem;
 use num::Int;
-use ops::{Fn, FnMut};
+use ops::{Fn, FnMut, Index};
 use option::Option::{self, None, Some};
 use ptr::PtrExt;
 use raw::{Repr, Slice};
@@ -35,9 +35,8 @@
 use uint;
 
 macro_rules! delegate_iter {
-    (exact $te:ty in $ti:ty) => {
-        delegate_iter!{$te in $ti}
-        #[stable]
+    (exact $te:ty : $ti:ty) => {
+        delegate_iter!{$te : $ti}
         impl<'a> ExactSizeIterator for $ti {
             #[inline]
             fn len(&self) -> uint {
@@ -45,7 +44,7 @@ fn len(&self) -> uint {
             }
         }
     };
-    ($te:ty in $ti:ty) => {
+    ($te:ty : $ti:ty) => {
         #[stable]
         impl<'a> Iterator for $ti {
             type Item = $te;
@@ -67,7 +66,7 @@ fn next_back(&mut self) -> Option<$te> {
             }
         }
     };
-    (pattern $te:ty in $ti:ty) => {
+    (pattern $te:ty : $ti:ty) => {
         #[stable]
         impl<'a, P: CharEq> Iterator for $ti {
             type Item = $te;
@@ -89,7 +88,7 @@ fn next_back(&mut self) -> Option<$te> {
             }
         }
     };
-    (pattern forward $te:ty in $ti:ty) => {
+    (pattern forward $te:ty : $ti:ty) => {
         #[stable]
         impl<'a, P: CharEq> Iterator for $ti {
             type Item = $te;
@@ -143,7 +142,7 @@ fn from_str(s: &str) -> Option<bool> {
 */
 
 /// Errors which can occur when attempting to interpret a byte slice as a `str`.
-#[derive(Copy, Eq, PartialEq, Clone)]
+#[derive(Copy, Eq, PartialEq, Clone, Show)]
 #[unstable = "error enumeration recently added and definitions may be refined"]
 pub enum Utf8Error {
     /// An invalid byte was detected at the byte offset given.
@@ -415,7 +414,7 @@ fn next_back(&mut self) -> Option<(uint, char)> {
 #[stable]
 #[derive(Clone)]
 pub struct Bytes<'a>(Map<&'a u8, u8, slice::Iter<'a, u8>, BytesDeref>);
-delegate_iter!{exact u8 in Bytes<'a>}
+delegate_iter!{exact u8 : Bytes<'a>}
 
 /// A temporary fn new type that ensures that the `Bytes` iterator
 /// is cloneable.
@@ -581,7 +580,7 @@ fn new() -> NaiveSearcher {
 
     fn next(&mut self, haystack: &[u8], needle: &[u8]) -> Option<(uint, uint)> {
         while self.position + needle.len() <= haystack.len() {
-            if haystack[self.position .. self.position + needle.len()] == needle {
+            if haystack.index(&(self.position .. self.position + needle.len())) == needle {
                 let match_pos = self.position;
                 self.position += needle.len(); // add 1 for all matches
                 return Some((match_pos, match_pos + needle.len()));
@@ -702,10 +701,10 @@ fn new(needle: &[u8]) -> TwoWaySearcher {
         //
         // What's going on is we have some critical factorization (u, v) of the
         // needle, and we want to determine whether u is a suffix of
-        // v[..period]. If it is, we use "Algorithm CP1". Otherwise we use
+        // v.index(&(0..period)). If it is, we use "Algorithm CP1". Otherwise we use
         // "Algorithm CP2", which is optimized for when the period of the needle
         // is large.
-        if needle[..crit_pos] == needle[period.. period + crit_pos] {
+        if needle.index(&(0..crit_pos)) == needle.index(&(period.. period + crit_pos)) {
             TwoWaySearcher {
                 crit_pos: crit_pos,
                 period: period,
@@ -1119,25 +1118,32 @@ fn partial_cmp(&self, other: &str) -> Option<Ordering> {
         }
     }
 
-    impl ops::Slice<uint, str> for str {
+    impl ops::Index<ops::Range<uint>> for str {
+        type Output = str;
         #[inline]
-        fn as_slice_<'a>(&'a self) -> &'a str {
-            self
+        fn index(&self, index: &ops::Range<uint>) -> &str {
+            self.slice(index.start, index.end)
         }
-
+    }
+    impl ops::Index<ops::RangeTo<uint>> for str {
+        type Output = str;
         #[inline]
-        fn slice_from_or_fail<'a>(&'a self, from: &uint) -> &'a str {
-            self.slice_from(*from)
+        fn index(&self, index: &ops::RangeTo<uint>) -> &str {
+            self.slice_to(index.end)
         }
-
+    }
+    impl ops::Index<ops::RangeFrom<uint>> for str {
+        type Output = str;
         #[inline]
-        fn slice_to_or_fail<'a>(&'a self, to: &uint) -> &'a str {
-            self.slice_to(*to)
+        fn index(&self, index: &ops::RangeFrom<uint>) -> &str {
+            self.slice_from(index.start)
         }
-
+    }
+    impl ops::Index<ops::FullRange> for str {
+        type Output = str;
         #[inline]
-        fn slice_or_fail<'a>(&'a self, from: &uint, to: &uint) -> &'a str {
-            self.slice(*from, *to)
+        fn index(&self, _index: &ops::FullRange) -> &str {
+            self
         }
     }
 }
@@ -1165,25 +1171,25 @@ fn as_slice(&self) -> &str { Str::as_slice(*self) }
 #[derive(Clone)]
 #[stable]
 pub struct Split<'a, P>(CharSplits<'a, P>);
-delegate_iter!{pattern &'a str in Split<'a, P>}
+delegate_iter!{pattern &'a str : Split<'a, P>}
 
 /// Return type of `StrExt::split_terminator`
 #[derive(Clone)]
 #[unstable = "might get removed in favour of a constructor method on Split"]
 pub struct SplitTerminator<'a, P>(CharSplits<'a, P>);
-delegate_iter!{pattern &'a str in SplitTerminator<'a, P>}
+delegate_iter!{pattern &'a str : SplitTerminator<'a, P>}
 
 /// Return type of `StrExt::splitn`
 #[derive(Clone)]
 #[stable]
 pub struct SplitN<'a, P>(CharSplitsN<'a, P>);
-delegate_iter!{pattern forward &'a str in SplitN<'a, P>}
+delegate_iter!{pattern forward &'a str : SplitN<'a, P>}
 
 /// Return type of `StrExt::rsplitn`
 #[derive(Clone)]
 #[stable]
 pub struct RSplitN<'a, P>(CharSplitsN<'a, P>);
-delegate_iter!{pattern forward &'a str in RSplitN<'a, P>}
+delegate_iter!{pattern forward &'a str : RSplitN<'a, P>}
 
 /// Methods for string slices
 #[allow(missing_docs)]
@@ -1406,13 +1412,13 @@ unsafe fn slice_unchecked(&self, begin: uint, end: uint) -> &str {
     #[inline]
     fn starts_with(&self, needle: &str) -> bool {
         let n = needle.len();
-        self.len() >= n && needle.as_bytes() == self.as_bytes()[..n]
+        self.len() >= n && needle.as_bytes() == self.as_bytes().index(&(0..n))
     }
 
     #[inline]
     fn ends_with(&self, needle: &str) -> bool {
         let (m, n) = (self.len(), needle.len());
-        m >= n && needle.as_bytes() == self.as_bytes()[m-n..]
+        m >= n && needle.as_bytes() == self.as_bytes().index(&((m-n)..))
     }
 
     #[inline]
index f8e03662b00eca4bc29dff6d320b777dd2fce3cf..35c1cb09281f41cc035500f52014afca66f60754 100644 (file)
@@ -10,4 +10,4 @@
 
 //! Types dealing with unsafe actions.
 
-use kinds::marker;
+use marker;
index 9b0471bfad9365b4d506e7d916679f72329df2a6..c0be3a287940a9bbbac8546b48f764fcfc2f479f 100644 (file)
@@ -56,12 +56,12 @@ fn any_downcast_ref() {
 
     match a.downcast_ref::<uint>() {
         Some(&5) => {}
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 
     match a.downcast_ref::<Test>() {
         None => {}
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 }
 
@@ -79,7 +79,7 @@ fn any_downcast_mut() {
             assert_eq!(*x, 5u);
             *x = 612;
         }
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 
     match b_r.downcast_mut::<uint>() {
@@ -87,27 +87,27 @@ fn any_downcast_mut() {
             assert_eq!(*x, 7u);
             *x = 413;
         }
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 
     match a_r.downcast_mut::<Test>() {
         None => (),
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 
     match b_r.downcast_mut::<Test>() {
         None => (),
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 
     match a_r.downcast_mut::<uint>() {
         Some(&612) => {}
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 
     match b_r.downcast_mut::<uint>() {
         Some(&413) => {}
-        x => panic!("Unexpected value {}", x)
+        x => panic!("Unexpected value {:?}", x)
     }
 }
 
index 54da6264bb0491e1f947250c7f723c2c73ebe557..86f34ecd15efeefdef43ac28f2712aaedbcc05e4 100644 (file)
@@ -29,10 +29,10 @@ fn smoketest_cell() {
 #[test]
 fn cell_has_sensible_show() {
     let x = Cell::new("foo bar");
-    assert!(format!("{}", x).contains(x.get()));
+    assert!(format!("{:?}", x).contains(x.get()));
 
     x.set("baz qux");
-    assert!(format!("{}", x).contains(x.get()));
+    assert!(format!("{:?}", x).contains(x.get()));
 }
 
 #[test]
@@ -40,11 +40,11 @@ fn ref_and_refmut_have_sensible_show() {
     let refcell = RefCell::new("foo");
 
     let refcell_refmut = refcell.borrow_mut();
-    assert!(format!("{}", refcell_refmut).contains("foo"));
+    assert!(format!("{:?}", refcell_refmut).contains("foo"));
     drop(refcell_refmut);
 
     let refcell_ref = refcell.borrow();
-    assert!(format!("{}", refcell_ref).contains("foo"));
+    assert!(format!("{:?}", refcell_ref).contains("foo"));
     drop(refcell_ref);
 }
 
index b581cdbd710934982effc6a83d0415376edce861..f901e8001767d5ce6644369d23a976383d33a33b 100644 (file)
@@ -167,7 +167,7 @@ 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);
-        assert_eq!(buf[..n], expect);
+        assert_eq!(buf.index(&(0..n)), expect);
     }
 
     check('x', &[0x78]);
@@ -181,7 +181,7 @@ 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);
-        assert_eq!(buf[..n], expect);
+        assert_eq!(buf.index(&(0..n)), expect);
     }
 
     check('x', &[0x0078]);
index 1e28933becd6ec6808011712ca09e77f76aac57d..c259e4cbb686d3da9e619ee9cd3bd6961b7658a8 100644 (file)
@@ -26,6 +26,11 @@ fn test_format_int() {
     assert!(format!("{}", -1i16) == "-1");
     assert!(format!("{}", -1i32) == "-1");
     assert!(format!("{}", -1i64) == "-1");
+    assert!(format!("{:?}", 1i) == "1i");
+    assert!(format!("{:?}", 1i8) == "1i8");
+    assert!(format!("{:?}", 1i16) == "1i16");
+    assert!(format!("{:?}", 1i32) == "1i32");
+    assert!(format!("{:?}", 1i64) == "1i64");
     assert!(format!("{:b}", 1i) == "1");
     assert!(format!("{:b}", 1i8) == "1");
     assert!(format!("{:b}", 1i16) == "1");
@@ -52,6 +57,11 @@ fn test_format_int() {
     assert!(format!("{}", 1u16) == "1");
     assert!(format!("{}", 1u32) == "1");
     assert!(format!("{}", 1u64) == "1");
+    assert!(format!("{:?}", 1u) == "1u");
+    assert!(format!("{:?}", 1u8) == "1u8");
+    assert!(format!("{:?}", 1u16) == "1u16");
+    assert!(format!("{:?}", 1u32) == "1u32");
+    assert!(format!("{:?}", 1u64) == "1u64");
     assert!(format!("{:b}", 1u) == "1");
     assert!(format!("{:b}", 1u8) == "1");
     assert!(format!("{:b}", 1u16) == "1");
@@ -84,12 +94,14 @@ fn test_format_int() {
 #[test]
 fn test_format_int_zero() {
     assert!(format!("{}", 0i) == "0");
+    assert!(format!("{:?}", 0i) == "0i");
     assert!(format!("{:b}", 0i) == "0");
     assert!(format!("{:o}", 0i) == "0");
     assert!(format!("{:x}", 0i) == "0");
     assert!(format!("{:X}", 0i) == "0");
 
     assert!(format!("{}", 0u) == "0");
+    assert!(format!("{:?}", 0u) == "0u");
     assert!(format!("{:b}", 0u) == "0");
     assert!(format!("{:o}", 0u) == "0");
     assert!(format!("{:x}", 0u) == "0");
@@ -183,6 +195,12 @@ fn format_hex(b: &mut Bencher) {
         b.iter(|| { format!("{:x}", rng.gen::<uint>()); })
     }
 
+    #[bench]
+    fn format_show(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:?}", rng.gen::<uint>()); })
+    }
+
     #[bench]
     fn format_base_36(b: &mut Bencher) {
         let mut rng = weak_rng();
@@ -219,6 +237,12 @@ fn format_hex(b: &mut Bencher) {
         b.iter(|| { format!("{:x}", rng.gen::<int>()); })
     }
 
+    #[bench]
+    fn format_show(b: &mut Bencher) {
+        let mut rng = weak_rng();
+        b.iter(|| { format!("{:?}", rng.gen::<int>()); })
+    }
+
     #[bench]
     fn format_base_36(b: &mut Bencher) {
         let mut rng = weak_rng();
index a4bafe754ffdd812c011fafbb03f6a02fb57494f..63bf9ec331454f368c7cb354888425a7aa53018f 100644 (file)
@@ -7,7 +7,7 @@
 // <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.
-use core::kinds::Sized;
+use core::marker::Sized;
 use std::mem;
 
 use core::slice::SliceExt;
index 73db72d0313e6af1d527305e5061b3d145d226e8..61266a926494458f62bfffdbac6b964cbcffac83 100644 (file)
@@ -14,7 +14,6 @@
 use core::num::SignedInt;
 use core::uint;
 use core::cmp;
-use core::ops::Slice;
 
 use test::Bencher;
 
@@ -230,7 +229,7 @@ fn test_inspect() {
                .collect::<Vec<uint>>();
 
     assert_eq!(n, xs.len());
-    assert_eq!(xs[], ys[]);
+    assert_eq!(&xs[], &ys[]);
 }
 
 #[test]
@@ -281,21 +280,21 @@ fn test_iterator_nth() {
 fn test_iterator_last() {
     let v: &[_] = &[0i, 1, 2, 3, 4];
     assert_eq!(v.iter().last().unwrap(), &4);
-    assert_eq!(v[0..1].iter().last().unwrap(), &0);
+    assert_eq!(v[..1].iter().last().unwrap(), &0);
 }
 
 #[test]
 fn test_iterator_len() {
     let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-    assert_eq!(v[0..4].iter().count(), 4);
-    assert_eq!(v[0..10].iter().count(), 10);
+    assert_eq!(v[..4].iter().count(), 4);
+    assert_eq!(v[..10].iter().count(), 10);
     assert_eq!(v[0..0].iter().count(), 0);
 }
 
 #[test]
 fn test_iterator_sum() {
     let v: &[_] = &[0i, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
-    assert_eq!(v[0..4].iter().map(|&x| x).sum(), 6);
+    assert_eq!(v[..4].iter().map(|&x| x).sum(), 6);
     assert_eq!(v.iter().map(|&x| x).sum(), 55);
     assert_eq!(v[0..0].iter().map(|&x| x).sum(), 0);
 }
@@ -374,7 +373,7 @@ fn test_all() {
     assert!(v.iter().all(|&x| x < 10));
     assert!(!v.iter().all(|&x| x % 2 == 0));
     assert!(!v.iter().all(|&x| x > 100));
-    assert!(v.slice_or_fail(&0, &0).iter().all(|_| panic!()));
+    assert!(v[0..0].iter().all(|_| panic!()));
 }
 
 #[test]
@@ -383,7 +382,7 @@ fn test_any() {
     assert!(v.iter().any(|&x| x < 10));
     assert!(v.iter().any(|&x| x % 2 == 0));
     assert!(!v.iter().any(|&x| x > 100));
-    assert!(!v.slice_or_fail(&0, &0).iter().any(|_| panic!()));
+    assert!(!v[0..0].iter().any(|_| panic!()));
 }
 
 #[test]
@@ -586,7 +585,7 @@ fn check_randacc_iter<A, T>(a: T, len: uint) where
 fn test_double_ended_flat_map() {
     let u = [0u,1];
     let v = [5u,6,7,8];
-    let mut it = u.iter().flat_map(|x| v[*x..v.len()].iter());
+    let mut it = u.iter().flat_map(|x| v[(*x)..v.len()].iter());
     assert_eq!(it.next_back().unwrap(), &8);
     assert_eq!(it.next().unwrap(),      &5);
     assert_eq!(it.next_back().unwrap(), &7);
index f86c85f821638f98813ab459ea8dab0293e00331..8186a4f0904afe8fe39d0eeee5066034c990e29b 100644 (file)
 use core::fmt::Show;
 use core::num::{NumCast, cast};
 use core::ops::{Add, Sub, Mul, Div, Rem};
-use core::kinds::Copy;
+use core::marker::Copy;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod int_macros;
 
 mod i8;
@@ -24,8 +23,7 @@
 mod i64;
 mod int;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod uint_macros;
 
 mod u8;
index 4a459992098a08b8a86dff85264e26614e760996..1169f910238022b2c7148e013d8ef10b96b20f98 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use core::option::*;
-use core::kinds::marker;
+use core::marker;
 use core::mem;
 use core::clone::Clone;
 
index 52ea14dd05dd922ec87611c3b4d26ca0109dcd3b..b9403598ec2b2d3b8f0ab8d2b5b5bd5545a76c39 100644 (file)
@@ -95,10 +95,10 @@ pub fn test_fmt_default() {
     let ok: Result<int, &'static str> = Ok(100);
     let err: Result<int, &'static str> = Err("Err");
 
-    let s = format!("{}", ok);
-    assert_eq!(s, "Ok(100)");
-    let s = format!("{}", err);
-    assert_eq!(s, "Err(Err)");
+    let s = format!("{:?}", ok);
+    assert_eq!(s, "Ok(100i)");
+    let s = format!("{:?}", err);
+    assert_eq!(s, "Err(\"Err\")");
 }
 
 #[test]
index 9ef7d6030593a008f24a6d22fb1477afcdcd5ead..b714b6a4e417dfb1bdfde88a2741fb6d122177d9 100644 (file)
@@ -43,35 +43,35 @@ macro_rules! test {
 
             {
                 let mut iter = data.iter();
-                assert_eq!(iter[], other_data[]);
+                assert_eq!(&iter[], &other_data[]);
 
                 iter.next();
-                assert_eq!(iter[], other_data[1..]);
+                assert_eq!(&iter[], &other_data[1..]);
 
                 iter.next_back();
-                assert_eq!(iter[], other_data[1..2]);
+                assert_eq!(&iter[], &other_data[1..2]);
 
                 let s = iter.as_slice();
                 iter.next();
-                assert_eq!(s, other_data[1..2]);
+                assert_eq!(s, &other_data[1..2]);
             }
             {
                 let mut iter = data.iter_mut();
-                assert_eq!(iter[], other_data[]);
+                assert_eq!(iter.index(&FullRange), other_data.index(&FullRange));
                 // mutability:
-                assert!(iter[mut] == other_data);
+                assert!(&mut iter[] == other_data);
 
                 iter.next();
-                assert_eq!(iter[], other_data[1..]);
-                assert!(iter[mut] == other_data[mut 1..]);
+                assert_eq!(iter.index(&FullRange), other_data.index(&(1..)));
+                assert!(&mut iter[] == &mut other_data[1..]);
 
                 iter.next_back();
 
-                assert_eq!(iter[], other_data[1..2]);
-                assert!(iter[mut] == other_data[mut 1..2]);
+                assert_eq!(iter.index(&FullRange), other_data.index(&(1..2)));
+                assert!(&mut iter[] == &mut other_data[1..2]);
 
                 let s = iter.into_slice();
-                assert!(s == other_data[mut 1..2]);
+                assert!(s == &mut other_data[1..2]);
             }
         }}
     }
index c3bc38a6614b8ce270ccd214cfddb212d0581151..62eb9f4ad3480c9df71a12feb97692c735297072 100644 (file)
@@ -59,10 +59,10 @@ fn test_tuple_cmp() {
 
 #[test]
 fn test_show() {
-    let s = format!("{}", (1i,));
-    assert_eq!(s, "(1,)");
-    let s = format!("{}", (1i, true));
-    assert_eq!(s, "(1, true)");
-    let s = format!("{}", (1i, "hi", true));
-    assert_eq!(s, "(1, hi, true)");
+    let s = format!("{:?}", (1i,));
+    assert_eq!(s, "(1i,)");
+    let s = format!("{:?}", (1i, true));
+    assert_eq!(s, "(1i, true)");
+    let s = format!("{:?}", (1i, "hi", true));
+    assert_eq!(s, "(1i, \"hi\", true)");
 }
index 6ac311fe4b646ae2f5d9a8ae5642a8b5f0fd6e11..f38440d86c6e855a4f171443d9397469adb9d1b3 100644 (file)
@@ -21,7 +21,6 @@
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
-#![feature(unboxed_closures, associated_types)]
 
 #[cfg(test)] #[macro_use] extern crate log;
 
index 917c6e99992f24c2aa084a23d03352b695516cb4..47cc072a636a147fe81e5b69b537bd28da6cca21 100644 (file)
@@ -23,8 +23,7 @@
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
 
-#![feature(globs, slicing_syntax)]
-#![feature(associated_types)]
+#![feature(slicing_syntax)]
 
 pub use self::Piece::*;
 pub use self::Position::*;
@@ -212,11 +211,12 @@ fn must_consume(&mut self, c: char) {
                 self.cur.next();
             }
             Some((_, other)) => {
-                self.err(format!("expected `{}`, found `{}`", c, other)[]);
+                self.err(format!("expected `{:?}`, found `{:?}`", c,
+                                 other).index(&FullRange));
             }
             None => {
-                self.err(format!("expected `{}` but string was terminated",
-                                 c)[]);
+                self.err(format!("expected `{:?}` but string was terminated",
+                                 c).index(&FullRange));
             }
         }
     }
@@ -239,12 +239,12 @@ fn string(&mut self, start: uint) -> &'a str {
             // we may not consume the character, so clone the iterator
             match self.cur.clone().next() {
                 Some((pos, '}')) | Some((pos, '{')) => {
-                    return self.input[start..pos];
+                    return self.input.index(&(start..pos));
                 }
                 Some(..) => { self.cur.next(); }
                 None => {
                     self.cur.next();
-                    return self.input[start..self.input.len()];
+                    return self.input.index(&(start..self.input.len()));
                 }
             }
         }
@@ -284,7 +284,7 @@ fn format(&mut self) -> FormatSpec<'a> {
             flags: 0,
             precision: CountImplied,
             width: CountImplied,
-            ty: self.input[0..0],
+            ty: self.input.index(&(0..0)),
         };
         if !self.consume(':') { return spec }
 
@@ -393,7 +393,7 @@ fn word(&mut self) -> &'a str {
                 self.cur.next();
                 pos
             }
-            Some(..) | None => { return self.input[0..0]; }
+            Some(..) | None => { return self.input.index(&(0..0)); }
         };
         let mut end;
         loop {
@@ -405,7 +405,7 @@ fn word(&mut self) -> &'a str {
                 None => { end = self.input.len(); break }
             }
         }
-        self.input[start..end]
+        self.input.index(&(start..end))
     }
 
     /// Optionally parses an integer at the current position. This doesn't deal
index 18077795e245f16dda711c3bc2c62a0373e86d83..f50e24c6354f184ea6a344be5abe6361c8125482 100644 (file)
@@ -85,8 +85,7 @@
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
-#![feature(globs, slicing_syntax)]
-#![feature(unboxed_closures)]
+#![feature(slicing_syntax)]
 #![deny(missing_docs)]
 
 #[cfg(test)] #[macro_use] extern crate log;
 use std::result;
 
 /// Name of an option. Either a string or a single char.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Show)]
 pub enum Name {
     /// A string representing the long name of an option.
     /// For example: "help"
@@ -116,7 +115,7 @@ pub enum Name {
 }
 
 /// Describes whether an option has an argument.
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Clone, Copy, PartialEq, Eq, Show)]
 pub enum HasArg {
     /// The option requires an argument.
     Yes,
@@ -127,7 +126,7 @@ pub enum HasArg {
 }
 
 /// Describes how often an option may occur.
-#[derive(Clone, Copy, PartialEq, Eq)]
+#[derive(Clone, Copy, PartialEq, Eq, Show)]
 pub enum Occur {
     /// The option occurs once.
     Req,
@@ -138,7 +137,7 @@ pub enum Occur {
 }
 
 /// A description of a possible option.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Show)]
 pub struct Opt {
     /// Name of the option
     pub name: Name,
@@ -152,7 +151,7 @@ pub struct Opt {
 
 /// One group of options, e.g., both `-h` and `--help`, along with
 /// their shared description and properties.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Show)]
 pub struct OptGroup {
     /// Short name of the option, e.g. `h` for a `-h` option
     pub short_name: String,
@@ -169,7 +168,7 @@ pub struct OptGroup {
 }
 
 /// Describes whether an option is given at all or has a value.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Show)]
 enum Optval {
     Val(String),
     Given,
@@ -177,7 +176,7 @@ enum Optval {
 
 /// The result of checking command line arguments. Contains a vector
 /// of matches and a vector of free strings.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Show)]
 pub struct Matches {
     /// Options that matched
     opts: Vec<Opt>,
@@ -190,7 +189,7 @@ pub struct Matches {
 /// The type returned when the command line does not conform to the
 /// expected format. Use the `Show` implementation to output detailed
 /// information.
-#[derive(Clone, PartialEq, Eq)]
+#[derive(Clone, PartialEq, Eq, Show)]
 pub enum Fail {
     /// The option requires an argument but none was passed.
     ArgumentMissing(String),
@@ -205,7 +204,7 @@ pub enum Fail {
 }
 
 /// The type of failure that occurred.
-#[derive(Copy, PartialEq, Eq)]
+#[derive(Copy, PartialEq, Eq, Show)]
 #[allow(missing_docs)]
 pub enum FailType {
     ArgumentMissing_,
@@ -281,7 +280,7 @@ pub fn long_to_short(&self) -> Opt {
 
 impl Matches {
     fn opt_vals(&self, nm: &str) -> Vec<Optval> {
-        match find_opt(self.opts[], Name::from_str(nm)) {
+        match find_opt(self.opts.index(&FullRange), Name::from_str(nm)) {
             Some(id) => self.vals[id].clone(),
             None => panic!("No option '{}' defined", nm)
         }
@@ -309,7 +308,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.iter() {
-            match find_opt(self.opts.as_slice(), Name::from_str(nm[])) {
+            match find_opt(self.opts.as_slice(), Name::from_str(nm.index(&FullRange))) {
                 Some(id) if !self.vals[id].is_empty() => return true,
                 _ => (),
             };
@@ -320,7 +319,7 @@ pub fn opts_present(&self, names: &[String]) -> bool {
     /// Returns the string argument supplied to one of several matching options or `None`.
     pub fn opts_str(&self, names: &[String]) -> Option<String> {
         for nm in names.iter() {
-            match self.opt_val(nm[]) {
+            match self.opt_val(nm.index(&FullRange)) {
                 Some(Val(ref s)) => return Some(s.clone()),
                 _ => ()
             }
@@ -536,13 +535,13 @@ pub fn opt(short_name: &str,
 
 impl Fail {
     /// Convert a `Fail` enum into an error string.
-    #[deprecated="use `Show` (`{}` format specifier)"]
+    #[deprecated="use `fmt::String` (`{}` format specifier)"]
     pub fn to_err_msg(self) -> String {
         self.to_string()
     }
 }
 
-impl fmt::Show for Fail {
+impl fmt::String for Fail {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             ArgumentMissing(ref nm) => {
@@ -585,7 +584,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
     while i < l {
         let cur = args[i].clone();
         let curlen = cur.len();
-        if !is_arg(cur[]) {
+        if !is_arg(cur.index(&FullRange)) {
             free.push(cur);
         } else if cur == "--" {
             let mut j = i + 1;
@@ -595,7 +594,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
             let mut names;
             let mut i_arg = None;
             if cur.as_bytes()[1] == b'-' {
-                let tail = cur[2..curlen];
+                let tail = cur.index(&(2..curlen));
                 let tail_eq: Vec<&str> = tail.split('=').collect();
                 if tail_eq.len() <= 1 {
                     names = vec!(Long(tail.to_string()));
@@ -631,7 +630,7 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
                     };
 
                     if arg_follows && range.next < curlen {
-                        i_arg = Some(cur[range.next..curlen].to_string());
+                        i_arg = Some(cur.index(&(range.next..curlen)).to_string());
                         break;
                     }
 
@@ -650,29 +649,34 @@ pub fn getopts(args: &[String], optgrps: &[OptGroup]) -> Result {
                     if name_pos == names.len() && !i_arg.is_none() {
                         return Err(UnexpectedArgument(nm.to_string()));
                     }
-                    vals[optid].push(Given);
+                    let v = &mut vals[optid];
+                    v.push(Given);
                   }
                   Maybe => {
                     if !i_arg.is_none() {
-                        vals[optid]
-                            .push(Val((i_arg.clone())
+                        let v = &mut vals[optid];
+                        v.push(Val((i_arg.clone())
                             .unwrap()));
                     } else if name_pos < names.len() || i + 1 == l ||
-                            is_arg(args[i + 1][]) {
-                        vals[optid].push(Given);
+                            is_arg(args[i + 1].index(&FullRange)) {
+                        let v = &mut vals[optid];
+                        v.push(Given);
                     } else {
                         i += 1;
-                        vals[optid].push(Val(args[i].clone()));
+                        let v = &mut vals[optid];
+                        v.push(Val(args[i].clone()));
                     }
                   }
                   Yes => {
                     if !i_arg.is_none() {
-                        vals[optid].push(Val(i_arg.clone().unwrap()));
+                        let v = &mut vals[optid];
+                        v.push(Val(i_arg.clone().unwrap()));
                     } else if i + 1 == l {
                         return Err(ArgumentMissing(nm.to_string()));
                     } else {
                         i += 1;
-                        vals[optid].push(Val(args[i].clone()));
+                        let v = &mut vals[optid];
+                        v.push(Val(args[i].clone()));
                     }
                   }
                 }
@@ -717,7 +721,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
             0 => {}
             1 => {
                 row.push('-');
-                row.push_str(short_name[]);
+                row.push_str(short_name.index(&FullRange));
                 row.push(' ');
             }
             _ => panic!("the short name should only be 1 ascii char long"),
@@ -728,7 +732,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
             0 => {}
             _ => {
                 row.push_str("--");
-                row.push_str(long_name[]);
+                row.push_str(long_name.index(&FullRange));
                 row.push(' ');
             }
         }
@@ -736,10 +740,10 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
         // arg
         match hasarg {
             No => {}
-            Yes => row.push_str(hint[]),
+            Yes => row.push_str(hint.index(&FullRange)),
             Maybe => {
                 row.push('[');
-                row.push_str(hint[]);
+                row.push_str(hint.index(&FullRange));
                 row.push(']');
             }
         }
@@ -752,7 +756,7 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
                 row.push(' ');
             }
         } else {
-            row.push_str(desc_sep[]);
+            row.push_str(desc_sep.index(&FullRange));
         }
 
         // Normalize desc to contain words separated by one space character
@@ -764,14 +768,14 @@ pub fn usage(brief: &str, opts: &[OptGroup]) -> String {
 
         // FIXME: #5516 should be graphemes not codepoints
         let mut desc_rows = Vec::new();
-        each_split_within(desc_normalized_whitespace[], 54, |substr| {
+        each_split_within(desc_normalized_whitespace.index(&FullRange), 54, |substr| {
             desc_rows.push(substr.to_string());
             true
         });
 
         // FIXME: #5516 should be graphemes not codepoints
         // wrapped description
-        row.push_str(desc_rows.connect(desc_sep[])[]);
+        row.push_str(desc_rows.connect(desc_sep.index(&FullRange)).index(&FullRange));
 
         row
     });
@@ -790,10 +794,10 @@ fn format_option(opt: &OptGroup) -> String {
     // Use short_name is possible, but fallback to long_name.
     if opt.short_name.len() > 0 {
         line.push('-');
-        line.push_str(opt.short_name[]);
+        line.push_str(opt.short_name.index(&FullRange));
     } else {
         line.push_str("--");
-        line.push_str(opt.long_name[]);
+        line.push_str(opt.long_name.index(&FullRange));
     }
 
     if opt.hasarg != No {
@@ -801,7 +805,7 @@ fn format_option(opt: &OptGroup) -> String {
         if opt.hasarg == Maybe {
             line.push('[');
         }
-        line.push_str(opt.hint[]);
+        line.push_str(opt.hint.index(&FullRange));
         if opt.hasarg == Maybe {
             line.push(']');
         }
@@ -823,7 +827,7 @@ pub fn short_usage(program_name: &str, opts: &[OptGroup]) -> String {
     line.push_str(opts.iter()
                       .map(format_option)
                       .collect::<Vec<String>>()
-                      .connect(" ")[]);
+                      .connect(" ").index(&FullRange));
     line
 }
 
@@ -886,9 +890,9 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
             (B, Cr, UnderLim) => { B }
             (B, Cr, OverLim)  if (i - last_start + 1) > lim
                             => panic!("word starting with {} longer than limit!",
-                                    ss[last_start..i + 1]),
+                                    ss.index(&(last_start..(i + 1)))),
             (B, Cr, OverLim)  => {
-                *cont = it(ss[slice_start..last_end]);
+                *cont = it(ss.index(&(slice_start..last_end)));
                 slice_start = last_start;
                 B
             }
@@ -898,7 +902,7 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
             }
             (B, Ws, OverLim)  => {
                 last_end = i;
-                *cont = it(ss[slice_start..last_end]);
+                *cont = it(ss.index(&(slice_start..last_end)));
                 A
             }
 
@@ -907,14 +911,14 @@ fn each_split_within<F>(ss: &str, lim: uint, mut it: F) -> bool where
                 B
             }
             (C, Cr, OverLim)  => {
-                *cont = it(ss[slice_start..last_end]);
+                *cont = it(ss.index(&(slice_start..last_end)));
                 slice_start = i;
                 last_start = i;
                 last_end = i;
                 B
             }
             (C, Ws, OverLim)  => {
-                *cont = it(ss[slice_start..last_end]);
+                *cont = it(ss.index(&(slice_start..last_end)));
                 A
             }
             (C, Ws, UnderLim) => {
index 64cc490f4b163e7d7c1d841b3f85a69087c0f8f4..83bad70e7b117b05f67ff3a4157e2d21279713be 100644 (file)
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
-#![feature(globs, slicing_syntax)]
-#![feature(unboxed_closures)]
+#![feature(slicing_syntax)]
 
 use self::LabelText::*;
 
@@ -453,7 +452,7 @@ fn escape_str(s: &str) -> String {
     pub fn escape(&self) -> String {
         match self {
             &LabelStr(ref s) => s.escape_default(),
-            &EscStr(ref s) => LabelText::escape_str(s[]),
+            &EscStr(ref s) => LabelText::escape_str(s.index(&FullRange)),
         }
     }
 
@@ -482,7 +481,7 @@ pub fn suffix_line(self, suffix: LabelText) -> LabelText<'static> {
         let mut prefix = self.pre_escaped_content().into_owned();
         let suffix = suffix.pre_escaped_content();
         prefix.push_str(r"\n\n");
-        prefix.push_str(suffix[]);
+        prefix.push_str(suffix.index(&FullRange));
         EscStr(prefix.into_cow())
     }
 }
@@ -676,7 +675,7 @@ fn id_name<'a>(n: &Node) -> Id<'a> {
 
     impl<'a> Labeller<'a, Node, &'a Edge> for LabelledGraph {
         fn graph_id(&'a self) -> Id<'a> {
-            Id::new(self.name[]).unwrap()
+            Id::new(self.name.index(&FullRange)).unwrap()
         }
         fn node_id(&'a self, n: &Node) -> Id<'a> {
             id_name(n)
index e3f02146a75f437bbd8ef411106ca509c52f07be..347a958076dff36706f82b14ddd57a45c0e74346 100644 (file)
@@ -8,12 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-#![feature(globs)]
 #![crate_name = "libc"]
-#![experimental]
-#![no_std] // we don't need std, and we can't have std, since it doesn't exist
-           // yet. std depends on us.
 #![crate_type = "rlib"]
+#![cfg_attr(not(feature = "cargo-build"), experimental)]
+#![no_std]
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/",
 //! in multiple derived systems. This is the 4.4BSD r2 / 1995 release, the final
 //! one from Berkeley after the lawsuits died down and the CSRG dissolved.
 
-#![allow(non_camel_case_types)]
-#![allow(non_snake_case)]
-#![allow(non_upper_case_globals)]
-#![allow(missing_docs)]
-#![allow(non_snake_case)]
-#![allow(raw_pointer_deriving)]
+#![allow(bad_style, raw_pointer_derive)]
 
-extern crate core;
+#[cfg(feature = "cargo-build")] extern crate "std" as core;
+#[cfg(not(feature = "cargo-build"))] extern crate core;
 
 #[cfg(test)] extern crate std;
 #[cfg(test)] extern crate test;
 
-pub use self::Nullable::*;
-
 // Explicit export lists for the intersection (provided here) mean that
 // you can write more-platform-agnostic code if you stick to just these
 // symbols.
 #[link(name = "m")]
 extern {}
 
-/// A wrapper for a nullable pointer. Don't use this except for interacting
-/// with libc. Basically Option, but without the dependence on libstd.
-// If/when libprim happens, this can be removed in favor of that
-pub enum Nullable<T> {
-    Null,
-    NotNull(T)
-}
-
 pub mod types {
 
     // Types tend to vary *per architecture* so we pull their definitions out
@@ -4649,7 +4633,7 @@ pub mod glob {
             extern {
                 pub fn glob(pattern: *const c_char,
                             flags: c_int,
-                            errfunc: ::Nullable<extern "C" fn(epath: *const c_char,
+                            errfunc: ::core::option::Option<extern "C" fn(epath: *const c_char,
                                                               errno: c_int) -> c_int>,
                             pglob: *mut glob_t);
                 pub fn globfree(pglob: *mut glob_t);
@@ -5081,5 +5065,7 @@ pub fn issue_14344_workaround() {} // FIXME #14344 force linkage to happen corre
 #[doc(hidden)]
 #[cfg(not(test))]
 mod std {
-    pub use core::kinds;
+    #[cfg(stage0)]
+    pub use core::marker as kinds;
+    pub use core::marker;
 }
index 8134503019c99ad9362232e9a47e892bb084a5c2..d741019aa7b9c3804e9e0ee27d12dcd5f208fabb 100644 (file)
@@ -84,7 +84,7 @@ pub fn parse_logging_spec(spec: &str) -> (Vec<LogDirective>, Option<Regex>) {
         match Regex::new(filter) {
             Ok(re) => Some(re),
             Err(e) => {
-                println!("warning: invalid regex filter - {}", e);
+                println!("warning: invalid regex filter - {:?}", e);
                 None
             }
         }
index df85e89efd17c5a805f46094b1766e0ba76be7e7..08b01e956e1ac83c073524226f8ca2ef5200d41d 100644 (file)
 //! #[macro_use] extern crate log;
 //!
 //! fn main() {
-//!     debug!("this is a debug {}", "message");
+//!     debug!("this is a debug {:?}", "message");
 //!     error!("this is printed by default");
 //!
 //!     if log_enabled!(log::INFO) {
 //!         let x = 3i * 4i; // expensive computation
-//!         info!("the answer was: {}", x);
+//!         info!("the answer was: {:?}", x);
 //!     }
 //! }
 //! ```
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
-#![feature(macro_rules, unboxed_closures, slicing_syntax)]
+#![feature(slicing_syntax)]
 #![deny(missing_docs)]
 
 extern crate regex;
 
 use directive::LOG_LEVEL_NAMES;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod macros;
 
 mod directive;
@@ -238,11 +237,17 @@ struct DefaultLogger {
 pub struct LogLevel(pub u32);
 
 impl fmt::Show for LogLevel {
+    fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, fmt)
+    }
+}
+
+impl fmt::String for LogLevel {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let LogLevel(level) = *self;
         match LOG_LEVEL_NAMES.get(level as uint - 1) {
-            Some(name) => name.fmt(fmt),
-            None => level.fmt(fmt)
+            Some(ref name) => fmt::String::fmt(name, fmt),
+            None => fmt::String::fmt(&level, fmt)
         }
     }
 }
@@ -254,7 +259,7 @@ fn log(&mut self, record: &LogRecord) {
                        record.level,
                        record.module_path,
                        record.args) {
-            Err(e) => panic!("failed to log: {}", e),
+            Err(e) => panic!("failed to log: {:?}", e),
             Ok(()) => {}
         }
     }
@@ -264,7 +269,7 @@ impl Drop for DefaultLogger {
     fn drop(&mut self) {
         // FIXME(#12628): is panicking the right thing to do?
         match self.handle.flush() {
-            Err(e) => panic!("failed to flush a logger: {}", e),
+            Err(e) => panic!("failed to flush a logger: {:?}", e),
             Ok(()) => {}
         }
     }
@@ -282,7 +287,7 @@ pub fn log(level: u32, loc: &'static LogLocation, args: fmt::Arguments) {
     // Test the literal string from args against the current filter, if there
     // is one.
     match unsafe { FILTER.as_ref() } {
-        Some(filter) if !filter.is_match(args.to_string()[]) => return,
+        Some(filter) if !filter.is_match(args.to_string().index(&FullRange)) => return,
         _ => {}
     }
 
@@ -377,7 +382,7 @@ fn enabled(level: u32,
     // Search for the longest match, the vector is assumed to be pre-sorted.
     for directive in iter.rev() {
         match directive.name {
-            Some(ref name) if !module.starts_with(name[]) => {},
+            Some(ref name) if !module.starts_with(name.index(&FullRange)) => {},
             Some(..) | None => {
                 return level <= directive.level
             }
@@ -392,7 +397,7 @@ fn enabled(level: u32,
 /// `Once` primitive (and this function is called from that primitive).
 fn init() {
     let (mut directives, filter) = match os::getenv("RUST_LOG") {
-        Some(spec) => directive::parse_logging_spec(spec[]),
+        Some(spec) => directive::parse_logging_spec(spec.index(&FullRange)),
         None => (Vec::new(), None),
     };
 
index 1038009522d67313af1e85c46f03d166a2f9222e..1002d9693ba691e3778abe1a1c0cf068f4cc9ac0 100644 (file)
@@ -12,7 +12,7 @@
 
 // this is surprisingly complicated to be both generic & correct
 
-use core::prelude::*;
+use core::prelude::{PartialOrd};
 use core::num::Int;
 
 use Rng;
@@ -166,7 +166,7 @@ mod tests {
     use std::num::Int;
     use std::prelude::v1::*;
     use distributions::{Sample, IndependentSample};
-    use super::Range;
+    use super::Range as Range;
 
     #[should_fail]
     #[test]
index c4dd08f9917e2dcbc95349b9449406adf91d3934..ad2a4dbec4e923b98ac91786b1c310cf6d3c941b 100644 (file)
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
 
-#![feature(macro_rules, phase, globs)]
-#![feature(unboxed_closures)]
-#![feature(associated_types)]
 #![no_std]
 #![experimental]
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate core;
-
-#[cfg(not(stage0))]
 #[macro_use]
 extern crate core;
 
-#[cfg(all(test, stage0))]
-#[phase(plugin, link)]
-extern crate std;
-
-#[cfg(all(test, not(stage0)))]
-#[macro_use]
-extern crate std;
-
-#[cfg(all(test, stage0))]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(all(test, not(stage0)))]
-#[macro_use]
-extern crate log;
+#[cfg(test)] #[macro_use] extern crate std;
+#[cfg(test)] #[macro_use] extern crate log;
 
 use core::prelude::*;
 
@@ -161,7 +140,7 @@ fn next_f64(&mut self) -> f64 {
     ///
     /// let mut v = [0u8; 13579];
     /// thread_rng().fill_bytes(&mut v);
-    /// println!("{}", v.as_slice());
+    /// println!("{:?}", v.as_slice());
     /// ```
     fn fill_bytes(&mut self, dest: &mut [u8]) {
         // this could, in theory, be done by transmuting dest to a
@@ -197,7 +176,7 @@ fn fill_bytes(&mut self, dest: &mut [u8]) {
     /// let mut rng = thread_rng();
     /// let x: uint = rng.gen();
     /// println!("{}", x);
-    /// println!("{}", rng.gen::<(f64, bool)>());
+    /// println!("{:?}", rng.gen::<(f64, bool)>());
     /// ```
     #[inline(always)]
     fn gen<T: Rand>(&mut self) -> T {
@@ -215,8 +194,8 @@ fn gen<T: Rand>(&mut self) -> T {
     /// let mut rng = thread_rng();
     /// let x = rng.gen_iter::<uint>().take(10).collect::<Vec<uint>>();
     /// println!("{}", x);
-    /// println!("{}", rng.gen_iter::<(f64, bool)>().take(5)
-    ///                   .collect::<Vec<(f64, bool)>>());
+    /// println!("{:?}", rng.gen_iter::<(f64, bool)>().take(5)
+    ///                     .collect::<Vec<(f64, bool)>>());
     /// ```
     fn gen_iter<'a, T: Rand>(&'a mut self) -> Generator<'a, T, Self> {
         Generator { rng: self }
@@ -289,9 +268,9 @@ fn gen_ascii_chars<'a>(&'a mut self) -> AsciiGenerator<'a, Self> {
     ///
     /// let choices = [1i, 2, 4, 8, 16, 32];
     /// let mut rng = thread_rng();
-    /// println!("{}", rng.choose(&choices));
-    /// # // replace with slicing syntax when it's stable!
-    /// assert_eq!(rng.choose(choices.slice_to(0)), None);
+    /// println!("{:?}", rng.choose(&choices));
+    /// # // uncomment when slicing syntax is stable
+    /// //assert_eq!(rng.choose(choices.index(&(0..0))), None);
     /// ```
     fn choose<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> {
         if values.is_empty() {
@@ -516,7 +495,9 @@ fn rand<R: Rng>(rng: &mut R) -> XorShiftRng {
 mod std {
     pub use core::{option, fmt}; // panic!()
     pub use core::clone; // derive Clone
-    pub use core::kinds;
+    #[cfg(stage0)]
+    pub use core::marker as kinds;
+    pub use core::marker;
 }
 
 #[cfg(test)]
index de06471e65ed9e62f2caf40dae9691a1fb2ea875..5ebec32d733841796f250b596328b6482fe47d73 100644 (file)
@@ -95,7 +95,7 @@ fn write(&mut self, buf: &[u8]) -> IoResult<()> {
             // there (left), and what will be appended on the end (right)
             let cap = self.buf.len() - self.pos;
             let (left, right) = if cap <= buf.len() {
-                (buf[..cap], buf[cap..])
+                (buf.index(&(0..cap)), buf.index(&(cap..)))
             } else {
                 let result: (_, &[_]) = (buf, &[]);
                 result
index e57542a6d14de1c1e2e08f91d51fe59ed594dc0f..a66d1dd08c1eb6aac528aa7723cde4a25d46e884 100644 (file)
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![allow(unknown_features)]
-#![feature(macro_rules, phase, slicing_syntax, globs)]
-#![feature(unboxed_closures, associated_types)]
-#![allow(missing_docs)]
+#![feature(slicing_syntax)]
 
 extern crate serialize;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
+#[macro_use] extern crate log;
 
 #[cfg(test)] extern crate test;
 
@@ -65,7 +56,7 @@ pub fn get<'a>(&'a self, tag: uint) -> Doc<'a> {
     }
 
     pub fn as_str_slice<'a>(&'a self) -> &'a str {
-        str::from_utf8(self.data[self.start..self.end]).unwrap()
+        str::from_utf8(self.data.index(&(self.start..self.end))).unwrap()
     }
 
     pub fn as_str(&self) -> String {
@@ -147,7 +138,7 @@ macro_rules! try_or {
             match $e {
                 Ok(e) => e,
                 Err(e) => {
-                    debug!("ignored error: {}", e);
+                    debug!("ignored error: {:?}", e);
                     return $r
                 }
             }
@@ -256,7 +247,7 @@ pub fn get_doc<'a>(d: Doc<'a>, tg: uint) -> Doc<'a> {
         match maybe_get_doc(d, tg) {
             Some(d) => d,
             None => {
-                error!("failed to find block with tag {}", tg);
+                error!("failed to find block with tag {:?}", tg);
                 panic!();
             }
         }
@@ -300,7 +291,7 @@ pub fn tagged_docs<F>(d: Doc, tg: uint, mut it: F) -> bool where
     pub fn with_doc_data<T, F>(d: Doc, f: F) -> T where
         F: FnOnce(&[u8]) -> T,
     {
-        f(d.data[d.start..d.end])
+        f(d.data.index(&(d.start..d.end)))
     }
 
 
@@ -351,8 +342,8 @@ fn _check_label(&mut self, lbl: &str) -> DecodeResult<()> {
                     self.pos = r_doc.end;
                     let str = r_doc.as_str_slice();
                     if lbl != str {
-                        return Err(Expected(format!("Expected label {} but \
-                                                     found {}", lbl, str)));
+                        return Err(Expected(format!("Expected label {:?} but \
+                                                     found {:?}", lbl, str)));
                     }
                 }
             }
@@ -360,14 +351,14 @@ fn _check_label(&mut self, lbl: &str) -> DecodeResult<()> {
         }
 
         fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<Doc<'doc>> {
-            debug!(". next_doc(exp_tag={})", exp_tag);
+            debug!(". next_doc(exp_tag={:?})", exp_tag);
             if self.pos >= self.parent.end {
                 return Err(Expected(format!("no more documents in \
                                              current node!")));
             }
             let TaggedDoc { tag: r_tag, doc: r_doc } =
                 try!(doc_at(self.parent.data, self.pos));
-            debug!("self.parent={}-{} self.pos={} r_tag={} r_doc={}-{}",
+            debug!("self.parent={:?}-{:?} self.pos={:?} r_tag={:?} r_doc={:?}-{:?}",
                    self.parent.start,
                    self.parent.end,
                    self.pos,
@@ -375,8 +366,8 @@ fn next_doc(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<Doc<'doc>> {
                    r_doc.start,
                    r_doc.end);
             if r_tag != (exp_tag as uint) {
-                return Err(Expected(format!("expected EBML doc with tag {} but \
-                                             found tag {}", exp_tag, r_tag)));
+                return Err(Expected(format!("expected EBML doc with tag {:?} but \
+                                             found tag {:?}", exp_tag, r_tag)));
             }
             if r_doc.end > self.parent.end {
                 return Err(Expected(format!("invalid EBML, child extends to \
@@ -403,7 +394,7 @@ fn push_doc<T, F>(&mut self, exp_tag: EbmlEncoderTag, f: F) -> DecodeResult<T> w
 
         fn _next_uint(&mut self, exp_tag: EbmlEncoderTag) -> DecodeResult<uint> {
             let r = doc_as_u32(try!(self.next_doc(exp_tag)));
-            debug!("_next_uint exp_tag={} result={}", exp_tag, r);
+            debug!("_next_uint exp_tag={:?} result={:?}", exp_tag, r);
             Ok(r as uint)
         }
 
@@ -424,263 +415,6 @@ pub fn read_opaque<R, F>(&mut self, op: F) -> DecodeResult<R> where
         }
     }
 
-    #[cfg(stage0)]
-    impl<'doc> serialize::Decoder<Error> for Decoder<'doc> {
-        fn read_nil(&mut self) -> DecodeResult<()> { Ok(()) }
-
-        fn read_u64(&mut self) -> DecodeResult<u64> { Ok(doc_as_u64(try!(self.next_doc(EsU64)))) }
-        fn read_u32(&mut self) -> DecodeResult<u32> { Ok(doc_as_u32(try!(self.next_doc(EsU32)))) }
-        fn read_u16(&mut self) -> DecodeResult<u16> { Ok(doc_as_u16(try!(self.next_doc(EsU16)))) }
-        fn read_u8 (&mut self) -> DecodeResult<u8 > { Ok(doc_as_u8 (try!(self.next_doc(EsU8 )))) }
-        fn read_uint(&mut self) -> DecodeResult<uint> {
-            let v = doc_as_u64(try!(self.next_doc(EsUint)));
-            if v > (::std::uint::MAX as u64) {
-                Err(IntTooBig(v as uint))
-            } else {
-                Ok(v as uint)
-            }
-        }
-
-        fn read_i64(&mut self) -> DecodeResult<i64> {
-            Ok(doc_as_u64(try!(self.next_doc(EsI64))) as i64)
-        }
-        fn read_i32(&mut self) -> DecodeResult<i32> {
-            Ok(doc_as_u32(try!(self.next_doc(EsI32))) as i32)
-        }
-        fn read_i16(&mut self) -> DecodeResult<i16> {
-            Ok(doc_as_u16(try!(self.next_doc(EsI16))) as i16)
-        }
-        fn read_i8 (&mut self) -> DecodeResult<i8> {
-            Ok(doc_as_u8(try!(self.next_doc(EsI8 ))) as i8)
-        }
-        fn read_int(&mut self) -> DecodeResult<int> {
-            let v = doc_as_u64(try!(self.next_doc(EsInt))) as i64;
-            if v > (int::MAX as i64) || v < (int::MIN as i64) {
-                debug!("FIXME \\#6122: Removing this makes this function miscompile");
-                Err(IntTooBig(v as uint))
-            } else {
-                Ok(v as int)
-            }
-        }
-
-        fn read_bool(&mut self) -> DecodeResult<bool> {
-            Ok(doc_as_u8(try!(self.next_doc(EsBool))) != 0)
-        }
-
-        fn read_f64(&mut self) -> DecodeResult<f64> {
-            let bits = doc_as_u64(try!(self.next_doc(EsF64)));
-            Ok(unsafe { transmute(bits) })
-        }
-        fn read_f32(&mut self) -> DecodeResult<f32> {
-            let bits = doc_as_u32(try!(self.next_doc(EsF32)));
-            Ok(unsafe { transmute(bits) })
-        }
-        fn read_char(&mut self) -> DecodeResult<char> {
-            Ok(char::from_u32(doc_as_u32(try!(self.next_doc(EsChar)))).unwrap())
-        }
-        fn read_str(&mut self) -> DecodeResult<String> {
-            Ok(try!(self.next_doc(EsStr)).as_str())
-        }
-
-        // Compound types:
-        fn read_enum<T, F>(&mut self, name: &str, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_enum({})", name);
-            try!(self._check_label(name));
-
-            let doc = try!(self.next_doc(EsEnum));
-
-            let (old_parent, old_pos) = (self.parent, self.pos);
-            self.parent = doc;
-            self.pos = self.parent.start;
-
-            let result = try!(f(self));
-
-            self.parent = old_parent;
-            self.pos = old_pos;
-            Ok(result)
-        }
-
-        fn read_enum_variant<T, F>(&mut self, _: &[&str],
-                                   mut f: F) -> DecodeResult<T>
-            where F: FnMut(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
-        {
-            debug!("read_enum_variant()");
-            let idx = try!(self._next_uint(EsEnumVid));
-            debug!("  idx={}", idx);
-
-            let doc = try!(self.next_doc(EsEnumBody));
-
-            let (old_parent, old_pos) = (self.parent, self.pos);
-            self.parent = doc;
-            self.pos = self.parent.start;
-
-            let result = try!(f(self, idx));
-
-            self.parent = old_parent;
-            self.pos = old_pos;
-            Ok(result)
-        }
-
-        fn read_enum_variant_arg<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_enum_variant_arg(idx={})", idx);
-            f(self)
-        }
-
-        fn read_enum_struct_variant<T, F>(&mut self, _: &[&str],
-                                          mut f: F) -> DecodeResult<T>
-            where F: FnMut(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
-        {
-            debug!("read_enum_struct_variant()");
-            let idx = try!(self._next_uint(EsEnumVid));
-            debug!("  idx={}", idx);
-
-            let doc = try!(self.next_doc(EsEnumBody));
-
-            let (old_parent, old_pos) = (self.parent, self.pos);
-            self.parent = doc;
-            self.pos = self.parent.start;
-
-            let result = try!(f(self, idx));
-
-            self.parent = old_parent;
-            self.pos = old_pos;
-            Ok(result)
-        }
-
-        fn read_enum_struct_variant_field<T, F>(&mut self,
-                                                name: &str,
-                                                idx: uint,
-                                                f: F)
-                                                -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-                debug!("read_enum_struct_variant_arg(name={}, idx={})", name, idx);
-            f(self)
-        }
-
-        fn read_struct<T, F>(&mut self, name: &str, _: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_struct(name={})", name);
-            f(self)
-        }
-
-        fn read_struct_field<T, F>(&mut self, name: &str, idx: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_struct_field(name={}, idx={})", name, idx);
-            try!(self._check_label(name));
-            f(self)
-        }
-
-        fn read_tuple<T, F>(&mut self, tuple_len: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_tuple()");
-            self.read_seq(move |d, len| {
-                if len == tuple_len {
-                    f(d)
-                } else {
-                    Err(Expected(format!("Expected tuple of length `{}`, \
-                                          found tuple of length `{}`", tuple_len, len)))
-                }
-            })
-        }
-
-        fn read_tuple_arg<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_tuple_arg(idx={})", idx);
-            self.read_seq_elt(idx, f)
-        }
-
-        fn read_tuple_struct<T, F>(&mut self, name: &str, len: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_tuple_struct(name={})", name);
-            self.read_tuple(len, f)
-        }
-
-        fn read_tuple_struct_arg<T, F>(&mut self,
-                                       idx: uint,
-                                       f: F)
-                                       -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_tuple_struct_arg(idx={})", idx);
-            self.read_tuple_arg(idx, f)
-        }
-
-        fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where
-            F: FnMut(&mut Decoder<'doc>, bool) -> DecodeResult<T>,
-        {
-            debug!("read_option()");
-            self.read_enum("Option", move |this| {
-                this.read_enum_variant(&["None", "Some"], move |this, idx| {
-                    match idx {
-                        0 => f(this, false),
-                        1 => f(this, true),
-                        _ => {
-                            Err(Expected(format!("Expected None or Some")))
-                        }
-                    }
-                })
-            })
-        }
-
-        fn read_seq<T, F>(&mut self, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
-        {
-            debug!("read_seq()");
-            self.push_doc(EsVec, move |d| {
-                let len = try!(d._next_uint(EsVecLen));
-                debug!("  len={}", len);
-                f(d, len)
-            })
-        }
-
-        fn read_seq_elt<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_seq_elt(idx={})", idx);
-            self.push_doc(EsVecElt, f)
-        }
-
-        fn read_map<T, F>(&mut self, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>, uint) -> DecodeResult<T>,
-        {
-            debug!("read_map()");
-            self.push_doc(EsMap, move |d| {
-                let len = try!(d._next_uint(EsMapLen));
-                debug!("  len={}", len);
-                f(d, len)
-            })
-        }
-
-        fn read_map_elt_key<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_map_elt_key(idx={})", idx);
-            self.push_doc(EsMapKey, f)
-        }
-
-        fn read_map_elt_val<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
-            F: FnOnce(&mut Decoder<'doc>) -> DecodeResult<T>,
-        {
-            debug!("read_map_elt_val(idx={})", idx);
-            self.push_doc(EsMapVal, f)
-        }
-
-        fn error(&mut self, err: &str) -> Error {
-            ApplicationError(err.to_string())
-        }
-    }
-
-    #[cfg(not(stage0))]
     impl<'doc> serialize::Decoder for Decoder<'doc> {
         type Error = Error;
         fn read_nil(&mut self) -> DecodeResult<()> { Ok(()) }
@@ -1007,7 +741,7 @@ pub unsafe fn unsafe_clone(&self) -> Encoder<'a, W> {
         }
 
         pub fn start_tag(&mut self, tag_id: uint) -> EncodeResult {
-            debug!("Start tag {}", tag_id);
+            debug!("Start tag {:?}", tag_id);
 
             // Write the enum ID:
             try!(write_vuint(self.writer, tag_id));
@@ -1026,7 +760,7 @@ pub fn end_tag(&mut self) -> EncodeResult {
             try!(write_sized_vuint(self.writer, size, 4u));
             let r = try!(self.writer.seek(cur_pos as i64, io::SeekSet));
 
-            debug!("End tag (size = {})", size);
+            debug!("End tag (size = {:?})", size);
             Ok(r)
         }
 
@@ -1093,12 +827,12 @@ pub fn wr_tagged_str(&mut self, tag_id: uint, v: &str) -> EncodeResult {
         }
 
         pub fn wr_bytes(&mut self, b: &[u8]) -> EncodeResult {
-            debug!("Write {} bytes", b.len());
+            debug!("Write {:?} bytes", b.len());
             self.writer.write(b)
         }
 
         pub fn wr_str(&mut self, s: &str) -> EncodeResult {
-            debug!("Write str: {}", s);
+            debug!("Write str: {:?}", s);
             self.writer.write(s.as_bytes())
         }
     }
@@ -1137,209 +871,6 @@ pub fn emit_opaque<F>(&mut self, f: F) -> EncodeResult where
         }
     }
 
-    #[cfg(stage0)]
-    impl<'a, W: Writer + Seek> serialize::Encoder<io::IoError> for Encoder<'a, W> {
-
-        fn emit_nil(&mut self) -> EncodeResult {
-            Ok(())
-        }
-
-        fn emit_uint(&mut self, v: uint) -> EncodeResult {
-            self.wr_tagged_u64(EsUint as uint, v as u64)
-        }
-        fn emit_u64(&mut self, v: u64) -> EncodeResult {
-            self.wr_tagged_u64(EsU64 as uint, v)
-        }
-        fn emit_u32(&mut self, v: u32) -> EncodeResult {
-            self.wr_tagged_u32(EsU32 as uint, v)
-        }
-        fn emit_u16(&mut self, v: u16) -> EncodeResult {
-            self.wr_tagged_u16(EsU16 as uint, v)
-        }
-        fn emit_u8(&mut self, v: u8) -> EncodeResult {
-            self.wr_tagged_u8(EsU8 as uint, v)
-        }
-
-        fn emit_int(&mut self, v: int) -> EncodeResult {
-            self.wr_tagged_i64(EsInt as uint, v as i64)
-        }
-        fn emit_i64(&mut self, v: i64) -> EncodeResult {
-            self.wr_tagged_i64(EsI64 as uint, v)
-        }
-        fn emit_i32(&mut self, v: i32) -> EncodeResult {
-            self.wr_tagged_i32(EsI32 as uint, v)
-        }
-        fn emit_i16(&mut self, v: i16) -> EncodeResult {
-            self.wr_tagged_i16(EsI16 as uint, v)
-        }
-        fn emit_i8(&mut self, v: i8) -> EncodeResult {
-            self.wr_tagged_i8(EsI8 as uint, v)
-        }
-
-        fn emit_bool(&mut self, v: bool) -> EncodeResult {
-            self.wr_tagged_u8(EsBool as uint, v as u8)
-        }
-
-        fn emit_f64(&mut self, v: f64) -> EncodeResult {
-            let bits = unsafe { mem::transmute(v) };
-            self.wr_tagged_u64(EsF64 as uint, bits)
-        }
-        fn emit_f32(&mut self, v: f32) -> EncodeResult {
-            let bits = unsafe { mem::transmute(v) };
-            self.wr_tagged_u32(EsF32 as uint, bits)
-        }
-        fn emit_char(&mut self, v: char) -> EncodeResult {
-            self.wr_tagged_u32(EsChar as uint, v as u32)
-        }
-
-        fn emit_str(&mut self, v: &str) -> EncodeResult {
-            self.wr_tagged_str(EsStr as uint, v)
-        }
-
-        fn emit_enum<F>(&mut self, name: &str, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            try!(self._emit_label(name));
-            try!(self.start_tag(EsEnum as uint));
-            try!(f(self));
-            self.end_tag()
-        }
-
-        fn emit_enum_variant<F>(&mut self,
-                                _: &str,
-                                v_id: uint,
-                                _: uint,
-                                f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            try!(self._emit_tagged_uint(EsEnumVid, v_id));
-            try!(self.start_tag(EsEnumBody as uint));
-            try!(f(self));
-            self.end_tag()
-        }
-
-        fn emit_enum_variant_arg<F>(&mut self, _: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            f(self)
-        }
-
-        fn emit_enum_struct_variant<F>(&mut self,
-                                       v_name: &str,
-                                       v_id: uint,
-                                       cnt: uint,
-                                       f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            self.emit_enum_variant(v_name, v_id, cnt, f)
-        }
-
-        fn emit_enum_struct_variant_field<F>(&mut self,
-                                             _: &str,
-                                             idx: uint,
-                                             f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            self.emit_enum_variant_arg(idx, f)
-        }
-
-        fn emit_struct<F>(&mut self, _: &str, _len: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            f(self)
-        }
-
-        fn emit_struct_field<F>(&mut self, name: &str, _: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            try!(self._emit_label(name));
-            f(self)
-        }
-
-        fn emit_tuple<F>(&mut self, len: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            self.emit_seq(len, f)
-        }
-        fn emit_tuple_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            self.emit_seq_elt(idx, f)
-        }
-
-        fn emit_tuple_struct<F>(&mut self, _: &str, len: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            self.emit_seq(len, f)
-        }
-        fn emit_tuple_struct_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            self.emit_seq_elt(idx, f)
-        }
-
-        fn emit_option<F>(&mut self, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            self.emit_enum("Option", f)
-        }
-        fn emit_option_none(&mut self) -> EncodeResult {
-            self.emit_enum_variant("None", 0, 0, |_| Ok(()))
-        }
-        fn emit_option_some<F>(&mut self, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-
-            self.emit_enum_variant("Some", 1, 1, f)
-        }
-
-        fn emit_seq<F>(&mut self, len: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-
-            try!(self.start_tag(EsVec as uint));
-            try!(self._emit_tagged_uint(EsVecLen, len));
-            try!(f(self));
-            self.end_tag()
-        }
-
-        fn emit_seq_elt<F>(&mut self, _idx: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-
-            try!(self.start_tag(EsVecElt as uint));
-            try!(f(self));
-            self.end_tag()
-        }
-
-        fn emit_map<F>(&mut self, len: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-
-            try!(self.start_tag(EsMap as uint));
-            try!(self._emit_tagged_uint(EsMapLen, len));
-            try!(f(self));
-            self.end_tag()
-        }
-
-        fn emit_map_elt_key<F>(&mut self, _idx: uint, mut f: F) -> EncodeResult where
-            F: FnMut(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-
-            try!(self.start_tag(EsMapKey as uint));
-            try!(f(self));
-            self.end_tag()
-        }
-
-        fn emit_map_elt_val<F>(&mut self, _idx: uint, f: F) -> EncodeResult where
-            F: FnOnce(&mut Encoder<'a, W>) -> EncodeResult,
-        {
-            try!(self.start_tag(EsMapVal as uint));
-            try!(f(self));
-            self.end_tag()
-        }
-    }
-    #[cfg(not(stage0))]
     impl<'a, W: Writer + Seek> serialize::Encoder for Encoder<'a, W> {
         type Error = io::IoError;
 
@@ -1608,7 +1139,7 @@ fn test_vuint_at() {
     #[test]
     fn test_option_int() {
         fn test_v(v: Option<int>) {
-            debug!("v == {}", v);
+            debug!("v == {:?}", v);
             let mut wr = SeekableMemWriter::new();
             {
                 let mut rbml_w = writer::Encoder::new(&mut wr);
@@ -1617,7 +1148,7 @@ fn test_v(v: Option<int>) {
             let rbml_doc = Doc::new(wr.get_ref());
             let mut deser = reader::Decoder::new(rbml_doc);
             let v1 = Decodable::decode(&mut deser).unwrap();
-            debug!("v1 == {}", v1);
+            debug!("v1 == {:?}", v1);
             assert_eq!(v, v1);
         }
 
index d29a7a425c1164d1825549f49a99305377d89a95..5803da1d3350d541867c381caad253e904a4e0fa 100644 (file)
@@ -105,7 +105,7 @@ pub fn new(ast: parse::Ast) -> (Program, Vec<Option<String>>) {
         // This is a bit hacky since we have to skip over the initial
         // 'Save' instruction.
         let mut pre = String::with_capacity(5);
-        for inst in c.insts[1..].iter() {
+        for inst in c.insts.index(&(1..)).iter() {
             match *inst {
                 OneChar(c, FLAG_EMPTY) => pre.push(c),
                 _ => break
index 0084be49b561904534e693d4b69e736ab96f5eff..c039abc9aff2a8955134bfbcd8181f2a46b85ae9 100644 (file)
@@ -13,7 +13,6 @@
 //! Regular expressions implemented in Rust
 //!
 //! For official documentation, see the rust-lang/regex crate
-
 #![crate_name = "regex"]
 #![crate_type = "rlib"]
 #![crate_type = "dylib"]
@@ -24,9 +23,7 @@
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![allow(unknown_features)]
-#![feature(macro_rules, slicing_syntax, globs)]
-#![feature(unboxed_closures)]
-#![feature(associated_types)]
+#![feature(slicing_syntax)]
 #![deny(missing_docs)]
 
 #[cfg(test)]
index 07da86afcc9719834b50a60710c3d2104d628133..dd11d42b8aad60b0186701538d1554d1de626d52 100644 (file)
@@ -18,6 +18,7 @@
 use std::fmt;
 use std::iter;
 use std::num;
+use std::ops::Index;
 
 /// Static data containing Unicode ranges for general categories and scripts.
 use unicode::regex::{UNICODE_CLASSES, PERLD, PERLS, PERLW};
@@ -39,7 +40,7 @@ pub struct Error {
 
 impl fmt::Show for Error {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "Regex syntax error near position {}: {}",
+        write!(f, "Regex syntax error near position {}: {:?}",
                self.pos, self.msg)
     }
 }
@@ -121,7 +122,7 @@ fn paren(&self) -> bool {
     fn flags(&self) -> Flags {
         match *self {
             Paren(flags, _, _) => flags,
-            _ => panic!("Cannot get flags from {}", self),
+            _ => panic!("Cannot get flags from {:?}", self),
         }
     }
 
@@ -129,7 +130,7 @@ fn capture(&self) -> Option<uint> {
         match *self {
             Paren(_, 0, _) => None,
             Paren(_, c, _) => Some(c),
-            _ => panic!("Cannot get capture group from {}", self),
+            _ => panic!("Cannot get capture group from {:?}", self),
         }
     }
 
@@ -143,7 +144,7 @@ fn capture_name(&self) -> Option<String> {
                     Some(name.clone())
                 }
             }
-            _ => panic!("Cannot get capture name from {}", self),
+            _ => panic!("Cannot get capture name from {:?}", self),
         }
     }
 
@@ -157,7 +158,7 @@ fn bar(&self) -> bool {
     fn unwrap(self) -> Result<Ast, Error> {
         match self {
             Expr(x) => Ok(x),
-            _ => panic!("Tried to unwrap non-AST item: {}", self),
+            _ => panic!("Tried to unwrap non-AST item: {:?}", self),
         }
     }
 }
@@ -284,8 +285,8 @@ fn noteof(&mut self, expected: &str) -> Result<(), Error> {
         match self.next_char() {
             true => Ok(()),
             false => {
-                self.err(format!("Expected {} but got EOF.",
-                                 expected)[])
+                self.err(format!("Expected {:?} but got EOF.",
+                                 expected).index(&FullRange))
             }
         }
     }
@@ -293,11 +294,11 @@ fn noteof(&mut self, expected: &str) -> Result<(), Error> {
     fn expect(&mut self, expected: char) -> Result<(), Error> {
         match self.next_char() {
             true if self.cur() == expected => Ok(()),
-            true => self.err(format!("Expected '{}' but got '{}'.",
-                                     expected, self.cur())[]),
+            true => self.err(format!("Expected '{:?}' but got '{:?}'.",
+                                     expected, self.cur()).index(&FullRange)),
             false => {
-                self.err(format!("Expected '{}' but got EOF.",
-                                 expected)[])
+                self.err(format!("Expected '{:?}' but got EOF.",
+                                 expected).index(&FullRange))
             }
         }
     }
@@ -394,7 +395,7 @@ fn parse_class(&mut self) -> Result<(), Error> {
                             continue
                         }
                         Some(ast) =>
-                            panic!("Expected Class AST but got '{}'", ast),
+                            panic!("Expected Class AST but got '{:?}'", ast),
                         // Just drop down and try to add as a regular character.
                         None => {},
                     },
@@ -409,7 +410,7 @@ fn parse_class(&mut self) -> Result<(), Error> {
                             return self.err(
                                 "\\A, \\z, \\b and \\B are not valid escape \
                                  sequences inside a character class."),
-                        ast => panic!("Unexpected AST item '{}'", ast),
+                        ast => panic!("Unexpected AST item '{:?}'", ast),
                     }
                 }
                 ']' if ranges.len() > 0 || alts.len() > 0 => {
@@ -442,15 +443,15 @@ fn parse_class(&mut self) -> Result<(), Error> {
                     match try!(self.parse_escape()) {
                         Literal(c3, _) => c2 = c3, // allow literal escapes below
                         ast =>
-                            return self.err(format!("Expected a literal, but got {}.",
-                                                    ast)[]),
+                            return self.err(format!("Expected a literal, but got {:?}.",
+                                                    ast).index(&FullRange)),
                     }
                 }
                 if c2 < c {
                     return self.err(format!("Invalid character class \
                                              range '{}-{}'",
                                             c,
-                                            c2)[])
+                                            c2).index(&FullRange))
                 }
                 ranges.push((c, self.cur()))
             } else {
@@ -488,7 +489,7 @@ fn try_parse_ascii(&mut self) -> Option<Ast> {
                 FLAG_EMPTY
             };
         let name = self.slice(name_start, closer - 1);
-        match find_class(ASCII_CLASSES, name[]) {
+        match find_class(ASCII_CLASSES, name.index(&FullRange)) {
             None => None,
             Some(ranges) => {
                 self.chari = closer;
@@ -512,19 +513,19 @@ fn parse_counted(&mut self) -> Result<(), Error> {
                 None => {
                     return self.err(format!("No closing brace for counted \
                                              repetition starting at position \
-                                             {}.",
-                                            start)[])
+                                             {:?}.",
+                                            start).index(&FullRange))
                 }
             };
         self.chari = closer;
         let greed = try!(self.get_next_greedy());
-        let inner = self.chars[start+1..closer].iter().cloned()
+        let inner = self.chars.index(&((start+1)..closer)).iter().cloned()
                                                .collect::<String>();
 
         // Parse the min and max values from the regex.
         let (mut min, mut max): (uint, Option<uint>);
         if !inner.contains(",") {
-            min = try!(self.parse_uint(inner[]));
+            min = try!(self.parse_uint(inner.index(&FullRange)));
             max = Some(min);
         } else {
             let pieces: Vec<&str> = inner.splitn(1, ',').collect();
@@ -546,19 +547,19 @@ fn parse_counted(&mut self) -> Result<(), Error> {
         if min > MAX_REPEAT {
             return self.err(format!(
                 "{} exceeds maximum allowed repetitions ({})",
-                min, MAX_REPEAT)[]);
+                min, MAX_REPEAT).index(&FullRange));
         }
         if max.is_some() {
             let m = max.unwrap();
             if m > MAX_REPEAT {
                 return self.err(format!(
                     "{} exceeds maximum allowed repetitions ({})",
-                    m, MAX_REPEAT)[]);
+                    m, MAX_REPEAT).index(&FullRange));
             }
             if m < min {
                 return self.err(format!(
                     "Max repetitions ({}) cannot be smaller than min \
-                     repetitions ({}).", m, min)[]);
+                     repetitions ({}).", m, min).index(&FullRange));
             }
         }
 
@@ -622,7 +623,7 @@ fn parse_escape(&mut self) -> Result<Ast, Error> {
                 Ok(AstClass(ranges, flags))
             }
             _ => {
-                self.err(format!("Invalid escape sequence '\\\\{}'", c)[])
+                self.err(format!("Invalid escape sequence '\\\\{}'", c).index(&FullRange))
             }
         }
     }
@@ -642,7 +643,7 @@ fn parse_unicode_name(&mut self) -> Result<Ast, Error> {
                     Some(i) => i,
                     None => return self.err(format!(
                         "Missing '}}' for unclosed '{{' at position {}",
-                        self.chari)[]),
+                        self.chari).index(&FullRange)),
                 };
             if closer - self.chari + 1 == 0 {
                 return self.err("No Unicode class name found.")
@@ -656,10 +657,10 @@ fn parse_unicode_name(&mut self) -> Result<Ast, Error> {
             name = self.slice(self.chari + 1, self.chari + 2);
             self.chari += 1;
         }
-        match find_class(UNICODE_CLASSES, name[]) {
+        match find_class(UNICODE_CLASSES, name.index(&FullRange)) {
             None => {
                 return self.err(format!("Could not find Unicode class '{}'",
-                                        name)[])
+                                        name).index(&FullRange))
             }
             Some(ranges) => {
                 Ok(AstClass(ranges, negated | (self.flags & FLAG_NOCASE)))
@@ -682,11 +683,11 @@ fn parse_octal(&mut self) -> Result<Ast, Error> {
             }
         }
         let s = self.slice(start, end);
-        match num::from_str_radix::<u32>(s[], 8) {
+        match num::from_str_radix::<u32>(s.index(&FullRange), 8) {
             Some(n) => Ok(Literal(try!(self.char_from_u32(n)), FLAG_EMPTY)),
             None => {
-                self.err(format!("Could not parse '{}' as octal number.",
-                                 s)[])
+                self.err(format!("Could not parse '{:?}' as octal number.",
+                                 s).index(&FullRange))
             }
         }
     }
@@ -704,12 +705,12 @@ fn parse_hex(&mut self) -> Result<Ast, Error> {
                 None => {
                     return self.err(format!("Missing '}}' for unclosed \
                                              '{{' at position {}",
-                                            start)[])
+                                            start).index(&FullRange))
                 }
                 Some(i) => i,
             };
         self.chari = closer;
-        self.parse_hex_digits(self.slice(start, closer)[])
+        self.parse_hex_digits(self.slice(start, closer).index(&FullRange))
     }
 
     // Parses a two-digit hex number.
@@ -729,7 +730,7 @@ fn parse_hex_digits(&self, s: &str) -> Result<Ast, Error> {
         match num::from_str_radix::<u32>(s, 16) {
             Some(n) => Ok(Literal(try!(self.char_from_u32(n)), FLAG_EMPTY)),
             None => {
-                self.err(format!("Could not parse '{}' as hex number.", s)[])
+                self.err(format!("Could not parse '{}' as hex number.", s).index(&FullRange))
             }
         }
     }
@@ -755,7 +756,7 @@ fn parse_named_capture(&mut self) -> Result<(), Error> {
         }
         if self.names.contains(&name) {
             return self.err(format!("Duplicate capture group name '{}'.",
-                                    name)[])
+                                    name).index(&FullRange))
         }
         self.names.push(name.clone());
         self.chari = closer;
@@ -789,7 +790,7 @@ fn parse_group_opts(&mut self) -> Result<(), Error> {
                     if sign < 0 {
                         return self.err(format!(
                             "Cannot negate flags twice in '{}'.",
-                            self.slice(start, self.chari + 1))[])
+                            self.slice(start, self.chari + 1)).index(&FullRange))
                     }
                     sign = -1;
                     saw_flag = false;
@@ -800,7 +801,7 @@ fn parse_group_opts(&mut self) -> Result<(), Error> {
                         if !saw_flag {
                             return self.err(format!(
                                 "A valid flag does not follow negation in '{}'",
-                                self.slice(start, self.chari + 1))[])
+                                self.slice(start, self.chari + 1)).index(&FullRange))
                         }
                         flags = flags ^ flags;
                     }
@@ -812,7 +813,7 @@ fn parse_group_opts(&mut self) -> Result<(), Error> {
                     return Ok(())
                 }
                 _ => return self.err(format!(
-                    "Unrecognized flag '{}'.", self.cur())[]),
+                    "Unrecognized flag '{}'.", self.cur()).index(&FullRange)),
             }
         }
     }
@@ -910,7 +911,7 @@ fn parse_uint(&self, s: &str) -> Result<uint, Error> {
             Some(i) => Ok(i),
             None => {
                 self.err(format!("Expected an unsigned integer but got '{}'.",
-                                 s)[])
+                                 s).index(&FullRange))
             }
         }
     }
@@ -920,7 +921,7 @@ fn char_from_u32(&self, n: u32) -> Result<char, Error> {
             Some(c) => Ok(c),
             None => {
                 self.err(format!("Could not decode '{}' to unicode \
-                                  character.", n)[])
+                                  character.", n).index(&FullRange))
             }
         }
     }
@@ -953,7 +954,7 @@ fn cur(&self) -> char {
     }
 
     fn slice(&self, start: uint, end: uint) -> String {
-        self.chars[start..end].iter().cloned().collect()
+        self.chars.index(&(start..end)).iter().cloned().collect()
     }
 }
 
index 1840a3343e63c424294a4d214ef83d27159bf2a2..37f9869f3bfaf6e50e0be95965f8fe993472390c 100644 (file)
@@ -90,10 +90,19 @@ fn clone(&self) -> ExNative {
     }
 }
 
+#[cfg(stage0)]
+//FIXME: remove after stage0 snapshot
 impl fmt::Show for Regex {
     /// Shows the original regular expression.
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", self.as_str())
+        fmt::String::fmt(self.as_str(), f)
+    }
+}
+
+impl fmt::String for Regex {
+    /// Shows the original regular expression.
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self.as_str(), f)
     }
 }
 
@@ -238,19 +247,19 @@ pub fn replacen<R: Replacer>
             }
 
             let (s, e) = cap.pos(0).unwrap(); // captures only reports matches
-            new.push_str(text[last_match..s]);
-            new.push_str(rep.reg_replace(&cap)[]);
+            new.push_str(text.index(&(last_match..s)));
+            new.push_str(rep.reg_replace(&cap).index(&FullRange));
             last_match = e;
         }
-        new.push_str(text[last_match..text.len()]);
+        new.push_str(text.index(&(last_match..text.len())));
         return new;
     }
 
     /// Returns the original string of this regex.
     pub fn as_str<'a>(&'a self) -> &'a str {
         match *self {
-            Dynamic(ExDynamic { ref original, .. }) => original[],
-            Native(ExNative { ref original, .. }) => original[],
+            Dynamic(ExDynamic { ref original, .. }) => original.index(&FullRange),
+            Native(ExNative { ref original, .. }) => original.index(&FullRange),
         }
     }
 
@@ -347,13 +356,13 @@ fn next(&mut self) -> Option<&'t str> {
                 if self.last >= text.len() {
                     None
                 } else {
-                    let s = text[self.last..text.len()];
+                    let s = text.index(&(self.last..text.len()));
                     self.last = text.len();
                     Some(s)
                 }
             }
             Some((s, e)) => {
-                let matched = text[self.last..s];
+                let matched = text.index(&(self.last..s));
                 self.last = e;
                 Some(matched)
             }
@@ -384,7 +393,7 @@ fn next(&mut self) -> Option<&'t str> {
         } else {
             self.cur += 1;
             if self.cur >= self.limit {
-                Some(text[self.splits.last..text.len()])
+                Some(text.index(&(self.splits.last..text.len())))
             } else {
                 self.splits.next()
             }
@@ -517,7 +526,7 @@ pub fn expand(&self, text: &str) -> String {
             })
         });
         let re = Regex::new(r"\$\$").unwrap();
-        re.replace_all(text[], NoExpand("$"))
+        re.replace_all(text.index(&FullRange), NoExpand("$"))
     }
 
     /// Returns the number of captured groups.
index 48cc35aa5d93cfda8f7bd1ac347acf715d6d23ec..e11094b1174713a1b2bdbdc0480d4c94421dbd83 100644 (file)
@@ -12,7 +12,7 @@ macro_rules! regex {
     ($re:expr) => (
         match ::regex::Regex::new($re) {
             Ok(re) => re,
-            Err(err) => panic!("{}", err),
+            Err(err) => panic!("{:?}", err),
         }
     );
 }
index d087814b7f40194660787e5bb5b4b9dea7bbc7f1..b69420ac05bd1336e5b187950f8037bd0c2815e6 100644 (file)
@@ -159,10 +159,10 @@ fn $name() {
             // actual capture groups to match test set.
             let mut sgot = got.as_slice();
             if sgot.len() > expected.len() {
-                sgot = sgot[0..expected.len()]
+                sgot = &sgot[..expected.len()]
             }
             if expected != sgot {
-                panic!("For RE '{}' against '{}', expected '{}' but got '{}'",
+                panic!("For RE '{}' against '{}', expected '{:?}' but got '{:?}'",
                       $re, text, expected, sgot);
             }
         }
index 914167019d20969fd01412b99ce643aaf52fc0c2..04c430da4d29080f222f10cb935b57aa1482e7c5 100644 (file)
@@ -152,7 +152,7 @@ fn run(&mut self) -> CaptureLocs {
                 // out early.
                 if self.prog.prefix.len() > 0 && clist.size == 0 {
                     let needle = self.prog.prefix.as_bytes();
-                    let haystack = self.input.as_bytes()[self.ic..];
+                    let haystack = self.input.as_bytes().index(&(self.ic..));
                     match find_prefix(needle, haystack) {
                         None => break,
                         Some(i) => {
@@ -503,7 +503,8 @@ fn pc(&self, i: uint) -> uint {
 
     #[inline]
     fn groups<'r>(&'r mut self, i: uint) -> &'r mut [Option<uint>] {
-        self.queue[i].groups.as_mut_slice()
+        let q = &mut self.queue[i];
+        q.groups.as_mut_slice()
     }
 }
 
index 3ed712b15dfdcdb4eba468811aaff5a1634d3a42..a3a041c2497c7a9fed075053374a2127f9e6929a 100644 (file)
       html_root_url = "http://doc.rust-lang.org/nightly/")]
 
 #![allow(unknown_features)]
-#![feature(default_type_params, globs, macro_rules, phase, quote)]
+#![feature(quote)]
 #![feature(slicing_syntax, unsafe_destructor)]
 #![feature(rustc_diagnostic_macros)]
-#![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
-#![feature(associated_types)]
+#![feature(old_impl_check)]
 
 extern crate arena;
 extern crate flate;
 extern crate serialize;
 extern crate rbml;
 extern crate collections;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate syntax;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate syntax;
+#[macro_use] extern crate log;
+#[macro_use] extern crate syntax;
 
 extern crate "serialize" as rustc_serialize; // used by deriving
 
index 425e34cd9f0424b437b8eab9972519829e3a36b3..1af8e2f29ebd7c63faf25b93bc15f9a54bb92dd4 100644 (file)
@@ -46,7 +46,7 @@
 use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::{Span, DUMMY_SP};
 use syntax::parse::token;
-use syntax::ast::{TyI, TyU, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
+use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
 use syntax::ast_util;
 use syntax::ptr::P;
 use syntax::visit::{self, Visitor};
@@ -216,7 +216,7 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
                         match lit.node {
                             ast::LitInt(v, ast::SignedIntLit(_, ast::Plus)) |
                             ast::LitInt(v, ast::UnsuffixedIntLit(ast::Plus)) => {
-                                let int_type = if t == ast::TyI {
+                                let int_type = if t == ast::TyIs {
                                     cx.sess().target.int_type
                                 } else { t };
                                 let (min, max) = int_ty_range(int_type);
@@ -233,7 +233,7 @@ fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
                         };
                     },
                     ty::ty_uint(t) => {
-                        let uint_type = if t == ast::TyU {
+                        let uint_type = if t == ast::TyUs {
                             cx.sess().target.uint_type
                         } else { t };
                         let (min, max) = uint_ty_range(uint_type);
@@ -296,7 +296,7 @@ fn rev_binop(binop: ast::BinOp) -> ast::BinOp {
         // warnings are consistent between 32- and 64-bit platforms
         fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) {
             match int_ty {
-                ast::TyI =>    (i64::MIN,        i64::MAX),
+                ast::TyIs=>    (i64::MIN,        i64::MAX),
                 ast::TyI8 =>   (i8::MIN  as i64, i8::MAX  as i64),
                 ast::TyI16 =>  (i16::MIN as i64, i16::MAX as i64),
                 ast::TyI32 =>  (i32::MIN as i64, i32::MAX as i64),
@@ -306,7 +306,7 @@ fn int_ty_range(int_ty: ast::IntTy) -> (i64, i64) {
 
         fn uint_ty_range(uint_ty: ast::UintTy) -> (u64, u64) {
             match uint_ty {
-                ast::TyU =>   (u64::MIN,         u64::MAX),
+                ast::TyUs=>   (u64::MIN,         u64::MAX),
                 ast::TyU8 =>  (u8::MIN   as u64, u8::MAX   as u64),
                 ast::TyU16 => (u16::MIN  as u64, u16::MAX  as u64),
                 ast::TyU32 => (u32::MIN  as u64, u32::MAX  as u64),
@@ -323,7 +323,7 @@ fn float_ty_range(float_ty: ast::FloatTy) -> (f64, f64) {
 
         fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
             match int_ty {
-                ast::TyI =>    int_ty_bits(target_int_ty, target_int_ty),
+                ast::TyIs=>    int_ty_bits(target_int_ty, target_int_ty),
                 ast::TyI8 =>   i8::BITS  as u64,
                 ast::TyI16 =>  i16::BITS as u64,
                 ast::TyI32 =>  i32::BITS as u64,
@@ -333,7 +333,7 @@ fn int_ty_bits(int_ty: ast::IntTy, target_int_ty: ast::IntTy) -> u64 {
 
         fn uint_ty_bits(uint_ty: ast::UintTy, target_uint_ty: ast::UintTy) -> u64 {
             match uint_ty {
-                ast::TyU =>    uint_ty_bits(target_uint_ty, target_uint_ty),
+                ast::TyUs=>    uint_ty_bits(target_uint_ty, target_uint_ty),
                 ast::TyU8 =>   u8::BITS  as u64,
                 ast::TyU16 =>  u16::BITS as u64,
                 ast::TyU32 =>  u32::BITS as u64,
@@ -404,14 +404,14 @@ struct ImproperCTypesVisitor<'a, 'tcx: 'a> {
 impl<'a, 'tcx> ImproperCTypesVisitor<'a, 'tcx> {
     fn check_def(&mut self, sp: Span, ty_id: ast::NodeId, path_id: ast::NodeId) {
         match self.cx.tcx.def_map.borrow()[path_id].clone() {
-            def::DefPrimTy(ast::TyInt(ast::TyI)) => {
+            def::DefPrimTy(ast::TyInt(ast::TyIs)) => {
                 self.cx.span_lint(IMPROPER_CTYPES, sp,
-                                  "found rust type `int` in foreign module, while \
+                                  "found rust type `isize` in foreign module, while \
                                    libc::c_int or libc::c_long should be used");
             }
-            def::DefPrimTy(ast::TyUint(ast::TyU)) => {
+            def::DefPrimTy(ast::TyUint(ast::TyUs)) => {
                 self.cx.span_lint(IMPROPER_CTYPES, sp,
-                                  "found rust type `uint` in foreign module, while \
+                                  "found rust type `usize` in foreign module, while \
                                    libc::c_uint or libc::c_ulong should be used");
             }
             def::DefTy(..) => {
@@ -506,7 +506,7 @@ fn check_heap_type<'a, 'tcx>(&self, cx: &Context<'a, 'tcx>,
         if n_uniq > 0 {
             let s = ty_to_string(cx.tcx, ty);
             let m = format!("type uses owned (Box type) pointers: {}", s);
-            cx.span_lint(BOX_POINTERS, span, m[]);
+            cx.span_lint(BOX_POINTERS, span, m.index(&FullRange));
         }
     }
 }
@@ -586,7 +586,7 @@ fn get_lints(&self) -> LintArray {
     }
 
     fn check_item(&mut self, cx: &Context, item: &ast::Item) {
-        if !attr::contains_name(item.attrs[], "automatically_derived") {
+        if !attr::contains_name(item.attrs.index(&FullRange), "automatically_derived") {
             return
         }
         let did = match item.node {
@@ -669,6 +669,7 @@ fn check_attribute(&mut self, cx: &Context, attr: &ast::Attribute) {
 
             // FIXME: #19470 this shouldn't be needed forever
             "old_orphan_check",
+            "old_impl_check",
         ];
 
         static CRATE_ATTRS: &'static [&'static str] = &[
@@ -769,11 +770,11 @@ fn check_stmt(&mut self, cx: &Context, s: &ast::Stmt) {
             ty::ty_enum(did, _) => {
                 if ast_util::is_local(did) {
                     if let ast_map::NodeItem(it) = cx.tcx.map.get(did.node) {
-                        warned |= check_must_use(cx, it.attrs[], s.span);
+                        warned |= check_must_use(cx, it.attrs.index(&FullRange), s.span);
                     }
                 } else {
                     csearch::get_item_attrs(&cx.sess().cstore, did, |attrs| {
-                        warned |= check_must_use(cx, attrs[], s.span);
+                        warned |= check_must_use(cx, attrs.index(&FullRange), s.span);
                     });
                 }
             }
@@ -795,7 +796,7 @@ fn check_must_use(cx: &Context, attrs: &[ast::Attribute], sp: Span) -> bool {
                             msg.push_str(s.get());
                         }
                     }
-                    cx.span_lint(UNUSED_MUST_USE, sp, msg[]);
+                    cx.span_lint(UNUSED_MUST_USE, sp, msg.index(&FullRange));
                     return true;
                 }
             }
@@ -841,7 +842,7 @@ fn to_camel_case(s: &str) -> String {
             } else {
                 format!("{} `{}` should have a camel case name such as `{}`", sort, s, c)
             };
-            cx.span_lint(NON_CAMEL_CASE_TYPES, span, m[]);
+            cx.span_lint(NON_CAMEL_CASE_TYPES, span, m.index(&FullRange));
         }
     }
 }
@@ -981,7 +982,7 @@ fn to_snake_case(str: &str) -> String {
         if !is_snake_case(ident) {
             cx.span_lint(NON_SNAKE_CASE, span,
                 format!("{} `{}` should have a snake case name such as `{}`",
-                        sort, s, to_snake_case(s.get()))[]);
+                        sort, s, to_snake_case(s.get())).index(&FullRange));
         }
     }
 }
@@ -1068,7 +1069,7 @@ fn check_item(&mut self, cx: &Context, it: &ast::Item) {
                         format!("static constant `{}` should have an uppercase name \
                                  such as `{}`",
                                 s.get(), s.get().chars().map(|c| c.to_uppercase())
-                                .collect::<String>()[])[]);
+                                .collect::<String>().index(&FullRange)).index(&FullRange));
                 }
             }
             _ => {}
@@ -1085,7 +1086,7 @@ fn check_pat(&mut self, cx: &Context, p: &ast::Pat) {
                         format!("static constant in pattern `{}` should have an uppercase \
                                  name such as `{}`",
                                 s.get(), s.get().chars().map(|c| c.to_uppercase())
-                                    .collect::<String>()[])[]);
+                                    .collect::<String>().index(&FullRange)).index(&FullRange));
                 }
             }
             _ => {}
@@ -1110,7 +1111,7 @@ fn check_unused_parens_core(&self, cx: &Context, value: &ast::Expr, msg: &str,
             if !necessary {
                 cx.span_lint(UNUSED_PARENS, value.span,
                              format!("unnecessary parentheses around {}",
-                                     msg)[])
+                                     msg).index(&FullRange))
             }
         }
 
@@ -1212,7 +1213,7 @@ fn check_view_item(&mut self, cx: &Context, view_item: &ast::ViewItem) {
                                     let m = format!("braces around {} is unnecessary",
                                                     token::get_ident(*name).get());
                                     cx.span_lint(UNUSED_IMPORT_BRACES, view_item.span,
-                                                 m[]);
+                                                 m.index(&FullRange));
                                 },
                                 _ => ()
                             }
@@ -1251,7 +1252,7 @@ fn check_pat(&mut self, cx: &Context, pat: &ast::Pat) {
                     if ident.node.as_str() == fieldpat.node.ident.as_str() {
                         cx.span_lint(NON_SHORTHAND_FIELD_PATTERNS, fieldpat.span,
                                      format!("the `{}:` in this pattern is redundant and can \
-                                              be removed", ident.node.as_str())[])
+                                              be removed", ident.node.as_str()).index(&FullRange))
                     }
                 }
             }
@@ -1328,7 +1329,7 @@ fn check_unused_mut_pat(&self, cx: &Context, pats: &[P<ast::Pat>]) {
                 let ident = path1.node;
                 if let ast::BindByValue(ast::MutMutable) = mode {
                     if !token::get_ident(ident).get().starts_with("_") {
-                        match mutables.entry(&ident.name.uint()) {
+                        match mutables.entry(ident.name.uint()) {
                             Vacant(entry) => { entry.insert(vec![id]); },
                             Occupied(mut entry) => { entry.get_mut().push(id); },
                         }
@@ -1355,7 +1356,7 @@ fn get_lints(&self) -> LintArray {
     fn check_expr(&mut self, cx: &Context, e: &ast::Expr) {
         if let ast::ExprMatch(_, ref arms, _) = e.node {
             for a in arms.iter() {
-                self.check_unused_mut_pat(cx, a.pats[])
+                self.check_unused_mut_pat(cx, a.pats.index(&FullRange))
             }
         }
     }
@@ -1476,7 +1477,7 @@ fn check_missing_docs_attrs(&self,
         });
         if !has_doc {
             cx.span_lint(MISSING_DOCS, sp,
-                format!("missing documentation for {}", desc)[]);
+                format!("missing documentation for {}", desc).index(&FullRange));
         }
     }
 }
@@ -1490,7 +1491,7 @@ fn enter_lint_attrs(&mut self, _: &Context, attrs: &[ast::Attribute]) {
         let doc_hidden = self.doc_hidden() || attrs.iter().any(|attr| {
             attr.check_name("doc") && match attr.meta_item_list() {
                 None => false,
-                Some(l) => attr::contains_name(l[], "hidden"),
+                Some(l) => attr::contains_name(l.index(&FullRange), "hidden"),
             }
         });
         self.doc_hidden_stack.push(doc_hidden);
@@ -1512,7 +1513,7 @@ fn check_struct_def_post(&mut self, _: &Context,
     }
 
     fn check_crate(&mut self, cx: &Context, krate: &ast::Crate) {
-        self.check_missing_docs_attrs(cx, None, krate.attrs[],
+        self.check_missing_docs_attrs(cx, None, krate.attrs.index(&FullRange),
                                      krate.span, "crate");
     }
 
@@ -1526,7 +1527,7 @@ fn check_item(&mut self, cx: &Context, it: &ast::Item) {
             ast::ItemTy(..) => "a type alias",
             _ => return
         };
-        self.check_missing_docs_attrs(cx, Some(it.id), it.attrs[],
+        self.check_missing_docs_attrs(cx, Some(it.id), it.attrs.index(&FullRange),
                                      it.span, desc);
     }
 
@@ -1539,13 +1540,13 @@ fn check_fn(&mut self, cx: &Context,
 
             // Otherwise, doc according to privacy. This will also check
             // doc for default methods defined on traits.
-            self.check_missing_docs_attrs(cx, Some(m.id), m.attrs[],
+            self.check_missing_docs_attrs(cx, Some(m.id), m.attrs.index(&FullRange),
                                           m.span, "a method");
         }
     }
 
     fn check_ty_method(&mut self, cx: &Context, tm: &ast::TypeMethod) {
-        self.check_missing_docs_attrs(cx, Some(tm.id), tm.attrs[],
+        self.check_missing_docs_attrs(cx, Some(tm.id), tm.attrs.index(&FullRange),
                                      tm.span, "a type method");
     }
 
@@ -1555,14 +1556,14 @@ fn check_struct_field(&mut self, cx: &Context, sf: &ast::StructField) {
                 let cur_struct_def = *self.struct_def_stack.last()
                     .expect("empty struct_def_stack");
                 self.check_missing_docs_attrs(cx, Some(cur_struct_def),
-                                              sf.node.attrs[], sf.span,
+                                              sf.node.attrs.index(&FullRange), sf.span,
                                               "a struct field")
             }
         }
     }
 
     fn check_variant(&mut self, cx: &Context, v: &ast::Variant, _: &ast::Generics) {
-        self.check_missing_docs_attrs(cx, Some(v.node.id), v.node.attrs[],
+        self.check_missing_docs_attrs(cx, Some(v.node.id), v.node.attrs.index(&FullRange),
                                      v.span, "a variant");
         assert!(!self.in_variant);
         self.in_variant = true;
@@ -1629,7 +1630,6 @@ fn check_item(&mut self, cx: &Context, item: &ast::Item) {
     Warn,
     "detects use of #[deprecated] items"
 }
-
 // FIXME #6875: Change to Warn after std library stabilization is complete
 declare_lint! {
     EXPERIMENTAL,
@@ -1674,7 +1674,7 @@ fn lint(&self, cx: &Context, id: ast::DefId, span: Span) {
             _ => format!("use of {} item", label)
         };
 
-        cx.span_lint(lint, span, msg[]);
+        cx.span_lint(lint, span, msg.index(&FullRange));
     }
 
     fn is_internal(&self, cx: &Context, span: Span) -> bool {
@@ -1848,7 +1848,7 @@ fn check_item(&mut self, cx: &Context, item: &ast::Item) {
     "detects transmutes of fat pointers"
 }
 
-declare_lint!{
+declare_lint! {
     pub MISSING_COPY_IMPLEMENTATIONS,
     Warn,
     "detects potentially-forgotten implementations of `Copy`"
index 5c0fd8944368f60da86abc2a3a85b2860e3de174..51998bdbcf299dda29f9bcf011b4c3b051af0d67 100644 (file)
@@ -104,7 +104,7 @@ pub fn new() -> LintStore {
     }
 
     pub fn get_lints<'t>(&'t self) -> &'t [(&'static Lint, bool)] {
-        self.lints[]
+        self.lints.index(&FullRange)
     }
 
     pub fn get_lint_groups<'t>(&'t self) -> Vec<(&'static str, Vec<LintId>, bool)> {
@@ -124,11 +124,11 @@ pub fn register_pass(&mut self, sess: Option<&Session>,
                 match (sess, from_plugin) {
                     // We load builtin lints first, so a duplicate is a compiler bug.
                     // Use early_error when handling -W help with no crate.
-                    (None, _) => early_error(msg[]),
-                    (Some(sess), false) => sess.bug(msg[]),
+                    (None, _) => early_error(msg.index(&FullRange)),
+                    (Some(sess), false) => sess.bug(msg.index(&FullRange)),
 
                     // A duplicate name from a plugin is a user error.
-                    (Some(sess), true)  => sess.err(msg[]),
+                    (Some(sess), true)  => sess.err(msg.index(&FullRange)),
                 }
             }
 
@@ -149,11 +149,11 @@ pub fn register_group(&mut self, sess: Option<&Session>,
             match (sess, from_plugin) {
                 // We load builtin lints first, so a duplicate is a compiler bug.
                 // Use early_error when handling -W help with no crate.
-                (None, _) => early_error(msg[]),
-                (Some(sess), false) => sess.bug(msg[]),
+                (None, _) => early_error(msg.index(&FullRange)),
+                (Some(sess), false) => sess.bug(msg.index(&FullRange)),
 
                 // A duplicate name from a plugin is a user error.
-                (Some(sess), true)  => sess.err(msg[]),
+                (Some(sess), true)  => sess.err(msg.index(&FullRange)),
             }
         }
     }
@@ -267,8 +267,8 @@ fn find_lint(&self, lint_name: &str, sess: &Session, span: Option<Span>)
                 let warning = format!("lint {} has been renamed to {}",
                                       lint_name, new_name);
                 match span {
-                    Some(span) => sess.span_warn(span, warning[]),
-                    None => sess.warn(warning[]),
+                    Some(span) => sess.span_warn(span, warning.index(&FullRange)),
+                    None => sess.warn(warning.index(&FullRange)),
                 };
                 Some(lint_id)
             }
@@ -278,13 +278,13 @@ fn find_lint(&self, lint_name: &str, sess: &Session, span: Option<Span>)
 
     pub fn process_command_line(&mut self, sess: &Session) {
         for &(ref lint_name, level) in sess.opts.lint_opts.iter() {
-            match self.find_lint(lint_name[], sess, None) {
+            match self.find_lint(lint_name.index(&FullRange), sess, None) {
                 Some(lint_id) => self.set_level(lint_id, (level, CommandLine)),
                 None => {
                     match self.lint_groups.iter().map(|(&x, pair)| (x, pair.0.clone()))
                                                  .collect::<FnvHashMap<&'static str,
                                                                        Vec<LintId>>>()
-                                                 .get(lint_name[]) {
+                                                 .get(lint_name.index(&FullRange)) {
                         Some(v) => {
                             v.iter()
                              .map(|lint_id: &LintId|
@@ -292,7 +292,7 @@ pub fn process_command_line(&mut self, sess: &Session) {
                              .collect::<Vec<()>>();
                         }
                         None => sess.err(format!("unknown {} flag: {}",
-                                                 level.as_str(), lint_name)[]),
+                                                 level.as_str(), lint_name).index(&FullRange)),
                     }
                 }
             }
@@ -403,10 +403,10 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
     if level == Forbid { level = Deny; }
 
     match (level, span) {
-        (Warn, Some(sp)) => sess.span_warn(sp, msg[]),
-        (Warn, None)     => sess.warn(msg[]),
-        (Deny, Some(sp)) => sess.span_err(sp, msg[]),
-        (Deny, None)     => sess.err(msg[]),
+        (Warn, Some(sp)) => sess.span_warn(sp, msg.index(&FullRange)),
+        (Warn, None)     => sess.warn(msg.index(&FullRange)),
+        (Deny, Some(sp)) => sess.span_err(sp, msg.index(&FullRange)),
+        (Deny, None)     => sess.err(msg.index(&FullRange)),
         _ => sess.bug("impossible level in raw_emit_lint"),
     }
 
@@ -499,7 +499,7 @@ fn with_lint_attrs<F>(&mut self,
                                 None => {
                                     self.span_lint(builtin::UNKNOWN_LINTS, span,
                                                format!("unknown `{}` attribute: `{}`",
-                                                       level.as_str(), lint_name)[]);
+                                                       level.as_str(), lint_name).as_slice());
                                     continue;
                                 }
                             }
@@ -515,7 +515,7 @@ fn with_lint_attrs<F>(&mut self,
                     self.tcx.sess.span_err(span,
                                            format!("{}({}) overruled by outer forbid({})",
                                                    level.as_str(), lint_name,
-                                                   lint_name)[]);
+                                                   lint_name).index(&FullRange));
                 } else if now != level {
                     let src = self.lints.get_level_source(lint_id).1;
                     self.level_stack.push((lint_id, (now, src)));
@@ -550,7 +550,7 @@ fn visit_ids<F>(&mut self, f: F) where
 
 impl<'a, 'tcx, 'v> Visitor<'v> for Context<'a, 'tcx> {
     fn visit_item(&mut self, it: &ast::Item) {
-        self.with_lint_attrs(it.attrs[], |cx| {
+        self.with_lint_attrs(it.attrs.index(&FullRange), |cx| {
             run_lints!(cx, check_item, it);
             cx.visit_ids(|v| v.visit_item(it));
             visit::walk_item(cx, it);
@@ -558,14 +558,14 @@ fn visit_item(&mut self, it: &ast::Item) {
     }
 
     fn visit_foreign_item(&mut self, it: &ast::ForeignItem) {
-        self.with_lint_attrs(it.attrs[], |cx| {
+        self.with_lint_attrs(it.attrs.index(&FullRange), |cx| {
             run_lints!(cx, check_foreign_item, it);
             visit::walk_foreign_item(cx, it);
         })
     }
 
     fn visit_view_item(&mut self, i: &ast::ViewItem) {
-        self.with_lint_attrs(i.attrs[], |cx| {
+        self.with_lint_attrs(i.attrs.index(&FullRange), |cx| {
             run_lints!(cx, check_view_item, i);
             cx.visit_ids(|v| v.visit_view_item(i));
             visit::walk_view_item(cx, i);
@@ -591,7 +591,7 @@ fn visit_fn(&mut self, fk: FnKind<'v>, decl: &'v ast::FnDecl,
                 body: &'v ast::Block, span: Span, id: ast::NodeId) {
         match fk {
             visit::FkMethod(_, _, m) => {
-                self.with_lint_attrs(m.attrs[], |cx| {
+                self.with_lint_attrs(m.attrs.index(&FullRange), |cx| {
                     run_lints!(cx, check_fn, fk, decl, body, span, id);
                     cx.visit_ids(|v| {
                         v.visit_fn(fk, decl, body, span, id);
@@ -607,7 +607,7 @@ fn visit_fn(&mut self, fk: FnKind<'v>, decl: &'v ast::FnDecl,
     }
 
     fn visit_ty_method(&mut self, t: &ast::TypeMethod) {
-        self.with_lint_attrs(t.attrs[], |cx| {
+        self.with_lint_attrs(t.attrs.index(&FullRange), |cx| {
             run_lints!(cx, check_ty_method, t);
             visit::walk_ty_method(cx, t);
         })
@@ -624,14 +624,14 @@ fn visit_struct_def(&mut self,
     }
 
     fn visit_struct_field(&mut self, s: &ast::StructField) {
-        self.with_lint_attrs(s.node.attrs[], |cx| {
+        self.with_lint_attrs(s.node.attrs.index(&FullRange), |cx| {
             run_lints!(cx, check_struct_field, s);
             visit::walk_struct_field(cx, s);
         })
     }
 
     fn visit_variant(&mut self, v: &ast::Variant, g: &ast::Generics) {
-        self.with_lint_attrs(v.node.attrs[], |cx| {
+        self.with_lint_attrs(v.node.attrs.index(&FullRange), |cx| {
             run_lints!(cx, check_variant, v, g);
             visit::walk_variant(cx, v, g);
             run_lints!(cx, check_variant_post, v, g);
@@ -725,7 +725,7 @@ fn visit_id(&mut self, id: ast::NodeId) {
             None => {}
             Some(lints) => {
                 for (lint_id, span, msg) in lints.into_iter() {
-                    self.span_lint(lint_id.lint, span, msg[])
+                    self.span_lint(lint_id.lint, span, msg.index(&FullRange))
                 }
             }
         }
@@ -771,7 +771,7 @@ pub fn check_crate(tcx: &ty::ctxt,
     let mut cx = Context::new(tcx, krate, exported_items);
 
     // Visit the whole crate.
-    cx.with_lint_attrs(krate.attrs[], |cx| {
+    cx.with_lint_attrs(krate.attrs.index(&FullRange), |cx| {
         cx.visit_id(ast::CRATE_NODE_ID);
         cx.visit_ids(|v| {
             v.visited_outermost = true;
@@ -791,7 +791,7 @@ pub fn check_crate(tcx: &ty::ctxt,
         for &(lint, span, ref msg) in v.iter() {
             tcx.sess.span_bug(span,
                               format!("unprocessed lint {} at {}: {}",
-                                      lint.as_str(), tcx.map.node_to_string(*id), *msg)[])
+                                      lint.as_str(), tcx.map.node_to_string(*id), *msg).as_slice())
         }
     }
 
index b44520e28527b8e5c9e6772b54101fed0bed6a56..66967a735460fe8bca856b5d6d3597acb2a46ec0 100644 (file)
@@ -65,7 +65,8 @@ fn dump_crates(cstore: &CStore) {
 }
 
 fn should_link(i: &ast::ViewItem) -> bool {
-    !attr::contains_name(i.attrs[], "no_link")
+    !attr::contains_name(i.attrs.index(&FullRange), "no_link")
+
 }
 
 struct CrateInfo {
@@ -89,7 +90,7 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
     for c in s.chars() {
         if c.is_alphanumeric() { continue }
         if c == '_' || c == '-' { continue }
-        err(format!("invalid character `{}` in crate name: `{}`", c, s)[]);
+        err(format!("invalid character `{}` in crate name: `{}`", c, s).index(&FullRange));
     }
     match sess {
         Some(sess) => sess.abort_if_errors(),
@@ -97,6 +98,7 @@ pub fn validate_crate_name(sess: Option<&Session>, s: &str, sp: Option<Span>) {
     }
 }
 
+
 fn register_native_lib(sess: &Session,
                        span: Option<Span>,
                        name: String,
@@ -187,8 +189,8 @@ fn process_view_item(&mut self, i: &ast::ViewItem) {
         match self.extract_crate_info(i) {
             Some(info) => {
                 let (cnum, _, _) = self.resolve_crate(&None,
-                                                      info.ident[],
-                                                      info.name[],
+                                                      info.ident.index(&FullRange),
+                                                      info.name.index(&FullRange),
                                                       None,
                                                       i.span,
                                                       PathKind::Crate);
@@ -202,12 +204,12 @@ fn extract_crate_info(&self, i: &ast::ViewItem) -> Option<CrateInfo> {
         match i.node {
             ast::ViewItemExternCrate(ident, ref path_opt, id) => {
                 let ident = token::get_ident(ident);
-                debug!("resolving extern crate stmt. ident: {} path_opt: {}",
+                debug!("resolving extern crate stmt. ident: {} path_opt: {:?}",
                        ident, path_opt);
                 let name = match *path_opt {
                     Some((ref path_str, _)) => {
                         let name = path_str.get().to_string();
-                        validate_crate_name(Some(self.sess), name[],
+                        validate_crate_name(Some(self.sess), name.index(&FullRange),
                                             Some(i.span));
                         name
                     }
@@ -274,7 +276,7 @@ fn process_item(&self, i: &ast::Item) {
                                     } else {
                                         self.sess.span_err(m.span,
                                             format!("unknown kind: `{}`",
-                                                    k)[]);
+                                                    k).index(&FullRange));
                                         cstore::NativeUnknown
                                     }
                                 }
@@ -328,7 +330,7 @@ fn existing_match(&self, name: &str,
             match self.sess.opts.externs.get(name) {
                 Some(locs) => {
                     let found = locs.iter().any(|l| {
-                        let l = fs::realpath(&Path::new(l[])).ok();
+                        let l = fs::realpath(&Path::new(l.index(&FullRange))).ok();
                         l == source.dylib || l == source.rlib
                     });
                     if found {
@@ -407,7 +409,7 @@ fn resolve_crate(&mut self,
                     crate_name: name,
                     hash: hash.map(|a| &*a),
                     filesearch: self.sess.target_filesearch(kind),
-                    triple: self.sess.opts.target_triple[],
+                    triple: self.sess.opts.target_triple.index(&FullRange),
                     root: root,
                     rejected_via_hash: vec!(),
                     rejected_via_triple: vec!(),
@@ -433,8 +435,8 @@ fn resolve_crate_deps(&mut self,
         decoder::get_crate_deps(cdata).iter().map(|dep| {
             debug!("resolving dep crate {} hash: `{}`", dep.name, dep.hash);
             let (local_cnum, _, _) = self.resolve_crate(root,
-                                                   dep.name[],
-                                                   dep.name[],
+                                                   dep.name.index(&FullRange),
+                                                   dep.name.index(&FullRange),
                                                    Some(&dep.hash),
                                                    span,
                                                    PathKind::Dependency);
@@ -445,7 +447,7 @@ fn resolve_crate_deps(&mut self,
     pub fn read_plugin_metadata<'b>(&'b mut self,
                                     vi: &'b ast::ViewItem) -> PluginMetadata<'b> {
         let info = self.extract_crate_info(vi).unwrap();
-        let target_triple = self.sess.opts.target_triple[];
+        let target_triple = self.sess.opts.target_triple.index(&FullRange);
         let is_cross = target_triple != config::host_triple();
         let mut should_link = info.should_link && !is_cross;
         let mut target_only = false;
@@ -454,8 +456,8 @@ pub fn read_plugin_metadata<'b>(&'b mut self,
         let mut load_ctxt = loader::Context {
             sess: self.sess,
             span: vi.span,
-            ident: ident[],
-            crate_name: name[],
+            ident: ident.index(&FullRange),
+            crate_name: name.index(&FullRange),
             hash: None,
             filesearch: self.sess.host_filesearch(PathKind::Crate),
             triple: config::host_triple(),
@@ -480,11 +482,11 @@ pub fn read_plugin_metadata<'b>(&'b mut self,
         };
 
         let dylib = library.dylib.clone();
-        let register = should_link && self.existing_match(info.name[], None).is_none();
+        let register = should_link && self.existing_match(info.name.as_slice(), None).is_none();
         let metadata = if register {
             // Register crate now to avoid double-reading metadata
-            let (_, cmd, _) = self.register_crate(&None, info.ident[],
-                                info.name[], vi.span, library);
+            let (_, cmd, _) = self.register_crate(&None, info.ident.index(&FullRange),
+                                info.name.index(&FullRange), vi.span, library);
             PMDSource::Registered(cmd)
         } else {
             // Not registering the crate; just hold on to the metadata
@@ -505,8 +507,8 @@ pub fn read_plugin_metadata<'b>(&'b mut self,
 impl<'a> PluginMetadata<'a> {
     /// Read exported macros
     pub fn exported_macros(&self) -> Vec<ast::MacroDef> {
-        let imported_from = Some(token::intern(self.info.ident[]).ident());
-        let source_name = format!("<{} macros>", self.info.ident[]);
+        let imported_from = Some(token::intern(self.info.ident.index(&FullRange)).ident());
+        let source_name = format!("<{} macros>", self.info.ident.index(&FullRange));
         let mut macros = vec![];
         decoder::each_exported_macro(self.metadata.as_slice(),
                                      &*self.sess.cstore.intr,
@@ -548,7 +550,7 @@ pub fn plugin_registrar(&self) -> Option<(Path, String)> {
                                   self.info.ident,
                                   config::host_triple(),
                                   self.sess.opts.target_triple);
-            self.sess.span_err(self.vi_span, message[]);
+            self.sess.span_err(self.vi_span, message.index(&FullRange));
             self.sess.abort_if_errors();
         }
 
@@ -561,7 +563,7 @@ pub fn plugin_registrar(&self) -> Option<(Path, String)> {
                 let message = format!("plugin crate `{}` only found in rlib format, \
                                        but must be available in dylib format",
                                        self.info.ident);
-                self.sess.span_err(self.vi_span, message[]);
+                self.sess.span_err(self.vi_span, message.index(&FullRange));
                 // No need to abort because the loading code will just ignore this
                 // empty dylib.
                 None
index 1401a7d4a1a6ee564181a98153ee048d5875c3ad..72ce61b133a2bad37f32d9f3296b26c6ddc018f8 100644 (file)
@@ -95,7 +95,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[]))];
+    let mut r = vec![ast_map::PathMod(token::intern(cdata.name.index(&FullRange)))];
     r.push_all(path.as_slice());
     r
 }
@@ -246,13 +246,13 @@ pub fn get_field_type<'tcx>(tcx: &ty::ctxt<'tcx>, class_id: ast::DefId,
     let class_doc = expect(tcx.sess.diagnostic(),
                            decoder::maybe_find_item(class_id.node, all_items),
                            || {
-        (format!("get_field_type: class ID {} not found",
+        (format!("get_field_type: class ID {:?} not found",
                  class_id)).to_string()
     });
     let the_field = expect(tcx.sess.diagnostic(),
         decoder::maybe_find_item(def.node, class_doc),
         || {
-            (format!("get_field_type: in class {}, field ID {} not found",
+            (format!("get_field_type: in class {:?}, field ID {:?} not found",
                     class_id,
                     def)).to_string()
         });
index ed0a1f6211b16edd5cc56be5cf8c7321e340c51d..9e71c867efa09473242fd17cfcdc5a696bccbb74 100644 (file)
@@ -75,7 +75,7 @@ fn lookup_hash<'a, F>(d: rbml::Doc<'a>, mut eq_fn: F, hash: u64) -> Option<rbml:
     let mut ret = None;
     reader::tagged_docs(tagged_doc.doc, belt, |elt| {
         let pos = u64_from_be_bytes(elt.data, elt.start, 4) as uint;
-        if eq_fn(elt.data[elt.start + 4 .. elt.end]) {
+        if eq_fn(elt.data.index(&((elt.start + 4) .. elt.end))) {
             ret = Some(reader::doc_at(d.data, pos).unwrap().doc);
             false
         } else {
@@ -89,7 +89,7 @@ pub fn maybe_find_item<'a>(item_id: ast::NodeId,
                            items: rbml::Doc<'a>) -> Option<rbml::Doc<'a>> {
     fn eq_item(bytes: &[u8], item_id: ast::NodeId) -> bool {
         return u64_from_be_bytes(
-            bytes[0u..4u], 0u, 4u) as ast::NodeId
+            bytes.index(&(0u..4u)), 0u, 4u) as ast::NodeId
             == item_id;
     }
     lookup_hash(items,
@@ -675,14 +675,14 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &ty::ctxt<'tcx>, id: ast::NodeI
     debug!("Looking up item: {}", id);
     let item_doc = lookup_item(id, cdata.data());
     let path = item_path(item_doc).init().to_vec();
-    match decode_inlined_item.call_mut((cdata, tcx, path, item_doc)) {
+    match decode_inlined_item(cdata, tcx, path, item_doc) {
         Ok(ii) => csearch::found(ii),
         Err(path) => {
             match item_parent_item(item_doc) {
                 Some(did) => {
                     let did = translate_def_id(cdata, did);
                     let parent_item = lookup_item(did.node, cdata.data());
-                    match decode_inlined_item.call_mut((cdata, tcx, path, parent_item)) {
+                    match decode_inlined_item(cdata, tcx, path, parent_item) {
                         Ok(ii) => csearch::found_parent(did, ii),
                         Err(_) => csearch::not_found
                     }
@@ -1191,7 +1191,7 @@ fn docstr(doc: rbml::Doc, tag_: uint) -> String {
     }
     reader::tagged_docs(depsdoc, tag_crate_dep, |depdoc| {
         let name = docstr(depdoc, tag_crate_dep_crate_name);
-        let hash = Svh::new(docstr(depdoc, tag_crate_dep_hash)[]);
+        let hash = Svh::new(docstr(depdoc, tag_crate_dep_hash).index(&FullRange));
         deps.push(CrateDep {
             cnum: crate_num,
             name: name,
index b762f58685ded50f890cf542ea069b8a1a9b60a4..83038df338b2dc508d095d50b25751c9fa3d766e 100644 (file)
@@ -95,7 +95,7 @@ fn encode_impl_type_basename(rbml_w: &mut Encoder, name: ast::Ident) {
 }
 
 pub fn encode_def_id(rbml_w: &mut Encoder, id: DefId) {
-    rbml_w.wr_tagged_str(tag_def_id, def_to_string(id)[]);
+    rbml_w.wr_tagged_str(tag_def_id, def_to_string(id).index(&FullRange));
 }
 
 #[derive(Clone)]
@@ -154,7 +154,7 @@ fn encode_variant_id(rbml_w: &mut Encoder, vid: DefId) {
     rbml_w.end_tag();
 
     rbml_w.start_tag(tag_mod_child);
-    rbml_w.wr_str(s[]);
+    rbml_w.wr_str(s.index(&FullRange));
     rbml_w.end_tag();
 }
 
@@ -264,7 +264,7 @@ fn encode_symbol(ecx: &EncodeContext,
         }
         None => {
             ecx.diag.handler().bug(
-                format!("encode_symbol: id not found {}", id)[]);
+                format!("encode_symbol: id not found {}", id).index(&FullRange));
         }
     }
     rbml_w.end_tag();
@@ -332,8 +332,8 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
         encode_name(rbml_w, variant.node.name.name);
         encode_parent_item(rbml_w, local_def(id));
         encode_visibility(rbml_w, variant.node.vis);
-        encode_attributes(rbml_w, variant.node.attrs[]);
-        encode_repr_attrs(rbml_w, ecx, variant.node.attrs[]);
+        encode_attributes(rbml_w, variant.node.attrs.index(&FullRange));
+        encode_repr_attrs(rbml_w, ecx, variant.node.attrs.index(&FullRange));
 
         let stab = stability::lookup(ecx.tcx, ast_util::local_def(variant.node.id));
         encode_stability(rbml_w, stab);
@@ -344,9 +344,9 @@ fn encode_enum_variant_info(ecx: &EncodeContext,
                 let fields = ty::lookup_struct_fields(ecx.tcx, def_id);
                 let idx = encode_info_for_struct(ecx,
                                                  rbml_w,
-                                                 fields[],
+                                                 fields.index(&FullRange),
                                                  index);
-                encode_struct_fields(rbml_w, fields[], def_id);
+                encode_struct_fields(rbml_w, fields.index(&FullRange), def_id);
                 encode_index(rbml_w, idx, write_i64);
             }
         }
@@ -386,12 +386,12 @@ fn encode_reexported_static_method(rbml_w: &mut Encoder,
             exp.name, token::get_name(method_name));
     rbml_w.start_tag(tag_items_data_item_reexport);
     rbml_w.start_tag(tag_items_data_item_reexport_def_id);
-    rbml_w.wr_str(def_to_string(method_def_id)[]);
+    rbml_w.wr_str(def_to_string(method_def_id).index(&FullRange));
     rbml_w.end_tag();
     rbml_w.start_tag(tag_items_data_item_reexport_name);
     rbml_w.wr_str(format!("{}::{}",
                           exp.name,
-                          token::get_name(method_name))[]);
+                          token::get_name(method_name)).index(&FullRange));
     rbml_w.end_tag();
     rbml_w.end_tag();
 }
@@ -529,7 +529,7 @@ fn encode_reexports(ecx: &EncodeContext,
                        id);
                 rbml_w.start_tag(tag_items_data_item_reexport);
                 rbml_w.start_tag(tag_items_data_item_reexport_def_id);
-                rbml_w.wr_str(def_to_string(exp.def_id)[]);
+                rbml_w.wr_str(def_to_string(exp.def_id).index(&FullRange));
                 rbml_w.end_tag();
                 rbml_w.start_tag(tag_items_data_item_reexport_name);
                 rbml_w.wr_str(exp.name.as_str());
@@ -562,13 +562,13 @@ fn encode_info_for_mod(ecx: &EncodeContext,
     // Encode info about all the module children.
     for item in md.items.iter() {
         rbml_w.start_tag(tag_mod_child);
-        rbml_w.wr_str(def_to_string(local_def(item.id))[]);
+        rbml_w.wr_str(def_to_string(local_def(item.id)).index(&FullRange));
         rbml_w.end_tag();
 
         each_auxiliary_node_id(&**item, |auxiliary_node_id| {
             rbml_w.start_tag(tag_mod_child);
             rbml_w.wr_str(def_to_string(local_def(
-                        auxiliary_node_id))[]);
+                        auxiliary_node_id)).index(&FullRange));
             rbml_w.end_tag();
             true
         });
@@ -580,7 +580,7 @@ fn encode_info_for_mod(ecx: &EncodeContext,
                    did, ecx.tcx.map.node_to_string(did));
 
             rbml_w.start_tag(tag_mod_impl);
-            rbml_w.wr_str(def_to_string(local_def(did))[]);
+            rbml_w.wr_str(def_to_string(local_def(did)).index(&FullRange));
             rbml_w.end_tag();
         }
     }
@@ -615,7 +615,7 @@ fn encode_visibility(rbml_w: &mut Encoder, visibility: ast::Visibility) {
         ast::Public => 'y',
         ast::Inherited => 'i',
     };
-    rbml_w.wr_str(ch.to_string()[]);
+    rbml_w.wr_str(ch.to_string().index(&FullRange));
     rbml_w.end_tag();
 }
 
@@ -627,7 +627,7 @@ fn encode_unboxed_closure_kind(rbml_w: &mut Encoder,
         ty::FnMutUnboxedClosureKind => 'm',
         ty::FnOnceUnboxedClosureKind => 'o',
     };
-    rbml_w.wr_str(ch.to_string()[]);
+    rbml_w.wr_str(ch.to_string().index(&FullRange));
     rbml_w.end_tag();
 }
 
@@ -788,7 +788,7 @@ fn encode_generics<'a, 'tcx>(rbml_w: &mut Encoder,
         rbml_w.end_tag();
 
         rbml_w.wr_tagged_str(tag_region_param_def_def_id,
-                             def_to_string(param.def_id)[]);
+                             def_to_string(param.def_id).index(&FullRange));
 
         rbml_w.wr_tagged_u64(tag_region_param_def_space,
                              param.space.to_uint() as u64);
@@ -845,7 +845,7 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
                                     parent_id: NodeId,
                                     ast_item_opt: Option<&ast::ImplItem>) {
 
-    debug!("encode_info_for_method: {} {}", m.def_id,
+    debug!("encode_info_for_method: {:?} {:?}", m.def_id,
            token::get_name(m.name));
     rbml_w.start_tag(tag_items_data_item);
 
@@ -864,9 +864,9 @@ fn encode_info_for_method<'a, 'tcx>(ecx: &EncodeContext<'a, 'tcx>,
     encode_path(rbml_w, impl_path.chain(Some(elem).into_iter()));
     match ast_item_opt {
         Some(&ast::MethodImplItem(ref ast_method)) => {
-            encode_attributes(rbml_w, ast_method.attrs[]);
+            encode_attributes(rbml_w, ast_method.attrs.index(&FullRange));
             let any_types = !pty.generics.types.is_empty();
-            if any_types || is_default_impl || should_inline(ast_method.attrs[]) {
+            if any_types || is_default_impl || should_inline(ast_method.attrs.index(&FullRange)) {
                 encode_inlined_item(ecx, rbml_w, IIImplItemRef(local_def(parent_id),
                                                                ast_item_opt.unwrap()));
             }
@@ -887,7 +887,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
                                    impl_path: PathElems,
                                    parent_id: NodeId,
                                    typedef_opt: Option<P<ast::Typedef>>) {
-    debug!("encode_info_for_associated_type({},{})",
+    debug!("encode_info_for_associated_type({:?},{:?})",
            associated_type.def_id,
            token::get_name(associated_type.name));
 
@@ -912,7 +912,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext,
     match typedef_opt {
         None => {}
         Some(typedef) => {
-            encode_attributes(rbml_w, typedef.attrs[]);
+            encode_attributes(rbml_w, typedef.attrs.index(&FullRange));
             encode_type(ecx, rbml_w, ty::node_id_to_type(ecx.tcx,
                                                          typedef.id));
         }
@@ -953,7 +953,7 @@ fn encode_inlined_item(ecx: &EncodeContext,
                        ii: InlinedItemRef) {
     let mut eii = ecx.encode_inlined_item.borrow_mut();
     let eii: &mut EncodeInlinedItem = &mut *eii;
-    eii.call_mut((ecx, rbml_w, ii))
+    eii(ecx, rbml_w, ii)
 }
 
 const FN_FAMILY: char = 'f';
@@ -1046,7 +1046,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         encode_path(rbml_w, path);
         encode_visibility(rbml_w, vis);
         encode_stability(rbml_w, stab);
-        encode_attributes(rbml_w, item.attrs[]);
+        encode_attributes(rbml_w, item.attrs.index(&FullRange));
         rbml_w.end_tag();
       }
       ast::ItemConst(_, _) => {
@@ -1072,8 +1072,8 @@ 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[]);
-        if tps_len > 0u || should_inline(item.attrs[]) {
+        encode_attributes(rbml_w, item.attrs.index(&FullRange));
+        if tps_len > 0u || should_inline(item.attrs.index(&FullRange)) {
             encode_inlined_item(ecx, rbml_w, IIItemRef(item));
         }
         if tps_len == 0 {
@@ -1089,7 +1089,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         encode_info_for_mod(ecx,
                             rbml_w,
                             m,
-                            item.attrs[],
+                            item.attrs.index(&FullRange),
                             item.id,
                             path,
                             item.ident,
@@ -1106,7 +1106,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         // Encode all the items in this module.
         for foreign_item in fm.items.iter() {
             rbml_w.start_tag(tag_mod_child);
-            rbml_w.wr_str(def_to_string(local_def(foreign_item.id))[]);
+            rbml_w.wr_str(def_to_string(local_def(foreign_item.id)).index(&FullRange));
             rbml_w.end_tag();
         }
         encode_visibility(rbml_w, vis);
@@ -1134,8 +1134,8 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         encode_item_variances(rbml_w, ecx, item.id);
         encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
         encode_name(rbml_w, item.ident.name);
-        encode_attributes(rbml_w, item.attrs[]);
-        encode_repr_attrs(rbml_w, ecx, item.attrs[]);
+        encode_attributes(rbml_w, item.attrs.index(&FullRange));
+        encode_repr_attrs(rbml_w, ecx, item.attrs.index(&FullRange));
         for v in (*enum_definition).variants.iter() {
             encode_variant_id(rbml_w, local_def(v.node.id));
         }
@@ -1152,7 +1152,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         encode_enum_variant_info(ecx,
                                  rbml_w,
                                  item.id,
-                                 (*enum_definition).variants[],
+                                 (*enum_definition).variants.index(&FullRange),
                                  index);
       }
       ast::ItemStruct(ref struct_def, _) => {
@@ -1164,7 +1164,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
            class itself */
         let idx = encode_info_for_struct(ecx,
                                          rbml_w,
-                                         fields[],
+                                         fields.index(&FullRange),
                                          index);
 
         /* Index the class*/
@@ -1178,16 +1178,16 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
 
         encode_item_variances(rbml_w, ecx, item.id);
         encode_name(rbml_w, item.ident.name);
-        encode_attributes(rbml_w, item.attrs[]);
+        encode_attributes(rbml_w, item.attrs.index(&FullRange));
         encode_path(rbml_w, path.clone());
         encode_stability(rbml_w, stab);
         encode_visibility(rbml_w, vis);
-        encode_repr_attrs(rbml_w, ecx, item.attrs[]);
+        encode_repr_attrs(rbml_w, ecx, item.attrs.index(&FullRange));
 
         /* Encode def_ids for each field and method
          for methods, write all the stuff get_trait_method
         needs to know*/
-        encode_struct_fields(rbml_w, fields[], def_id);
+        encode_struct_fields(rbml_w, fields.index(&FullRange), def_id);
 
         encode_inlined_item(ecx, rbml_w, IIItemRef(item));
 
@@ -1219,7 +1219,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         encode_family(rbml_w, 'i');
         encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(tcx, def_id));
         encode_name(rbml_w, item.ident.name);
-        encode_attributes(rbml_w, item.attrs[]);
+        encode_attributes(rbml_w, item.attrs.index(&FullRange));
         encode_unsafety(rbml_w, unsafety);
         encode_polarity(rbml_w, polarity);
         match ty.node {
@@ -1323,7 +1323,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
         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);
-        encode_attributes(rbml_w, item.attrs[]);
+        encode_attributes(rbml_w, item.attrs.index(&FullRange));
         encode_visibility(rbml_w, vis);
         encode_stability(rbml_w, stab);
         for &method_def_id in ty::trait_item_def_ids(tcx, def_id).iter() {
@@ -1341,7 +1341,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
             rbml_w.end_tag();
 
             rbml_w.start_tag(tag_mod_child);
-            rbml_w.wr_str(def_to_string(method_def_id.def_id())[]);
+            rbml_w.wr_str(def_to_string(method_def_id.def_id()).index(&FullRange));
             rbml_w.end_tag();
         }
         encode_path(rbml_w, path.clone());
@@ -1433,14 +1433,14 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
             };
             match trait_item {
                 &ast::RequiredMethod(ref m) => {
-                    encode_attributes(rbml_w, m.attrs[]);
+                    encode_attributes(rbml_w, m.attrs.index(&FullRange));
                     encode_trait_item(rbml_w);
                     encode_item_sort(rbml_w, 'r');
                     encode_method_argument_names(rbml_w, &*m.decl);
                 }
 
                 &ast::ProvidedMethod(ref m) => {
-                    encode_attributes(rbml_w, m.attrs[]);
+                    encode_attributes(rbml_w, m.attrs.index(&FullRange));
                     encode_trait_item(rbml_w);
                     encode_item_sort(rbml_w, 'p');
                     encode_inlined_item(ecx, rbml_w, IITraitItemRef(def_id, trait_item));
@@ -1449,7 +1449,7 @@ fn add_to_index(item: &ast::Item, rbml_w: &Encoder,
 
                 &ast::TypeTraitItem(ref associated_type) => {
                     encode_attributes(rbml_w,
-                                      associated_type.attrs[]);
+                                      associated_type.attrs.index(&FullRange));
                     encode_item_sort(rbml_w, 't');
                 }
             }
@@ -1603,7 +1603,7 @@ fn encode_index<T, F>(rbml_w: &mut Encoder, index: Vec<entry<T>>, mut write_fn:
     let mut buckets: Vec<Vec<entry<T>>> = range(0, 256u16).map(|_| Vec::new()).collect();
     for elt in index.into_iter() {
         let h = hash::hash(&elt.val) as uint;
-        buckets[h % 256].push(elt);
+        (&mut buckets[h % 256]).push(elt);
     }
 
     rbml_w.start_tag(tag_index);
@@ -1826,10 +1826,10 @@ fn encode_macro_defs(rbml_w: &mut Encoder,
         rbml_w.start_tag(tag_macro_def);
 
         encode_name(rbml_w, def.ident.name);
-        encode_attributes(rbml_w, def.attrs[]);
+        encode_attributes(rbml_w, def.attrs.index(&FullRange));
 
         rbml_w.start_tag(tag_macro_def_body);
-        rbml_w.wr_str(pprust::tts_to_string(def.body[])[]);
+        rbml_w.wr_str(pprust::tts_to_string(def.body.index(&FullRange)).index(&FullRange));
         rbml_w.end_tag();
 
         rbml_w.end_tag();
@@ -1869,7 +1869,7 @@ impl<'a, 'b, 'v> Visitor<'v> for StructFieldVisitor<'a, 'b> {
         fn visit_struct_field(&mut self, field: &ast::StructField) {
             self.rbml_w.start_tag(tag_struct_field);
             self.rbml_w.wr_tagged_u32(tag_struct_field_id, field.node.id);
-            encode_attributes(self.rbml_w, field.node.attrs[]);
+            encode_attributes(self.rbml_w, field.node.attrs.index(&FullRange));
             self.rbml_w.end_tag();
         }
     }
@@ -1941,13 +1941,13 @@ fn encode_misc_info(ecx: &EncodeContext,
     rbml_w.start_tag(tag_misc_info_crate_items);
     for item in krate.module.items.iter() {
         rbml_w.start_tag(tag_mod_child);
-        rbml_w.wr_str(def_to_string(local_def(item.id))[]);
+        rbml_w.wr_str(def_to_string(local_def(item.id)).index(&FullRange));
         rbml_w.end_tag();
 
         each_auxiliary_node_id(&**item, |auxiliary_node_id| {
             rbml_w.start_tag(tag_mod_child);
             rbml_w.wr_str(def_to_string(local_def(
-                        auxiliary_node_id))[]);
+                        auxiliary_node_id)).index(&FullRange));
             rbml_w.end_tag();
             true
         });
@@ -2116,17 +2116,17 @@ struct Stats {
 
     let mut rbml_w = writer::Encoder::new(wr);
 
-    encode_crate_name(&mut rbml_w, ecx.link_meta.crate_name[]);
+    encode_crate_name(&mut rbml_w, ecx.link_meta.crate_name.index(&FullRange));
     encode_crate_triple(&mut rbml_w,
                         tcx.sess
                            .opts
                            .target_triple
-                           []);
+                           .index(&FullRange));
     encode_hash(&mut rbml_w, &ecx.link_meta.crate_hash);
     encode_dylib_dependency_formats(&mut rbml_w, &ecx);
 
     let mut i = rbml_w.writer.tell().unwrap();
-    encode_attributes(&mut rbml_w, krate.attrs[]);
+    encode_attributes(&mut rbml_w, krate.attrs.index(&FullRange));
     stats.attr_bytes = rbml_w.writer.tell().unwrap() - i;
 
     i = rbml_w.writer.tell().unwrap();
index 7c0645b4ca204037c451ef1c62f6232a7c547360..0fa9472287caa05440fc6dff03f1ba5ee73bbe69 100644 (file)
@@ -315,14 +315,14 @@ pub fn report_load_errs(&mut self) {
             &Some(ref r) => format!("{} which `{}` depends on",
                                     message, r.ident)
         };
-        self.sess.span_err(self.span, message[]);
+        self.sess.span_err(self.span, message.index(&FullRange));
 
         if self.rejected_via_triple.len() > 0 {
             let mismatches = self.rejected_via_triple.iter();
             for (i, &CrateMismatch{ ref path, ref got }) in mismatches.enumerate() {
                 self.sess.fileline_note(self.span,
                     format!("crate `{}`, path #{}, triple {}: {}",
-                            self.ident, i+1, got, path.display())[]);
+                            self.ident, i+1, got, path.display()).index(&FullRange));
             }
         }
         if self.rejected_via_hash.len() > 0 {
@@ -332,7 +332,7 @@ pub fn report_load_errs(&mut self) {
             for (i, &CrateMismatch{ ref path, .. }) in mismatches.enumerate() {
                 self.sess.fileline_note(self.span,
                     format!("crate `{}` path {}{}: {}",
-                            self.ident, "#", i+1, path.display())[]);
+                            self.ident, "#", i+1, path.display()).index(&FullRange));
             }
             match self.root {
                 &None => {}
@@ -340,7 +340,7 @@ pub fn report_load_errs(&mut self) {
                     for (i, path) in r.paths().iter().enumerate() {
                         self.sess.fileline_note(self.span,
                             format!("crate `{}` path #{}: {}",
-                                    r.ident, i+1, path.display())[]);
+                                    r.ident, i+1, path.display()).index(&FullRange));
                     }
                 }
             }
@@ -386,7 +386,7 @@ fn find_library_crate(&mut self) -> Option<Library> {
                 None => return FileDoesntMatch,
                 Some(file) => file,
             };
-            let (hash, rlib) = if file.starts_with(rlib_prefix[]) &&
+            let (hash, rlib) = if file.starts_with(rlib_prefix.index(&FullRange)) &&
                     file.ends_with(".rlib") {
                 (file.slice(rlib_prefix.len(), file.len() - ".rlib".len()),
                  true)
@@ -400,7 +400,7 @@ fn find_library_crate(&mut self) -> Option<Library> {
             info!("lib candidate: {}", path.display());
 
             let hash_str = hash.to_string();
-            let slot = candidates.entry(&hash_str).get().unwrap_or_else(
+            let slot = candidates.entry(hash_str).get().unwrap_or_else(
                 |vacant_entry| vacant_entry.insert((HashSet::new(), HashSet::new())));
             let (ref mut rlibs, ref mut dylibs) = *slot;
             if rlib {
@@ -446,26 +446,26 @@ fn find_library_crate(&mut self) -> Option<Library> {
             _ => {
                 self.sess.span_err(self.span,
                     format!("multiple matching crates for `{}`",
-                            self.crate_name)[]);
+                            self.crate_name).index(&FullRange));
                 self.sess.note("candidates:");
                 for lib in libraries.iter() {
                     match lib.dylib {
                         Some(ref p) => {
                             self.sess.note(format!("path: {}",
-                                                   p.display())[]);
+                                                   p.display()).index(&FullRange));
                         }
                         None => {}
                     }
                     match lib.rlib {
                         Some(ref p) => {
                             self.sess.note(format!("path: {}",
-                                                   p.display())[]);
+                                                   p.display()).index(&FullRange));
                         }
                         None => {}
                     }
                     let data = lib.metadata.as_slice();
                     let name = decoder::get_crate_name(data);
-                    note_crate_name(self.sess.diagnostic(), name[]);
+                    note_crate_name(self.sess.diagnostic(), name.index(&FullRange));
                 }
                 None
             }
@@ -519,11 +519,11 @@ fn extract_one(&mut self, m: HashSet<Path>, flavor: &str,
                                    format!("multiple {} candidates for `{}` \
                                             found",
                                            flavor,
-                                           self.crate_name)[]);
+                                           self.crate_name).index(&FullRange));
                 self.sess.span_note(self.span,
                                     format!(r"candidate #1: {}",
                                             ret.as_ref().unwrap()
-                                               .display())[]);
+                                               .display()).index(&FullRange));
                 error = 1;
                 ret = None;
             }
@@ -531,7 +531,7 @@ fn extract_one(&mut self, m: HashSet<Path>, flavor: &str,
                 error += 1;
                 self.sess.span_note(self.span,
                                     format!(r"candidate #{}: {}", error,
-                                            lib.display())[]);
+                                            lib.display()).index(&FullRange));
                 continue
             }
             *slot = Some(metadata);
@@ -606,17 +606,17 @@ fn find_commandline_library(&mut self) -> Option<Library> {
         let mut rlibs = HashSet::new();
         let mut dylibs = HashSet::new();
         {
-            let mut locs = locs.iter().map(|l| Path::new(l[])).filter(|loc| {
+            let mut locs = locs.iter().map(|l| Path::new(l.index(&FullRange))).filter(|loc| {
                 if !loc.exists() {
                     sess.err(format!("extern location for {} does not exist: {}",
-                                     self.crate_name, loc.display())[]);
+                                     self.crate_name, loc.display()).index(&FullRange));
                     return false;
                 }
                 let file = match loc.filename_str() {
                     Some(file) => file,
                     None => {
                         sess.err(format!("extern location for {} is not a file: {}",
-                                         self.crate_name, loc.display())[]);
+                                         self.crate_name, loc.display()).index(&FullRange));
                         return false;
                     }
                 };
@@ -624,12 +624,13 @@ fn find_commandline_library(&mut self) -> Option<Library> {
                     return true
                 } else {
                     let (ref prefix, ref suffix) = dylibname;
-                    if file.starts_with(prefix[]) && file.ends_with(suffix[]) {
+                    if file.starts_with(prefix.index(&FullRange)) &&
+                       file.ends_with(suffix.index(&FullRange)) {
                         return true
                     }
                 }
                 sess.err(format!("extern location for {} is of an unknown type: {}",
-                                 self.crate_name, loc.display())[]);
+                                 self.crate_name, loc.display()).index(&FullRange));
                 false
             });
 
@@ -662,7 +663,7 @@ fn find_commandline_library(&mut self) -> Option<Library> {
 }
 
 pub fn note_crate_name(diag: &SpanHandler, name: &str) {
-    diag.handler().note(format!("crate name: {}", name)[]);
+    diag.handler().note(format!("crate name: {}", name).index(&FullRange));
 }
 
 impl ArchiveMetadata {
index 07dc13ff0d48f6e3b782bb1bbf858b57f935359c..a4304bf1e2d62a7d7918c9dbc003d57eb746a76b 100644 (file)
@@ -98,7 +98,7 @@ fn scan<R, F, G>(st: &mut PState, mut is_last: F, op: G) -> R where
     }
     let end_pos = st.pos;
     st.pos += 1;
-    return op(st.data[start_pos..end_pos]);
+    return op(st.data.index(&(start_pos..end_pos)));
 }
 
 pub fn parse_ident(st: &mut PState, last: char) -> ast::Ident {
@@ -251,7 +251,7 @@ fn parse_trait_store_<F>(st: &mut PState, conv: &mut F) -> ty::TraitStore where
         '&' => ty::RegionTraitStore(parse_region_(st, conv), parse_mutability(st)),
         c => {
             st.tcx.sess.bug(format!("parse_trait_store(): bad input '{}'",
-                                    c)[])
+                                    c).index(&FullRange))
         }
     }
 }
@@ -318,7 +318,7 @@ fn parse_bound_region_<F>(st: &mut PState, conv: &mut F) -> ty::BoundRegion wher
         }
         '[' => {
             let def = parse_def_(st, RegionParameter, conv);
-            let ident = token::str_to_ident(parse_str(st, ']')[]);
+            let ident = token::str_to_ident(parse_str(st, ']').index(&FullRange));
             ty::BrNamed(def, ident.name)
         }
         'f' => {
@@ -357,7 +357,7 @@ fn parse_region_<F>(st: &mut PState, conv: &mut F) -> ty::Region where
         assert_eq!(next(st), '|');
         let index = parse_u32(st);
         assert_eq!(next(st), '|');
-        let nm = token::str_to_ident(parse_str(st, ']')[]);
+        let nm = token::str_to_ident(parse_str(st, ']').index(&FullRange));
         ty::ReEarlyBound(node_id, space, index, nm.name)
       }
       'f' => {
@@ -443,8 +443,8 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
     let tcx = st.tcx;
     match next(st) {
       'b' => return tcx.types.bool,
-      'i' => return tcx.types.int,
-      'u' => return tcx.types.uint,
+      'i' => { /* eat the s of is */ next(st); return tcx.types.int },
+      'u' => { /* eat the s of us */ next(st); return tcx.types.uint },
       'M' => {
         match next(st) {
           'b' => return tcx.types.u8,
@@ -481,7 +481,7 @@ fn parse_ty_<'a, 'tcx, F>(st: &mut PState<'a, 'tcx>, conv: &mut F) -> Ty<'tcx> w
         assert_eq!(next(st), '|');
         let space = parse_param_space(st);
         assert_eq!(next(st), '|');
-        let name = token::intern(parse_str(st, ']')[]);
+        let name = token::intern(parse_str(st, ']').index(&FullRange));
         return ty::mk_param(tcx, space, index, name);
       }
       '~' => return ty::mk_uniq(tcx, parse_ty_(st, conv)),
@@ -637,7 +637,7 @@ fn parse_abi_set(st: &mut PState) -> abi::Abi {
     assert_eq!(next(st), '[');
     scan(st, |c| c == ']', |bytes| {
         let abi_str = str::from_utf8(bytes).unwrap();
-        abi::lookup(abi_str[]).expect(abi_str)
+        abi::lookup(abi_str.index(&FullRange)).expect(abi_str)
     })
 }
 
@@ -733,17 +733,17 @@ pub fn parse_def_id(buf: &[u8]) -> ast::DefId {
         panic!();
     }
 
-    let crate_part = buf[0u..colon_idx];
-    let def_part = buf[colon_idx + 1u..len];
+    let crate_part = buf.index(&(0u..colon_idx));
+    let def_part = buf.index(&((colon_idx + 1u)..len));
 
     let crate_num = match str::from_utf8(crate_part).ok().and_then(|s| s.parse::<uint>()) {
        Some(cn) => cn as ast::CrateNum,
-       None => panic!("internal error: parse_def_id: crate number expected, found {}",
+       None => panic!("internal error: parse_def_id: crate number expected, found {:?}",
                      crate_part)
     };
     let def_num = match str::from_utf8(def_part).ok().and_then(|s| s.parse::<uint>()) {
        Some(dn) => dn as ast::NodeId,
-       None => panic!("internal error: parse_def_id: id expected, found {}",
+       None => panic!("internal error: parse_def_id: id expected, found {:?}",
                      def_part)
     };
     ast::DefId { krate: crate_num, node: def_num }
index 0042209aced6ad4e17d1392c72e374e9d35f8f34..c019d129218b659ea878992351cb223157ca4742 100644 (file)
@@ -61,7 +61,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
         ty::ty_char => mywrite!(w, "c"),
         ty::ty_int(t) => {
             match t {
-                ast::TyI => mywrite!(w, "i"),
+                ast::TyIs => mywrite!(w, "is"),
                 ast::TyI8 => mywrite!(w, "MB"),
                 ast::TyI16 => mywrite!(w, "MW"),
                 ast::TyI32 => mywrite!(w, "ML"),
@@ -70,7 +70,7 @@ pub fn enc_ty<'a, 'tcx>(w: &mut SeekableMemWriter, cx: &ctxt<'a, 'tcx>, t: Ty<'t
         }
         ty::ty_uint(t) => {
             match t {
-                ast::TyU => mywrite!(w, "u"),
+                ast::TyUs => mywrite!(w, "us"),
                 ast::TyU8 => mywrite!(w, "Mb"),
                 ast::TyU16 => mywrite!(w, "Mw"),
                 ast::TyU32 => mywrite!(w, "Ml"),
index b2ad77467276f8e38fa676a2424bfd34cd2a0096..955f522b8041b36dfe2b2694ab530cab157c7618 100644 (file)
@@ -48,7 +48,7 @@ pub fn ast_ty_to_prim_ty<'tcx>(tcx: &ty::ctxt<'tcx>, ast_ty: &ast::Ty)
                 None => {
                     tcx.sess.span_bug(ast_ty.span,
                                       format!("unbound path {}",
-                                              path.repr(tcx))[])
+                                              path.repr(tcx)).index(&FullRange))
                 }
                 Some(&d) => d
             };
index 93a19a01f668fb26d65d2b8b07ba29c40dfed7fd..32ce131c57a3cb1eab725ae13c5df991e405505c 100644 (file)
@@ -82,7 +82,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext,
         e::IIImplItemRef(_, &ast::MethodImplItem(ref m)) => m.id,
         e::IIImplItemRef(_, &ast::TypeImplItem(ref ti)) => ti.id,
     };
-    debug!("> Encoding inlined item: {} ({})",
+    debug!("> Encoding inlined item: {} ({:?})",
            ecx.tcx.map.path_to_string(id),
            rbml_w.writer.tell());
 
@@ -96,7 +96,7 @@ pub fn encode_inlined_item(ecx: &e::EncodeContext,
     encode_side_tables_for_ii(ecx, rbml_w, &ii);
     rbml_w.end_tag();
 
-    debug!("< Encoded inlined fn: {} ({})",
+    debug!("< Encoded inlined fn: {} ({:?})",
            ecx.tcx.map.path_to_string(id),
            rbml_w.writer.tell());
 }
@@ -127,12 +127,12 @@ pub fn decode_inlined_item<'tcx>(cdata: &cstore::crate_metadata,
       None => Err(path),
       Some(ast_doc) => {
         let mut path_as_str = None;
-        debug!("> Decoding inlined fn: {}::?",
+        debug!("> Decoding inlined fn: {:?}::?",
         {
             // Do an Option dance to use the path after it is moved below.
             let s = ast_map::path_to_string(ast_map::Values(path.iter()));
             path_as_str = Some(s);
-            path_as_str.as_ref().map(|x| x[])
+            path_as_str.as_ref().map(|x| x.index(&FullRange))
         });
         let mut ast_dsr = reader::Decoder::new(ast_doc);
         let from_id_range = Decodable::decode(&mut ast_dsr).unwrap();
@@ -263,14 +263,6 @@ trait def_id_encoder_helpers {
     fn emit_def_id(&mut self, did: ast::DefId);
 }
 
-#[cfg(stage0)]
-impl<S:serialize::Encoder<E>, E> def_id_encoder_helpers for S {
-    fn emit_def_id(&mut self, did: ast::DefId) {
-        did.encode(self).ok().unwrap()
-    }
-}
-
-#[cfg(not(stage0))]
 impl<S:serialize::Encoder> def_id_encoder_helpers for S {
     fn emit_def_id(&mut self, did: ast::DefId) {
         did.encode(self).ok().unwrap()
@@ -283,21 +275,6 @@ fn read_def_id_nodcx(&mut self,
                          cdata: &cstore::crate_metadata) -> ast::DefId;
 }
 
-#[cfg(stage0)]
-impl<D:serialize::Decoder<E>, E> def_id_decoder_helpers for D {
-    fn read_def_id(&mut self, dcx: &DecodeContext) -> ast::DefId {
-        let did: ast::DefId = Decodable::decode(self).ok().unwrap();
-        did.tr(dcx)
-    }
-
-    fn read_def_id_nodcx(&mut self,
-                         cdata: &cstore::crate_metadata) -> ast::DefId {
-        let did: ast::DefId = Decodable::decode(self).ok().unwrap();
-        decoder::translate_def_id(cdata, did)
-    }
-}
-
-#[cfg(not(stage0))]
 impl<D:serialize::Decoder> def_id_decoder_helpers for D {
     fn read_def_id(&mut self, dcx: &DecodeContext) -> ast::DefId {
         let did: ast::DefId = Decodable::decode(self).ok().unwrap();
@@ -1880,7 +1857,7 @@ fn convert_def_id(&mut self,
             NominalType | TypeWithId | RegionParameter => dcx.tr_def_id(did),
             TypeParameter | UnboxedClosureSource => dcx.tr_intern_def_id(did)
         };
-        debug!("convert_def_id(source={}, did={})={}", source, did, r);
+        debug!("convert_def_id(source={:?}, did={:?})={:?}", source, did, r);
         return r;
     }
 }
@@ -1900,7 +1877,7 @@ fn decode_side_tables(dcx: &DecodeContext,
             None => {
                 dcx.tcx.sess.bug(
                     format!("unknown tag found in side tables: {:x}",
-                            tag)[]);
+                            tag).index(&FullRange));
             }
             Some(value) => {
                 let val_doc = entry_doc.get(c::tag_table_val as uint);
@@ -1985,7 +1962,7 @@ fn decode_side_tables(dcx: &DecodeContext,
                     _ => {
                         dcx.tcx.sess.bug(
                             format!("unknown tag found in side tables: {:x}",
-                                    tag)[]);
+                                    tag).index(&FullRange));
                     }
                 }
             }
index 3c672d0fdb6fa01057a9d69af99c66ed51c8be7b..f7fc90bcef6510c914a5a460f1ce62ad9dd2d5b3 100644 (file)
@@ -362,7 +362,7 @@ fn expr(&mut self, expr: &ast::Expr, pred: CFGIndex) -> CFGIndex {
                 let mut cond_exit = discr_exit;
                 for arm in arms.iter() {
                     cond_exit = self.add_dummy_node(&[cond_exit]);        // 2
-                    let pats_exit = self.pats_any(arm.pats[],
+                    let pats_exit = self.pats_any(arm.pats.index(&FullRange),
                                                   cond_exit);            // 3
                     let guard_exit = self.opt_expr(&arm.guard,
                                                    pats_exit);           // 4
@@ -480,12 +480,12 @@ fn expr(&mut self, expr: &ast::Expr, pred: CFGIndex) -> CFGIndex {
                 let inputs = inline_asm.inputs.iter();
                 let outputs = inline_asm.outputs.iter();
                 let post_inputs = self.exprs(inputs.map(|a| {
-                    debug!("cfg::construct InlineAsm id:{} input:{}", expr.id, a);
+                    debug!("cfg::construct InlineAsm id:{} input:{:?}", expr.id, a);
                     let &(_, ref expr) = a;
                     &**expr
                 }), pred);
                 let post_outputs = self.exprs(outputs.map(|a| {
-                    debug!("cfg::construct InlineAsm id:{} output:{}", expr.id, a);
+                    debug!("cfg::construct InlineAsm id:{} output:{:?}", expr.id, a);
                     let &(_, ref expr, _) = a;
                     &**expr
                 }), post_inputs);
@@ -514,7 +514,7 @@ fn call<'b, I: Iterator<Item=&'b ast::Expr>>(&mut self,
 
         let func_or_rcvr_exit = self.expr(func_or_rcvr, pred);
         let ret = self.straightline(call_expr, func_or_rcvr_exit, args);
-        if return_ty == ty::FnDiverging {
+        if return_ty.diverges() {
             self.add_node(ast::DUMMY_NODE_ID, &[])
         } else {
             ret
@@ -616,14 +616,14 @@ fn find_scope(&self,
                         self.tcx.sess.span_bug(
                             expr.span,
                             format!("no loop scope for id {}",
-                                    loop_id)[]);
+                                    loop_id).index(&FullRange));
                     }
 
                     r => {
                         self.tcx.sess.span_bug(
                             expr.span,
-                            format!("bad entry `{}` in def_map for label",
-                                    r)[]);
+                            format!("bad entry `{:?}` in def_map for label",
+                                    r).index(&FullRange));
                     }
                 }
             }
index 8a2ecbca20d55beab1226c9fa0284a1f9ad83b08..8b9a0d89b380c90547d0f304d07cf854e726d562 100644 (file)
@@ -52,7 +52,7 @@ fn replace_newline_with_backslash_l(s: String) -> String {
 }
 
 impl<'a, 'ast> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a, 'ast> {
-    fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(self.name[]).unwrap() }
+    fn graph_id(&'a self) -> dot::Id<'a> { dot::Id::new(self.name.index(&FullRange)).unwrap() }
 
     fn node_id(&'a self, &(i,_): &Node<'a>) -> dot::Id<'a> {
         dot::Id::new(format!("N{}", i.node_id())).unwrap()
@@ -85,7 +85,9 @@ fn edge_label(&self, e: &Edge<'a>) -> dot::LabelText<'a> {
             let s = self.ast_map.node_to_string(node_id);
             // left-aligns the lines
             let s = replace_newline_with_backslash_l(s);
-            label.push_str(format!("exiting scope_{} {}", i, s[])[]);
+            label.push_str(format!("exiting scope_{} {}",
+                                   i,
+                                   s.index(&FullRange)).index(&FullRange));
         }
         dot::LabelText::EscStr(label.into_cow())
     }
index ac53bdbefcf10a4e2d63c37efa7f4a4a9ae83474..621d7274b3f7c01a41c3c386ab8c1c3cf4623c5d 100644 (file)
@@ -118,7 +118,7 @@ fn check_expr(v: &mut CheckCrateVisitor, e: &ast::Expr) {
                 DefStruct(_) | DefVariant(_, _, _) => {}
 
                 def => {
-                    debug!("(checking const) found bad def: {}", def);
+                    debug!("(checking const) found bad def: {:?}", def);
                     span_err!(v.tcx.sess, e.span, E0014,
                               "paths in constants may only refer to constants \
                                or functions");
index e68a9fb50efd0f6e5ed0d3ae82660a7f6cc7ce81..5024e5c4f77de0ebdc745e4751d24b569301968a 100644 (file)
@@ -74,11 +74,11 @@ fn require_loop(&self, name: &str, span: Span) {
             Loop => {}
             Closure => {
                 self.sess.span_err(span,
-                                   format!("`{}` inside of a closure", name)[]);
+                                   format!("`{}` inside of a closure", name).index(&FullRange));
             }
             Normal => {
                 self.sess.span_err(span,
-                                   format!("`{}` outside of loop", name)[]);
+                                   format!("`{}` outside of loop", name).index(&FullRange));
             }
         }
     }
index f2b9ecb5ec4322aa8af50c7a0d780aad0bee7682..f1edfb37273bb37f73ed1229c8d3768ec45fc31d 100644 (file)
@@ -47,7 +47,7 @@
 
 /// Pretty-printer for matrices of patterns, example:
 /// ++++++++++++++++++++++++++
-/// + _     + []             +
+/// + _     + .index(&FullRange)             +
 /// ++++++++++++++++++++++++++
 /// + true  + [First]        +
 /// ++++++++++++++++++++++++++
@@ -161,7 +161,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
                 // First, check legality of move bindings.
                 check_legality_of_move_bindings(cx,
                                                 arm.guard.is_some(),
-                                                arm.pats[]);
+                                                arm.pats.index(&FullRange));
 
                 // Second, if there is a guard on each arm, make sure it isn't
                 // assigning or borrowing anything mutably.
@@ -198,7 +198,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
             }
 
             // Fourth, check for unreachable arms.
-            check_arms(cx, inlined_arms[], source);
+            check_arms(cx, inlined_arms.index(&FullRange), source);
 
             // Finally, check if the whole match expression is exhaustive.
             // Check for empty enum, because is_useful only works on inhabited types.
@@ -230,7 +230,7 @@ fn check_expr(cx: &mut MatchCheckCtxt, ex: &ast::Expr) {
                     pat.span,
                     format!("refutable pattern in `for` loop binding: \
                             `{}` not covered",
-                            pat_to_string(uncovered_pat))[]);
+                            pat_to_string(uncovered_pat)).index(&FullRange));
             });
 
             // Check legality of move bindings.
@@ -303,7 +303,7 @@ fn check_arms(cx: &MatchCheckCtxt,
         for pat in pats.iter() {
             let v = vec![&**pat];
 
-            match is_useful(cx, &seen, v[], LeaveOutWitness) {
+            match is_useful(cx, &seen, v.index(&FullRange), LeaveOutWitness) {
                 NotUseful => {
                     match source {
                         ast::MatchSource::IfLetDesugar { .. } => {
@@ -355,7 +355,7 @@ fn raw_pat<'a>(p: &'a Pat) -> &'a Pat {
 fn check_exhaustive(cx: &MatchCheckCtxt, sp: Span, matrix: &Matrix) {
     match is_useful(cx, matrix, &[DUMMY_WILD_PAT], ConstructWitness) {
         UsefulWithWitness(pats) => {
-            let witness = match pats[] {
+            let witness = match pats.index(&FullRange) {
                 [ref witness] => &**witness,
                 [] => DUMMY_WILD_PAT,
                 _ => unreachable!()
@@ -574,7 +574,7 @@ fn is_useful(cx: &MatchCheckCtxt,
              witness: WitnessPreference)
              -> Usefulness {
     let &Matrix(ref rows) = matrix;
-    debug!("{:}", matrix);
+    debug!("{:?}", matrix);
     if rows.len() == 0u {
         return match witness {
             ConstructWitness => UsefulWithWitness(vec!()),
@@ -609,7 +609,7 @@ fn is_useful(cx: &MatchCheckCtxt,
                         UsefulWithWitness(pats) => UsefulWithWitness({
                             let arity = constructor_arity(cx, &c, left_ty);
                             let mut result = {
-                                let pat_slice = pats[];
+                                let pat_slice = pats.index(&FullRange);
                                 let subpats: Vec<_> = range(0, arity).map(|i| {
                                     pat_slice.get(i).map_or(DUMMY_WILD_PAT, |p| &**p)
                                 }).collect();
@@ -656,10 +656,10 @@ fn is_useful_specialized(cx: &MatchCheckCtxt, &Matrix(ref m): &Matrix,
                          witness: WitnessPreference) -> Usefulness {
     let arity = constructor_arity(cx, &ctor, lty);
     let matrix = Matrix(m.iter().filter_map(|r| {
-        specialize(cx, r[], &ctor, 0u, arity)
+        specialize(cx, r.index(&FullRange), &ctor, 0u, arity)
     }).collect());
     match specialize(cx, v, &ctor, 0u, arity) {
-        Some(v) => is_useful(cx, &matrix, v[], witness),
+        Some(v) => is_useful(cx, &matrix, v.index(&FullRange), witness),
         None => NotUseful
     }
 }
@@ -729,7 +729,7 @@ fn pat_constructors(cx: &MatchCheckCtxt, p: &Pat,
 /// This computes the arity of a constructor. The arity of a constructor
 /// is how many subpattern patterns of that constructor should be expanded to.
 ///
-/// For instance, a tuple pattern (_, 42u, Some([])) has the arity of 3.
+/// For instance, a tuple pattern (_, 42u, Some(.index(&FullRange))) has the arity of 3.
 /// A struct pattern's arity is the number of fields it contains, etc.
 pub fn constructor_arity(cx: &MatchCheckCtxt, ctor: &Constructor, ty: Ty) -> uint {
     match ty.sty {
@@ -926,8 +926,8 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat],
         }
     };
     head.map(|mut head| {
-        head.push_all(r[..col]);
-        head.push_all(r[col + 1..]);
+        head.push_all(r.index(&(0..col)));
+        head.push_all(r.index(&((col + 1)..)));
         head
     })
 }
@@ -1042,9 +1042,9 @@ fn check_legality_of_move_bindings(cx: &MatchCheckCtxt,
                         cx.tcx.sess.span_bug(
                             p.span,
                             format!("binding pattern {} is not an \
-                                     identifier: {}",
+                                     identifier: {:?}",
                                     p.id,
-                                    p.node)[]);
+                                    p.node).index(&FullRange));
                     }
                 }
             }
index c383b1579ef84332a9817a10dc5cafc9dc133ba6..5ff1f36f0e06abae12e525a013003809e6539d3f 100644 (file)
@@ -59,7 +59,7 @@ fn consume(&mut self,
                span: Span,
                cmt: mc::cmt<'tcx>,
                _: euv::ConsumeMode) {
-        debug!("consume; cmt: {}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
+        debug!("consume; cmt: {:?}; type: {}", *cmt, ty_to_string(self.tcx, cmt.ty));
         if !ty::type_is_sized(self.param_env, span, cmt.ty) {
             span_err!(self.tcx.sess, span, E0161,
                 "cannot move a value of type {0}: the size of {0} cannot be statically determined",
index df51cb7e6bc4b3078c83cb9300640aea1d5be434..994a2b0dc8abc8a0b20c347c1db0cedf5ca10fd5 100644 (file)
@@ -112,7 +112,7 @@ fn check_static_mut_type(&self, e: &ast::Expr) {
         };
 
         self.tcx.sess.span_err(e.span, format!("mutable statics are not allowed \
-                                                to have {}", suffix)[]);
+                                                to have {}", suffix).index(&FullRange));
     }
 
     fn check_static_type(&self, e: &ast::Expr) {
@@ -170,7 +170,7 @@ fn visit_expr(&mut self, e: &ast::Expr) {
             ty::ty_enum(did, _) if ty::has_dtor(self.tcx, did) => {
                 self.tcx.sess.span_err(e.span,
                                        format!("{} are not allowed to have \
-                                                destructors", self.msg())[])
+                                                destructors", self.msg()).index(&FullRange))
             }
             _ => {}
         }
@@ -234,7 +234,7 @@ fn visit_expr(&mut self, e: &ast::Expr) {
                         let msg = "constants cannot refer to other statics, \
                                    insert an intermediate constant \
                                    instead";
-                        self.tcx.sess.span_err(e.span, msg[]);
+                        self.tcx.sess.span_err(e.span, msg.index(&FullRange));
                     }
                     _ => {}
                 }
index c36b4aa7f231e741c9135470c919429d6259b5b6..75851f0a8533327f145a660515996b30935fc132 100644 (file)
@@ -105,7 +105,7 @@ fn visit_expr(&mut self, e: &ast::Expr) {
                           _ => {
                             self.sess.span_err(e.span,
                               format!("expected item, found {}",
-                                      self.ast_map.node_to_string(def_id.node))[]);
+                                      self.ast_map.node_to_string(def_id.node)).index(&FullRange));
                             return;
                           },
                         }
index 32482fce4daa8b05d556f35333e724f4980937cb..e726993bd48402cfa27c835dec2e81a408091cac 100644 (file)
@@ -48,7 +48,7 @@
 //     target uses". This _includes_ integer-constants, plus the following
 //     constructors:
 //
-//        fixed-size vectors and strings: [] and ""/_
+//        fixed-size vectors and strings: .index(&FullRange) and ""/_
 //        vector and string slices: &[] and &""
 //        tuples: (,)
 //        enums: foo(...)
@@ -117,7 +117,7 @@ fn variant_expr<'a>(variants: &'a [P<ast::Variant>], id: ast::NodeId)
             None => None,
             Some(ast_map::NodeItem(it)) => match it.node {
                 ast::ItemEnum(ast::EnumDef { ref variants }, _) => {
-                    variant_expr(variants[], variant_def.node)
+                    variant_expr(variants.index(&FullRange), variant_def.node)
                 }
                 _ => None
             },
@@ -138,7 +138,7 @@ fn variant_expr<'a>(variants: &'a [P<ast::Variant>], id: ast::NodeId)
                     // NOTE this doesn't do the right thing, it compares inlined
                     // NodeId's to the original variant_def's NodeId, but they
                     // come from different crates, so they will likely never match.
-                    variant_expr(variants[], variant_def.node).map(|e| e.id)
+                    variant_expr(variants.index(&FullRange), variant_def.node).map(|e| e.id)
                 }
                 _ => None
             },
@@ -311,7 +311,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<ast::Pat> {
 
         ast::ExprCall(ref callee, ref args) => {
             let def = tcx.def_map.borrow()[callee.id].clone();
-            if let Vacant(entry) = tcx.def_map.borrow_mut().entry(&expr.id) {
+            if let Vacant(entry) = tcx.def_map.borrow_mut().entry(expr.id) {
                entry.insert(def);
             }
             let path = match def {
@@ -364,7 +364,7 @@ pub fn const_expr_to_pat(tcx: &ty::ctxt, expr: &Expr) -> P<ast::Pat> {
 pub fn eval_const_expr(tcx: &ty::ctxt, e: &Expr) -> const_val {
     match eval_const_expr_partial(tcx, e) {
         Ok(r) => r,
-        Err(s) => tcx.sess.span_fatal(e.span, s[])
+        Err(s) => tcx.sess.span_fatal(e.span, s.index(&FullRange))
     }
 }
 
@@ -528,12 +528,12 @@ macro_rules! define_casts {
 
         eval_const_expr_partial(tcx, &**base)
             .and_then(|val| define_casts!(val, {
-                ty::ty_int(ast::TyI) => (int, const_int, i64),
+                ty::ty_int(ast::TyIs) => (int, const_int, i64),
                 ty::ty_int(ast::TyI8) => (i8, const_int, i64),
                 ty::ty_int(ast::TyI16) => (i16, const_int, i64),
                 ty::ty_int(ast::TyI32) => (i32, const_int, i64),
                 ty::ty_int(ast::TyI64) => (i64, const_int, i64),
-                ty::ty_uint(ast::TyU) => (uint, const_uint, u64),
+                ty::ty_uint(ast::TyUs) => (uint, const_uint, u64),
                 ty::ty_uint(ast::TyU8) => (u8, const_uint, u64),
                 ty::ty_uint(ast::TyU16) => (u16, const_uint, u64),
                 ty::ty_uint(ast::TyU32) => (u32, const_uint, u64),
index e78b8047f695867ad51e875c90e4cb8a358addd0..bdd98a94fc32fba293defd79466b811d0c7fc395 100644 (file)
@@ -196,7 +196,7 @@ pub fn new(tcx: &'a ty::ctxt<'tcx>,
         let words_per_id = (bits_per_id + uint::BITS - 1) / uint::BITS;
         let num_nodes = cfg.graph.all_nodes().len();
 
-        debug!("DataFlowContext::new(analysis_name: {}, id_range={}, \
+        debug!("DataFlowContext::new(analysis_name: {}, id_range={:?}, \
                                      bits_per_id={}, words_per_id={}) \
                                      num_nodes: {}",
                analysis_name, id_range, bits_per_id, words_per_id,
@@ -251,7 +251,7 @@ pub fn add_kill(&mut self, id: ast::NodeId, bit: uint) {
 
     fn apply_gen_kill(&self, cfgidx: CFGIndex, bits: &mut [uint]) {
         //! Applies the gen and kill sets for `cfgidx` to `bits`
-        debug!("{} apply_gen_kill(cfgidx={}, bits={}) [before]",
+        debug!("{} apply_gen_kill(cfgidx={:?}, bits={}) [before]",
                self.analysis_name, cfgidx, mut_bits_to_string(bits));
         assert!(self.bits_per_id > 0);
 
@@ -261,7 +261,7 @@ fn apply_gen_kill(&self, cfgidx: CFGIndex, bits: &mut [uint]) {
         let kills = self.kills.slice(start, end);
         bitwise(bits, kills, &Subtract);
 
-        debug!("{} apply_gen_kill(cfgidx={}, bits={}) [after]",
+        debug!("{} apply_gen_kill(cfgidx={:?}, bits={}) [after]",
                self.analysis_name, cfgidx, mut_bits_to_string(bits));
     }
 
@@ -312,10 +312,10 @@ pub fn each_bit_for_node<F>(&self, e: EntryOrExit, cfgidx: CFGIndex, f: F) -> bo
                 let mut t = on_entry.to_vec();
                 self.apply_gen_kill(cfgidx, t.as_mut_slice());
                 temp_bits = t;
-                temp_bits[]
+                temp_bits.index(&FullRange)
             }
         };
-        debug!("{} each_bit_for_node({}, cfgidx={}) bits={}",
+        debug!("{} each_bit_for_node({:?}, cfgidx={:?}) bits={}",
                self.analysis_name, e, cfgidx, bits_to_string(slice));
         self.each_bit(slice, f)
     }
@@ -410,7 +410,7 @@ pub fn add_kills_from_flow_exits(&mut self, cfg: &cfg::CFG) {
                         }
                     }
                     None => {
-                        debug!("{} add_kills_from_flow_exits flow_exit={} \
+                        debug!("{} add_kills_from_flow_exits flow_exit={:?} \
                                 no cfg_idx for exiting_scope={}",
                                self.analysis_name, flow_exit, node_id);
                     }
@@ -419,10 +419,10 @@ pub fn add_kills_from_flow_exits(&mut self, cfg: &cfg::CFG) {
 
             if changed {
                 let bits = self.kills.slice_mut(start, end);
-                debug!("{} add_kills_from_flow_exits flow_exit={} bits={} [before]",
+                debug!("{} add_kills_from_flow_exits flow_exit={:?} bits={} [before]",
                        self.analysis_name, flow_exit, mut_bits_to_string(bits));
-                bits.clone_from_slice(orig_kills[]);
-                debug!("{} add_kills_from_flow_exits flow_exit={} bits={} [after]",
+                bits.clone_from_slice(orig_kills.index(&FullRange));
+                debug!("{} add_kills_from_flow_exits flow_exit={:?} bits={} [after]",
                        self.analysis_name, flow_exit, mut_bits_to_string(bits));
             }
             true
@@ -481,7 +481,7 @@ fn walk_cfg(&mut self,
         assert!(self.dfcx.bits_per_id > 0);
 
         cfg.graph.each_node(|node_index, node| {
-            debug!("DataFlowContext::walk_cfg idx={} id={} begin in_out={}",
+            debug!("DataFlowContext::walk_cfg idx={:?} id={} begin in_out={}",
                    node_index, node.data.id, bits_to_string(in_out));
 
             let (start, end) = self.dfcx.compute_id_range(node_index);
@@ -521,7 +521,7 @@ fn propagate_bits_into_entry_set_for(&mut self,
                                          edge: &cfg::CFGEdge) {
         let source = edge.source();
         let cfgidx = edge.target();
-        debug!("{} propagate_bits_into_entry_set_for(pred_bits={}, {} to {})",
+        debug!("{} propagate_bits_into_entry_set_for(pred_bits={}, {:?} to {:?})",
                self.dfcx.analysis_name, bits_to_string(pred_bits), source, cfgidx);
         assert!(self.dfcx.bits_per_id > 0);
 
@@ -532,7 +532,7 @@ fn propagate_bits_into_entry_set_for(&mut self,
             bitwise(on_entry, pred_bits, &self.dfcx.oper)
         };
         if changed {
-            debug!("{} changed entry set for {} to {}",
+            debug!("{} changed entry set for {:?} to {}",
                    self.dfcx.analysis_name, cfgidx,
                    bits_to_string(self.dfcx.on_entry.slice(start, end)));
             self.changed = true;
@@ -554,7 +554,7 @@ fn bits_to_string(words: &[uint]) -> String {
         let mut v = word;
         for _ in range(0u, uint::BYTES) {
             result.push(sep);
-            result.push_str(format!("{:02x}", v & 0xFF)[]);
+            result.push_str(format!("{:02x}", v & 0xFF).index(&FullRange));
             v >>= 8;
             sep = '-';
         }
index 6b56ece28bdb2e30968a38e13bbfffc17c316621..0bc899a8a62937ec3ff7c956a0c23dc5e4c77b2a 100644 (file)
@@ -118,7 +118,7 @@ fn calculate_type(sess: &session::Session,
                 let src = sess.cstore.get_used_crate_source(cnum).unwrap();
                 if src.rlib.is_some() { return }
                 sess.err(format!("dependency `{}` not found in rlib format",
-                                 data.name)[]);
+                                 data.name).index(&FullRange));
             });
             return Vec::new();
         }
@@ -149,7 +149,7 @@ fn calculate_type(sess: &session::Session,
             add_library(sess, cnum, cstore::RequireDynamic, &mut formats);
             let deps = csearch::get_dylib_dependency_formats(&sess.cstore, cnum);
             for &(depnum, style) in deps.iter() {
-                debug!("adding {}: {}", style,
+                debug!("adding {:?}: {}", style,
                        sess.cstore.get_crate_data(depnum).name.clone());
                 add_library(sess, depnum, style, &mut formats);
             }
@@ -197,7 +197,7 @@ fn calculate_type(sess: &session::Session,
                                  match kind {
                                      cstore::RequireStatic => "rlib",
                                      cstore::RequireDynamic => "dylib",
-                                 })[]);
+                                 }).index(&FullRange));
             }
         }
     }
@@ -222,7 +222,7 @@ fn add_library(sess: &session::Session,
                 let data = sess.cstore.get_crate_data(cnum);
                 sess.err(format!("cannot satisfy dependencies so `{}` only \
                                   shows up once",
-                                 data.name)[]);
+                                 data.name).index(&FullRange));
                 sess.help("having upstream crates all available in one format \
                            will likely make this go away");
             }
index df2a4e4c2532a988616508c89bab76516f8a1c73..45838436e6097350d1b12342228e85b4b50a540f 100644 (file)
@@ -29,7 +29,7 @@
 use middle::ty::{MethodStatic, MethodStaticUnboxedClosure};
 use util::ppaux::Repr;
 
-use std::kinds;
+use std::marker;
 use syntax::{ast, ast_util};
 use syntax::ptr::P;
 use syntax::codemap::Span;
@@ -135,7 +135,7 @@ enum TrackMatchMode<T> {
     Conflicting,
 }
 
-impl<T> kinds::Copy for TrackMatchMode<T> {}
+impl<T> marker::Copy for TrackMatchMode<T> {}
 
 impl<T> TrackMatchMode<T> {
     // Builds up the whole match mode for a pattern from its constituent
@@ -441,28 +441,12 @@ pub fn walk_expr(&mut self, expr: &ast::Expr) {
             }
 
             ast::ExprIndex(ref lhs, ref rhs) => {       // lhs[rhs]
-                match rhs.node {
-                    ast::ExprRange(ref start, ref end) => {
-                        // Hacked slicing syntax (KILLME).
-                        let args = match (start, end) {
-                            (&Some(ref e1), &Some(ref e2)) => vec![&**e1, &**e2],
-                            (&Some(ref e), &None) => vec![&**e],
-                            (&None, &Some(ref e)) => vec![&**e],
-                            (&None, &None) => Vec::new()
-                        };
-                        let overloaded =
-                            self.walk_overloaded_operator(expr, &**lhs, args, PassArgs::ByRef);
-                        assert!(overloaded);
-                    }
-                    _ => {
-                        if !self.walk_overloaded_operator(expr,
-                                                          &**lhs,
-                                                          vec![&**rhs],
-                                                          PassArgs::ByRef) {
-                            self.select_from_expr(&**lhs);
-                            self.consume_expr(&**rhs);
-                        }
-                    }
+                if !self.walk_overloaded_operator(expr,
+                                                  &**lhs,
+                                                  vec![&**rhs],
+                                                  PassArgs::ByRef) {
+                    self.select_from_expr(&**lhs);
+                    self.consume_expr(&**rhs);
                 }
             }
 
@@ -864,12 +848,17 @@ fn walk_autoderefs(&mut self,
                 None => {}
                 Some(method_ty) => {
                     let cmt = return_if_err!(self.mc.cat_expr_autoderefd(expr, i));
-                    let self_ty = ty::ty_fn_args(method_ty)[0];
+
+                    // the method call infrastructure should have
+                    // replaced all late-bound regions with variables:
+                    let self_ty = ty::ty_fn_sig(method_ty).input(0);
+                    let self_ty = ty::assert_no_late_bound_regions(self.tcx(), &self_ty);
+
                     let (m, r) = match self_ty.sty {
                         ty::ty_rptr(r, ref m) => (m.mutbl, r),
                         _ => self.tcx().sess.span_bug(expr.span,
                                 format!("bad overloaded deref type {}",
-                                    method_ty.repr(self.tcx()))[])
+                                    method_ty.repr(self.tcx())).index(&FullRange))
                     };
                     let bk = ty::BorrowKind::from_mutbl(m);
                     self.delegate.borrow(expr.id, expr.span, cmt,
@@ -1035,7 +1024,7 @@ fn walk_pat(&mut self,
             if pat_util::pat_is_binding(def_map, pat) {
                 let tcx = typer.tcx();
 
-                debug!("binding cmt_pat={} pat={} match_mode={}",
+                debug!("binding cmt_pat={} pat={} match_mode={:?}",
                        cmt_pat.repr(tcx),
                        pat.repr(tcx),
                        match_mode);
@@ -1171,10 +1160,10 @@ fn walk_pat(&mut self,
                             // pattern.
 
                             if !tcx.sess.has_errors() {
-                                let msg = format!("Pattern has unexpected type: {} and type {}",
+                                let msg = format!("Pattern has unexpected type: {:?} and type {}",
                                                   def,
                                                   cmt_pat.ty.repr(tcx));
-                                tcx.sess.span_bug(pat.span, msg[])
+                                tcx.sess.span_bug(pat.span, msg.as_slice())
                             }
                         }
 
@@ -1188,10 +1177,10 @@ fn walk_pat(&mut self,
                             // reported.
 
                             if !tcx.sess.has_errors() {
-                                let msg = format!("Pattern has unexpected def: {} and type {}",
+                                let msg = format!("Pattern has unexpected def: {:?} and type {}",
                                                   def,
                                                   cmt_pat.ty.repr(tcx));
-                                tcx.sess.span_bug(pat.span, msg[])
+                                tcx.sess.span_bug(pat.span, msg.index(&FullRange))
                             }
                         }
                     }
index 52b6af76081702d86109131490dffbe85bb69bdc..30e0ce33018d0f7c4c3e45de584019bdd2f1a4ce 100644 (file)
@@ -55,7 +55,7 @@ pub struct Edge<E> {
 
 impl<E: Show> Show for Edge<E> {
     fn fmt(&self, f: &mut Formatter) -> Result<(), Error> {
-        write!(f, "Edge {{ next_edge: [{}, {}], source: {}, target: {}, data: {} }}",
+        write!(f, "Edge {{ next_edge: [{:?}, {:?}], source: {:?}, target: {:?}, data: {:?} }}",
                self.next_edge[0], self.next_edge[1], self.source,
                self.target, self.data)
     }
@@ -419,7 +419,7 @@ fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>,
         graph.each_incoming_edge(start_index, |edge_index, edge| {
             assert!(graph.edge_data(edge_index) == &edge.data);
             assert!(counter < expected_incoming.len());
-            debug!("counter={} expected={} edge_index={} edge={}",
+            debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
                    counter, expected_incoming[counter], edge_index, edge);
             match expected_incoming[counter] {
                 (ref e, ref n) => {
@@ -437,7 +437,7 @@ fn test_adjacent_edges<N:PartialEq+Show,E:PartialEq+Show>(graph: &Graph<N,E>,
         graph.each_outgoing_edge(start_index, |edge_index, edge| {
             assert!(graph.edge_data(edge_index) == &edge.data);
             assert!(counter < expected_outgoing.len());
-            debug!("counter={} expected={} edge_index={} edge={}",
+            debug!("counter={:?} expected={:?} edge_index={:?} edge={:?}",
                    counter, expected_outgoing[counter], edge_index, edge);
             match expected_outgoing[counter] {
                 (ref e, ref n) => {
index 65de3a083d2d9154cb3268df618a033c4e4a283c..9f87e73d4af9df47ace6d33f6e2d608da2e73875 100644 (file)
@@ -265,7 +265,7 @@ fn coerce_unsized(&self,
                                                  ty::mt{ty: ty, mutbl: mt_b.mutbl});
                             try!(self.get_ref().infcx.try(|_| sub.tys(ty, b)));
                             debug!("Success, coerced with AutoDerefRef(1, \
-                                    AutoPtr(AutoUnsize({})))", kind);
+                                    AutoPtr(AutoUnsize({:?})))", kind);
                             Ok(Some(AdjustDerefRef(AutoDerefRef {
                                 autoderefs: 1,
                                 autoref: Some(ty::AutoPtr(r_borrow, mt_b.mutbl,
@@ -288,7 +288,7 @@ fn coerce_unsized(&self,
                                                  ty::mt{ty: ty, mutbl: mt_b.mutbl});
                             try!(self.get_ref().infcx.try(|_| sub.tys(ty, b)));
                             debug!("Success, coerced with AutoDerefRef(1, \
-                                    AutoPtr(AutoUnsize({})))", kind);
+                                    AutoPtr(AutoUnsize({:?})))", kind);
                             Ok(Some(AdjustDerefRef(AutoDerefRef {
                                 autoderefs: 1,
                                 autoref: Some(ty::AutoUnsafe(mt_b.mutbl,
@@ -306,7 +306,7 @@ fn coerce_unsized(&self,
                             let ty = ty::mk_uniq(self.tcx(), ty);
                             try!(self.get_ref().infcx.try(|_| sub.tys(ty, b)));
                             debug!("Success, coerced with AutoDerefRef(1, \
-                                    AutoUnsizeUniq({}))", kind);
+                                    AutoUnsizeUniq({:?}))", kind);
                             Ok(Some(AdjustDerefRef(AutoDerefRef {
                                 autoderefs: 1,
                                 autoref: Some(ty::AutoUnsizeUniq(kind))
@@ -328,7 +328,7 @@ fn unsize_ty(&self,
                  a: Ty<'tcx>,
                  ty_b: Ty<'tcx>)
                  -> Option<(Ty<'tcx>, ty::UnsizeKind<'tcx>)> {
-        debug!("unsize_ty(a={}, ty_b={})", a, ty_b.repr(self.tcx()));
+        debug!("unsize_ty(a={:?}, ty_b={})", a, ty_b.repr(self.tcx()));
 
         let tcx = self.tcx();
 
@@ -406,7 +406,7 @@ fn coerce_borrowed_object(&self,
     {
         let tcx = self.tcx();
 
-        debug!("coerce_borrowed_object(a={}, b={}, b_mutbl={})",
+        debug!("coerce_borrowed_object(a={}, b={}, b_mutbl={:?})",
                a.repr(tcx),
                b.repr(tcx), b_mutbl);
 
@@ -426,7 +426,7 @@ fn coerce_unsafe_object(&self,
     {
         let tcx = self.tcx();
 
-        debug!("coerce_unsafe_object(a={}, b={}, b_mutbl={})",
+        debug!("coerce_unsafe_object(a={}, b={}, b_mutbl={:?})",
                a.repr(tcx),
                b.repr(tcx), b_mutbl);
 
@@ -449,7 +449,7 @@ fn coerce_object<F, G>(&self,
         match a.sty {
             ty::ty_rptr(_, ty::mt{ty, mutbl}) => match ty.sty {
                 ty::ty_trait(box ty::TyTrait { ref principal, ref bounds }) => {
-                    debug!("mutbl={} b_mutbl={}", mutbl, b_mutbl);
+                    debug!("mutbl={:?} b_mutbl={:?}", mutbl, b_mutbl);
                     let tr = ty::mk_trait(tcx, principal.clone(), bounds.clone());
                     try!(self.subtype(mk_ty(tr), b));
                     Ok(Some(AdjustDerefRef(AutoDerefRef {
index dd711fcbf022eed6d76a7d49e45db83b026d6795..22975f54a9fb4e73cee177ab340c947adb234393 100644 (file)
@@ -142,7 +142,7 @@ fn substs_variances(&self,
                             for _ in a_regions.iter() {
                                 invariance.push(ty::Invariant);
                             }
-                            invariance[]
+                            invariance.index(&FullRange)
                         }
                     };
 
@@ -361,7 +361,7 @@ fn trait_stores(&self,
                     a: ty::TraitStore,
                     b: ty::TraitStore)
                     -> cres<'tcx, ty::TraitStore> {
-        debug!("{}.trait_stores(a={}, b={})", self.tag(), a, b);
+        debug!("{}.trait_stores(a={:?}, b={:?})", self.tag(), a, b);
 
         match (a, b) {
             (ty::RegionTraitStore(a_r, a_m),
@@ -471,7 +471,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
     let tcx = this.infcx().tcx;
     let a_sty = &a.sty;
     let b_sty = &b.sty;
-    debug!("super_tys: a_sty={} b_sty={}", a_sty, b_sty);
+    debug!("super_tys: a_sty={:?} b_sty={:?}", a_sty, b_sty);
     return match (a_sty, b_sty) {
       // The "subtype" ought to be handling cases involving var:
       (&ty::ty_infer(TyVar(_)), _) |
@@ -480,7 +480,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
             format!("{}: bot and var types should have been handled ({},{})",
                     this.tag(),
                     a.repr(this.infcx().tcx),
-                    b.repr(this.infcx().tcx))[]);
+                    b.repr(this.infcx().tcx)).index(&FullRange));
       }
 
       (&ty::ty_err, _) | (_, &ty::ty_err) => {
@@ -550,7 +550,7 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C,
 
       (&ty::ty_trait(ref a_),
        &ty::ty_trait(ref b_)) => {
-          debug!("Trying to match traits {} and {}", a, b);
+          debug!("Trying to match traits {:?} and {:?}", a, b);
           let principal = try!(this.binders(&a_.principal, &b_.principal));
           let bounds = try!(this.existential_bounds(&a_.bounds, &b_.bounds));
           Ok(ty::mk_trait(tcx, principal, bounds))
@@ -724,7 +724,7 @@ pub fn instantiate(&self,
                 Some(e) => e,
             };
 
-            debug!("instantiate(a_ty={} dir={} b_vid={})",
+            debug!("instantiate(a_ty={} dir={:?} b_vid={})",
                    a_ty.repr(tcx),
                    dir,
                    b_vid.repr(tcx));
@@ -745,7 +745,7 @@ pub fn instantiate(&self,
                             self.generalize(a_ty, b_vid, true)
                         }
                     });
-                    debug!("instantiate(a_ty={}, dir={}, \
+                    debug!("instantiate(a_ty={}, dir={:?}, \
                                         b_vid={}, generalized_ty={})",
                            a_ty.repr(tcx), dir, b_vid.repr(tcx),
                            generalized_ty.repr(tcx));
@@ -856,7 +856,7 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
                 self.tcx().sess.span_bug(
                     self.span,
                     format!("Encountered early bound region when generalizing: {}",
-                            r.repr(self.tcx()))[]);
+                            r.repr(self.tcx())).index(&FullRange));
             }
 
             // Always make a fresh region variable for skolemized regions;
index 9f5c8de8811f07ed2a30a3ce86a6de285c558ca7..762617fb49b88c1dca21d29cdf9c8a187dfe9aaf 100644 (file)
@@ -200,9 +200,9 @@ fn report_region_errors(&self,
                                 ref trace_origins,
                                 ref same_regions) => {
                     if !same_regions.is_empty() {
-                        self.report_processed_errors(var_origins[],
-                                                     trace_origins[],
-                                                     same_regions[]);
+                        self.report_processed_errors(var_origins.index(&FullRange),
+                                                     trace_origins.index(&FullRange),
+                                                     same_regions.index(&FullRange));
                     }
                 }
             }
@@ -268,7 +268,7 @@ fn process_errors(&self, errors: &Vec<RegionResolutionError<'tcx>>)
                 }
             }
             let pe = ProcessedErrors(var_origins, trace_origins, same_regions);
-            debug!("errors processed: {}", pe);
+            debug!("errors processed: {:?}", pe);
             processed_errors.push(pe);
         }
         return processed_errors;
@@ -297,7 +297,7 @@ fn free_regions_from_same_fn(tcx: &ty::ctxt,
                                      sub: Region,
                                      sup: Region)
                                      -> Option<FreeRegionsFromSameFn> {
-            debug!("free_regions_from_same_fn(sub={}, sup={})", sub, sup);
+            debug!("free_regions_from_same_fn(sub={:?}, sup={:?})", sub, sup);
             let (scope_id, fr1, fr2) = match (sub, sup) {
                 (ReFree(fr1), ReFree(fr2)) => {
                     if fr1.scope != fr2.scope {
@@ -376,7 +376,7 @@ fn report_type_error(&self, trace: TypeTrace<'tcx>, terr: &ty::type_err<'tcx>) {
             format!("{}: {} ({})",
                  message_root_str,
                  expected_found_str,
-                 ty::type_err_to_str(self.tcx, terr))[]);
+                 ty::type_err_to_str(self.tcx, terr)).index(&FullRange));
 
         match trace.origin {
             infer::MatchExpressionArm(_, arm_span) =>
@@ -445,25 +445,25 @@ fn report_generic_bound_failure(&self,
                 // Does the required lifetime have a nice name we can print?
                 self.tcx.sess.span_err(
                     origin.span(),
-                    format!("{} may not live long enough", labeled_user_string)[]);
+                    format!("{} may not live long enough", labeled_user_string).index(&FullRange));
                 self.tcx.sess.span_help(
                     origin.span(),
                     format!(
                         "consider adding an explicit lifetime bound `{}: {}`...",
                         bound_kind.user_string(self.tcx),
-                        sub.user_string(self.tcx))[]);
+                        sub.user_string(self.tcx)).index(&FullRange));
             }
 
             ty::ReStatic => {
                 // Does the required lifetime have a nice name we can print?
                 self.tcx.sess.span_err(
                     origin.span(),
-                    format!("{} may not live long enough", labeled_user_string)[]);
+                    format!("{} may not live long enough", labeled_user_string).index(&FullRange));
                 self.tcx.sess.span_help(
                     origin.span(),
                     format!(
                         "consider adding an explicit lifetime bound `{}: 'static`...",
-                        bound_kind.user_string(self.tcx))[]);
+                        bound_kind.user_string(self.tcx)).index(&FullRange));
             }
 
             _ => {
@@ -472,15 +472,15 @@ fn report_generic_bound_failure(&self,
                     origin.span(),
                     format!(
                         "{} may not live long enough",
-                        labeled_user_string)[]);
+                        labeled_user_string).index(&FullRange));
                 self.tcx.sess.span_help(
                     origin.span(),
                     format!(
                         "consider adding an explicit lifetime bound for `{}`",
-                        bound_kind.user_string(self.tcx))[]);
+                        bound_kind.user_string(self.tcx)).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
-                    format!("{} must be valid for ", labeled_user_string)[],
+                    format!("{} must be valid for ", labeled_user_string).index(&FullRange),
                     sub,
                     "...");
             }
@@ -522,7 +522,7 @@ fn report_concrete_failure(&self,
                             ty::local_var_name_str(self.tcx,
                                                    upvar_id.var_id)
                                 .get()
-                                .to_string())[]);
+                                .to_string()).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "...the borrowed pointer is valid for ",
@@ -534,7 +534,7 @@ fn report_concrete_failure(&self,
                             ty::local_var_name_str(self.tcx,
                                                    upvar_id.var_id)
                                 .get()
-                                .to_string())[],
+                                .to_string()).index(&FullRange),
                     sup,
                     "");
             }
@@ -580,7 +580,7 @@ fn report_concrete_failure(&self,
                             outlive the enclosing closure",
                             ty::local_var_name_str(self.tcx,
                                                    id).get()
-                                                      .to_string())[]);
+                                                      .to_string()).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "captured variable is valid for ",
@@ -622,7 +622,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("the type `{}` does not fulfill the \
                              required lifetime",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
                 note_and_explain_region(self.tcx,
                                         "type must outlive ",
                                         sub,
@@ -648,7 +648,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("the type `{}` (provided as the value of \
                              a type parameter) is not valid at this point",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
                 note_and_explain_region(self.tcx,
                                         "type must outlive ",
                                         sub,
@@ -714,7 +714,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("type of expression contains references \
                              that are not valid during the expression: `{}`",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "type is only valid for ",
@@ -736,7 +736,7 @@ fn report_concrete_failure(&self,
                     span,
                     format!("in type `{}`, reference has a longer lifetime \
                              than the data it references",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
                 note_and_explain_region(
                     self.tcx,
                     "the pointer is valid for ",
@@ -861,7 +861,7 @@ fn give_suggestion(&self, same_regions: &[SameRegions]) {
         let (fn_decl, generics, unsafety, ident, expl_self, span)
                                     = node_inner.expect("expect item fn");
         let taken = lifetimes_in_scope(self.tcx, scope_id);
-        let life_giver = LifeGiver::with_taken(taken[]);
+        let life_giver = LifeGiver::with_taken(taken.index(&FullRange));
         let rebuilder = Rebuilder::new(self.tcx, fn_decl, expl_self,
                                        generics, same_regions, &life_giver);
         let (fn_decl, expl_self, generics) = rebuilder.rebuild();
@@ -937,7 +937,7 @@ fn rebuild(&self)
             }
             expl_self_opt = self.rebuild_expl_self(expl_self_opt, lifetime,
                                                    &anon_nums, &region_names);
-            inputs = self.rebuild_args_ty(inputs[], lifetime,
+            inputs = self.rebuild_args_ty(inputs.index(&FullRange), lifetime,
                                           &anon_nums, &region_names);
             output = self.rebuild_output(&output, lifetime, &anon_nums, &region_names);
             ty_params = self.rebuild_ty_params(ty_params, lifetime,
@@ -972,7 +972,7 @@ fn pick_lifetime(&self,
                 names.push(lt_name);
             }
             names.sort();
-            let name = token::str_to_ident(names[0][]).name;
+            let name = token::str_to_ident(names[0].index(&FullRange)).name;
             return (name_to_dummy_lifetime(name), Kept);
         }
         return (self.life_giver.give_lifetime(), Fresh);
@@ -1222,7 +1222,7 @@ fn rebuild_arg_ty_or_output(&self,
                                 .sess
                                 .fatal(format!(
                                         "unbound path {}",
-                                        pprust::path_to_string(path))[])
+                                        pprust::path_to_string(path)).index(&FullRange))
                         }
                         Some(&d) => d
                     };
@@ -1420,7 +1420,7 @@ fn give_expl_lifetime_param(&self,
                                               opt_explicit_self, generics);
         let msg = format!("consider using an explicit lifetime \
                            parameter as shown: {}", suggested_fn);
-        self.tcx.sess.span_help(span, msg[]);
+        self.tcx.sess.span_help(span, msg.index(&FullRange));
     }
 
     fn report_inference_failure(&self,
@@ -1463,7 +1463,7 @@ fn report_inference_failure(&self,
             var_origin.span(),
             format!("cannot infer an appropriate lifetime{} \
                     due to conflicting requirements",
-                    var_description)[]);
+                    var_description).index(&FullRange));
     }
 
     fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
@@ -1511,7 +1511,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                         self.tcx.sess.span_note(
                             trace.origin.span(),
                             format!("...so that {} ({})",
-                                    desc, values_str)[]);
+                                    desc, values_str).index(&FullRange));
                     }
                     None => {
                         // Really should avoid printing this error at
@@ -1520,7 +1520,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                         // doing right now. - nmatsakis
                         self.tcx.sess.span_note(
                             trace.origin.span(),
-                            format!("...so that {}", desc)[]);
+                            format!("...so that {}", desc).index(&FullRange));
                     }
                 }
             }
@@ -1537,7 +1537,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                         "...so that closure can access `{}`",
                         ty::local_var_name_str(self.tcx, upvar_id.var_id)
                             .get()
-                            .to_string())[])
+                            .to_string()).index(&FullRange))
             }
             infer::InfStackClosure(span) => {
                 self.tcx.sess.span_note(
@@ -1562,7 +1562,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                             does not outlive the enclosing closure",
                             ty::local_var_name_str(
                                 self.tcx,
-                                id).get().to_string())[]);
+                                id).get().to_string()).index(&FullRange));
             }
             infer::IndexSlice(span) => {
                 self.tcx.sess.span_note(
@@ -1606,7 +1606,7 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                     span,
                     format!("...so type `{}` of expression is valid during the \
                              expression",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
             }
             infer::BindingTypeIsNotValidAtDecl(span) => {
                 self.tcx.sess.span_note(
@@ -1618,14 +1618,14 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                     span,
                     format!("...so that the reference type `{}` \
                              does not outlive the data it points at",
-                            self.ty_to_string(ty))[]);
+                            self.ty_to_string(ty)).index(&FullRange));
             }
             infer::RelateParamBound(span, t) => {
                 self.tcx.sess.span_note(
                     span,
                     format!("...so that the type `{}` \
                              will meet the declared lifetime bounds",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
             }
             infer::RelateDefaultParamBound(span, t) => {
                 self.tcx.sess.span_note(
@@ -1633,13 +1633,13 @@ fn note_region_origin(&self, origin: &SubregionOrigin<'tcx>) {
                     format!("...so that type parameter \
                              instantiated with `{}`, \
                              will meet its declared lifetime bounds",
-                            self.ty_to_string(t))[]);
+                            self.ty_to_string(t)).index(&FullRange));
             }
             infer::RelateRegionParamBound(span) => {
                 self.tcx.sess.span_note(
                     span,
                     format!("...so that the declared lifetime parameter bounds \
-                                are satisfied")[]);
+                                are satisfied").index(&FullRange));
             }
         }
     }
@@ -1691,7 +1691,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
         Some(node) => match node {
             ast_map::NodeItem(item) => match item.node {
                 ast::ItemFn(_, _, _, ref gen, _) => {
-                    taken.push_all(gen.lifetimes[]);
+                    taken.push_all(gen.lifetimes.index(&FullRange));
                     None
                 },
                 _ => None
@@ -1699,7 +1699,7 @@ fn lifetimes_in_scope(tcx: &ty::ctxt,
             ast_map::NodeImplItem(ii) => {
                 match *ii {
                     ast::MethodImplItem(ref m) => {
-                        taken.push_all(m.pe_generics().lifetimes[]);
+                        taken.push_all(m.pe_generics().lifetimes.index(&FullRange));
                         Some(m.id)
                     }
                     ast::TypeImplItem(_) => None,
@@ -1758,10 +1758,10 @@ fn give_lifetime(&self) -> ast::Lifetime {
         let mut lifetime;
         loop {
             let mut s = String::from_str("'");
-            s.push_str(num_to_string(self.counter.get())[]);
+            s.push_str(num_to_string(self.counter.get()).index(&FullRange));
             if !self.taken.contains(&s) {
                 lifetime = name_to_dummy_lifetime(
-                                    token::str_to_ident(s[]).name);
+                                    token::str_to_ident(s.index(&FullRange)).name);
                 self.generated.borrow_mut().push(lifetime);
                 break;
             }
index 608ae31475327e4b3430336fef69183f1e1b1583..02c52f82967613316bc9be19fd016e07c4941e65 100644 (file)
@@ -66,7 +66,7 @@ fn freshen<F>(&mut self,
             None => { }
         }
 
-        match self.freshen_map.entry(&key) {
+        match self.freshen_map.entry(key) {
             Entry::Occupied(entry) => *entry.get(),
             Entry::Vacant(entry) => {
                 let index = self.freshen_count;
index bf0a9cfbea66dae686571b73e9b335329d613ca5..073052dd368709571097ad8e6b81add70c5ef09f 100644 (file)
@@ -154,7 +154,7 @@ fn generalize_region(infcx: &InferCtxt,
             // Regions that pre-dated the LUB computation stay as they are.
             if !is_var_in_set(new_vars, r0) {
                 assert!(!r0.is_bound());
-                debug!("generalize_region(r0={}): not new variable", r0);
+                debug!("generalize_region(r0={:?}): not new variable", r0);
                 return r0;
             }
 
@@ -164,8 +164,8 @@ fn generalize_region(infcx: &InferCtxt,
             // *related* to regions that pre-date the LUB computation
             // stay as they are.
             if !tainted.iter().all(|r| is_var_in_set(new_vars, *r)) {
-                debug!("generalize_region(r0={}): \
-                        non-new-variables found in {}",
+                debug!("generalize_region(r0={:?}): \
+                        non-new-variables found in {:?}",
                        r0, tainted);
                 assert!(!r0.is_bound());
                 return r0;
@@ -178,8 +178,8 @@ fn generalize_region(infcx: &InferCtxt,
             // with.
             for (a_br, a_r) in a_map.iter() {
                 if tainted.iter().any(|x| x == a_r) {
-                    debug!("generalize_region(r0={}): \
-                            replacing with {}, tainted={}",
+                    debug!("generalize_region(r0={:?}): \
+                            replacing with {:?}, tainted={:?}",
                            r0, *a_br, tainted);
                     return ty::ReLateBound(debruijn, *a_br);
                 }
@@ -187,9 +187,9 @@ fn generalize_region(infcx: &InferCtxt,
 
             infcx.tcx.sess.span_bug(
                 span,
-                format!("region {} is not associated with \
+                format!("region {:?} is not associated with \
                          any bound region from A!",
-                        r0)[])
+                        r0).index(&FullRange))
         }
     }
 
@@ -322,7 +322,7 @@ fn rev_lookup(infcx: &InferCtxt,
             }
             infcx.tcx.sess.span_bug(
                 span,
-                format!("could not find original bound region for {}", r)[]);
+                format!("could not find original bound region for {:?}", r).index(&FullRange));
         }
 
         fn fresh_bound_variable(infcx: &InferCtxt, debruijn: ty::DebruijnIndex) -> ty::Region {
@@ -339,7 +339,7 @@ fn var_ids<'tcx, T: Combine<'tcx>>(combiner: &T,
             r => {
                 combiner.infcx().tcx.sess.span_bug(
                     combiner.trace().origin.span(),
-                    format!("found non-region-vid: {}", r)[]);
+                    format!("found non-region-vid: {:?}", r).index(&FullRange));
             }
         }).collect()
 }
index c2db81d311483b5e72d57be2921e26f39ce176bd..3f18af3d768e4331319d3eab85b96569665e0230 100644 (file)
@@ -989,7 +989,7 @@ pub fn type_error_message_str_with_expected<M>(&self,
                                                    err: Option<&ty::type_err<'tcx>>) where
         M: FnOnce(Option<String>, String) -> String,
     {
-        debug!("hi! expected_ty = {}, actual_ty = {}", expected_ty, actual_ty);
+        debug!("hi! expected_ty = {:?}, actual_ty = {}", expected_ty, actual_ty);
 
         let resolved_expected = expected_ty.map(|e_ty| self.resolve_type_vars_if_possible(&e_ty));
 
@@ -1002,7 +1002,7 @@ pub fn type_error_message_str_with_expected<M>(&self,
 
                 self.tcx.sess.span_err(sp, format!("{}{}",
                     mk_msg(resolved_expected.map(|t| self.ty_to_string(t)), actual_ty),
-                    error_str)[]);
+                    error_str).index(&FullRange));
 
                 for err in err.iter() {
                     ty::note_and_explain_type_err(self.tcx, *err)
@@ -1219,7 +1219,7 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
             }
             Reborrow(a) => format!("Reborrow({})", a.repr(tcx)),
             ReborrowUpvar(a, b) => {
-                format!("ReborrowUpvar({},{})", a.repr(tcx), b)
+                format!("ReborrowUpvar({},{:?})", a.repr(tcx), b)
             }
             ReferenceOutlivesReferent(_, a) => {
                 format!("ReferenceOutlivesReferent({})", a.repr(tcx))
@@ -1277,7 +1277,7 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
                 format!("EarlyBoundRegion({},{})", a.repr(tcx), b.repr(tcx))
             }
             LateBoundRegion(a, b, c) => {
-                format!("LateBoundRegion({},{},{})", a.repr(tcx), b.repr(tcx), c)
+                format!("LateBoundRegion({},{},{:?})", a.repr(tcx), b.repr(tcx), c)
             }
             BoundRegionInCoherence(a) => {
                 format!("bound_regionInCoherence({})", a.repr(tcx))
index 98c69962bc288b6732ab1951c698d068fe10f5dd..29feaf358e2e259795cef71f9505b386b5e92fe4 100644 (file)
@@ -67,7 +67,7 @@ pub fn maybe_print_constraints_for<'a, 'tcx>(region_vars: &RegionVarBindings<'a,
     }
 
     let requested_output = os::getenv("RUST_REGION_GRAPH");
-    debug!("requested_output: {} requested_node: {}",
+    debug!("requested_output: {:?} requested_node: {:?}",
            requested_output, requested_node);
 
     let output_path = {
@@ -137,7 +137,7 @@ fn new(tcx: &'a ty::ctxt<'tcx>,
         let mut node_ids = FnvHashMap::new();
         {
             let mut add_node = |&mut : node| {
-                if let Vacant(e) = node_ids.entry(&node) {
+                if let Vacant(e) = node_ids.entry(node) {
                     e.insert(i);
                     i += 1;
                 }
@@ -166,7 +166,7 @@ fn node_id(&self, n: &Node) -> dot::Id {
     fn node_label(&self, n: &Node) -> dot::LabelText {
         match *n {
             Node::RegionVid(n_vid) =>
-                dot::LabelText::label(format!("{}", n_vid)),
+                dot::LabelText::label(format!("{:?}", n_vid)),
             Node::Region(n_rgn) =>
                 dot::LabelText::label(format!("{}", n_rgn.repr(self.tcx))),
         }
@@ -204,12 +204,12 @@ fn edges(&self) -> dot::Edges<Edge> {
     }
     fn source(&self, edge: &Edge) -> Node {
         let (n1, _) = constraint_to_nodes(edge);
-        debug!("edge {} has source {}", edge, n1);
+        debug!("edge {:?} has source {:?}", edge, n1);
         n1
     }
     fn target(&self, edge: &Edge) -> Node {
         let (_, n2) = constraint_to_nodes(edge);
-        debug!("edge {} has target {}", edge, n2);
+        debug!("edge {:?} has target {:?}", edge, n2);
         n2
     }
 }
index a4888e7f186dba0dd83b266dd78d6c8463468fce..5c5c08b53a27566e44d8e036872db1237f36657d 100644 (file)
@@ -273,7 +273,7 @@ pub fn commit(&self, snapshot: RegionSnapshot) {
     }
 
     pub fn rollback_to(&self, snapshot: RegionSnapshot) {
-        debug!("RegionVarBindings: rollback_to({})", snapshot);
+        debug!("RegionVarBindings: rollback_to({:?})", snapshot);
         let mut undo_log = self.undo_log.borrow_mut();
         assert!(undo_log.len() > snapshot.length);
         assert!((*undo_log)[snapshot.length] == OpenSnapshot);
@@ -325,7 +325,7 @@ pub fn new_region_var(&self, origin: RegionVariableOrigin<'tcx>) -> RegionVid {
         if self.in_snapshot() {
             self.undo_log.borrow_mut().push(AddVar(vid));
         }
-        debug!("created new region variable {} with origin {}",
+        debug!("created new region variable {:?} with origin {}",
                vid, origin.repr(self.tcx));
         return vid;
     }
@@ -427,7 +427,7 @@ pub fn add_given(&self,
 
         let mut givens = self.givens.borrow_mut();
         if givens.insert((sub, sup)) {
-            debug!("add_given({} <= {})",
+            debug!("add_given({} <= {:?})",
                    sub.repr(self.tcx),
                    sup);
 
@@ -475,7 +475,7 @@ pub fn make_subregion(&self,
                 origin.span(),
                 format!("cannot relate bound region: {} <= {}",
                         sub.repr(self.tcx),
-                        sup.repr(self.tcx))[]);
+                        sup.repr(self.tcx)).index(&FullRange));
           }
           (_, ReStatic) => {
             // all regions are subregions of static, so we can ignore this
@@ -565,7 +565,7 @@ pub fn resolve_var(&self, rid: RegionVid) -> ty::Region {
             }
             Some(ref values) => {
                 let r = lookup(values, rid);
-                debug!("resolve_var({}) = {}", rid, r.repr(self.tcx));
+                debug!("resolve_var({:?}) = {}", rid, r.repr(self.tcx));
                 r
             }
         }
@@ -602,7 +602,7 @@ pub fn combine_vars<F>(&self,
         }
         relate(self, a, ReInfer(ReVar(c)));
         relate(self, b, ReInfer(ReVar(c)));
-        debug!("combine_vars() c={}", c);
+        debug!("combine_vars() c={:?}", c);
         ReInfer(ReVar(c))
     }
 
@@ -623,7 +623,7 @@ pub fn vars_created_since_snapshot(&self, mark: &RegionSnapshot)
     /// made---`r0` itself will be the first entry. This is used when checking whether skolemized
     /// regions are being improperly related to other regions.
     pub fn tainted(&self, mark: &RegionSnapshot, r0: Region) -> Vec<Region> {
-        debug!("tainted(mark={}, r0={})", mark, r0.repr(self.tcx));
+        debug!("tainted(mark={:?}, r0={})", mark, r0.repr(self.tcx));
         let _indenter = indenter();
 
         // `result_set` acts as a worklist: we explore all outgoing
@@ -634,7 +634,7 @@ pub fn tainted(&self, mark: &RegionSnapshot, r0: Region) -> Vec<Region> {
         while result_index < result_set.len() {
             // nb: can't use uint::range() here because result_set grows
             let r = result_set[result_index];
-            debug!("result_index={}, r={}", result_index, r);
+            debug!("result_index={}, r={:?}", result_index, r);
 
             for undo_entry in
                 self.undo_log.borrow().slice_from(mark.length).iter()
@@ -736,7 +736,7 @@ fn lub_concrete_regions(&self, a: Region, b: Region) -> Region {
             self.tcx.sess.bug(
                 format!("cannot relate bound region: LUB({}, {})",
                         a.repr(self.tcx),
-                        b.repr(self.tcx))[]);
+                        b.repr(self.tcx)).index(&FullRange));
           }
 
           (ReStatic, _) | (_, ReStatic) => {
@@ -751,9 +751,9 @@ fn lub_concrete_regions(&self, a: Region, b: Region) -> Region {
             self.tcx.sess.span_bug(
                 (*self.var_origins.borrow())[v_id.index as uint].span(),
                 format!("lub_concrete_regions invoked with \
-                         non-concrete regions: {}, {}",
+                         non-concrete regions: {:?}, {:?}",
                         a,
-                        b)[]);
+                        b).index(&FullRange));
           }
 
           (ReFree(ref fr), ReScope(s_id)) |
@@ -827,7 +827,7 @@ fn glb_concrete_regions(&self,
                             a: Region,
                             b: Region)
                          -> cres<'tcx, Region> {
-        debug!("glb_concrete_regions({}, {})", a, b);
+        debug!("glb_concrete_regions({:?}, {:?})", a, b);
         match (a, b) {
             (ReLateBound(..), _) |
             (_, ReLateBound(..)) |
@@ -836,7 +836,7 @@ fn glb_concrete_regions(&self,
               self.tcx.sess.bug(
                   format!("cannot relate bound region: GLB({}, {})",
                           a.repr(self.tcx),
-                          b.repr(self.tcx))[]);
+                          b.repr(self.tcx)).index(&FullRange));
             }
 
             (ReStatic, r) | (r, ReStatic) => {
@@ -854,9 +854,9 @@ fn glb_concrete_regions(&self,
                 self.tcx.sess.span_bug(
                     (*self.var_origins.borrow())[v_id.index as uint].span(),
                     format!("glb_concrete_regions invoked with \
-                             non-concrete regions: {}, {}",
+                             non-concrete regions: {:?}, {:?}",
                             a,
-                            b)[]);
+                            b).index(&FullRange));
             }
 
             (ReFree(ref fr), ReScope(s_id)) |
@@ -932,7 +932,7 @@ fn intersect_scopes(&self,
         // scopes or two free regions.  So, if one of
         // these scopes is a subscope of the other, return
         // it. Otherwise fail.
-        debug!("intersect_scopes(scope_a={}, scope_b={}, region_a={}, region_b={})",
+        debug!("intersect_scopes(scope_a={:?}, scope_b={:?}, region_a={:?}, region_b={:?})",
                scope_a, scope_b, region_a, region_b);
         match self.tcx.region_maps.nearest_common_ancestor(scope_a, scope_b) {
             Some(r_id) if scope_a == r_id => Ok(ReScope(scope_b)),
@@ -971,13 +971,13 @@ fn infer_variable_values(&self,
 
         // Dorky hack to cause `dump_constraints` to only get called
         // if debug mode is enabled:
-        debug!("----() End constraint listing {}---", self.dump_constraints());
+        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());
         let values =
-            self.extract_values_and_collect_conflicts(var_data[],
+            self.extract_values_and_collect_conflicts(var_data.index(&FullRange),
                                                       errors);
         self.collect_concrete_region_errors(&values, errors);
         values
@@ -1039,7 +1039,7 @@ fn expand_node(&self,
                    b_data: &mut VarData)
                    -> bool
     {
-        debug!("expand_node({}, {} == {})",
+        debug!("expand_node({}, {:?} == {})",
                a_region.repr(self.tcx),
                b_vid,
                b_data.value.repr(self.tcx));
@@ -1058,7 +1058,7 @@ fn expand_node(&self,
         b_data.classification = Expanding;
         match b_data.value {
           NoValue => {
-            debug!("Setting initial value of {} to {}",
+            debug!("Setting initial value of {:?} to {}",
                    b_vid, a_region.repr(self.tcx));
 
             b_data.value = Value(a_region);
@@ -1071,7 +1071,7 @@ fn expand_node(&self,
                 return false;
             }
 
-            debug!("Expanding value of {} from {} to {}",
+            debug!("Expanding value of {:?} from {} to {}",
                    b_vid,
                    cur_region.repr(self.tcx),
                    lub.repr(self.tcx));
@@ -1122,7 +1122,7 @@ fn contract_node(&self,
                      a_data: &mut VarData,
                      b_region: Region)
                      -> bool {
-        debug!("contract_node({} == {}/{}, {})",
+        debug!("contract_node({:?} == {}/{:?}, {})",
                a_vid, a_data.value.repr(self.tcx),
                a_data.classification, b_region.repr(self.tcx));
 
@@ -1156,7 +1156,7 @@ fn check_node(this: &RegionVarBindings,
                       b_region: Region)
                    -> bool {
             if !this.is_subregion_of(a_region, b_region) {
-                debug!("Setting {} to ErrorValue: {} not subregion of {}",
+                debug!("Setting {:?} to ErrorValue: {} not subregion of {}",
                        a_vid,
                        a_region.repr(this.tcx),
                        b_region.repr(this.tcx));
@@ -1176,7 +1176,7 @@ fn adjust_node(this: &RegionVarBindings,
                     if glb == a_region {
                         false
                     } else {
-                        debug!("Contracting value of {} from {} to {}",
+                        debug!("Contracting value of {:?} from {} to {}",
                                a_vid,
                                a_region.repr(this.tcx),
                                glb.repr(this.tcx));
@@ -1185,7 +1185,7 @@ fn adjust_node(this: &RegionVarBindings,
                     }
                 }
                 Err(_) => {
-                    debug!("Setting {} to ErrorValue: no glb of {}, {}",
+                    debug!("Setting {:?} to ErrorValue: no glb of {}, {}",
                            a_vid,
                            a_region.repr(this.tcx),
                            b_region.repr(this.tcx));
@@ -1412,10 +1412,10 @@ fn free_regions_first(a: &RegionAndOrigin,
         self.tcx.sess.span_bug(
             (*self.var_origins.borrow())[node_idx.index as uint].span(),
             format!("collect_error_for_expanding_node() could not find error \
-                    for var {}, lower_bounds={}, upper_bounds={}",
+                    for var {:?}, lower_bounds={}, upper_bounds={}",
                     node_idx,
                     lower_bounds.repr(self.tcx),
-                    upper_bounds.repr(self.tcx))[]);
+                    upper_bounds.repr(self.tcx)).index(&FullRange));
     }
 
     fn collect_error_for_contracting_node(
@@ -1457,9 +1457,9 @@ fn collect_error_for_contracting_node(
         self.tcx.sess.span_bug(
             (*self.var_origins.borrow())[node_idx.index as uint].span(),
             format!("collect_error_for_contracting_node() could not find error \
-                     for var {}, upper_bounds={}",
+                     for var {:?}, upper_bounds={}",
                     node_idx,
-                    upper_bounds.repr(self.tcx))[]);
+                    upper_bounds.repr(self.tcx)).index(&FullRange));
     }
 
     fn collect_concrete_regions(&self,
@@ -1498,8 +1498,8 @@ struct WalkState<'tcx> {
                 state.dup_found = true;
             }
 
-            debug!("collect_concrete_regions(orig_node_idx={}, node_idx={}, \
-                    classification={})",
+            debug!("collect_concrete_regions(orig_node_idx={:?}, node_idx={:?}, \
+                    classification={:?})",
                    orig_node_idx, node_idx, classification);
 
             // figure out the direction from which this node takes its
@@ -1520,7 +1520,7 @@ fn process_edges<'a, 'tcx>(this: &RegionVarBindings<'a, 'tcx>,
                          graph: &RegionGraph,
                          source_vid: RegionVid,
                          dir: Direction) {
-            debug!("process_edges(source_vid={}, dir={})", source_vid, dir);
+            debug!("process_edges(source_vid={:?}, dir={:?})", source_vid, dir);
 
             let source_node_index = NodeIndex(source_vid.index as uint);
             graph.each_adjacent_edge(source_node_index, dir, |_, edge| {
index 3ed866d4aba8f6a59e3cf21f272a228f405b8b10..9035d72e9a2fb633443a928ed7441d04779b6e6a 100644 (file)
@@ -96,7 +96,7 @@ fn fold_ty(&mut self, t: Ty<'tcx>) -> Ty<'tcx> {
                 ty::ty_infer(_) => {
                     self.infcx.tcx.sess.bug(
                         format!("Unexpected type in full type resolver: {}",
-                                t.repr(self.infcx.tcx))[]);
+                                t.repr(self.infcx.tcx)).index(&FullRange));
                 }
                 _ => {
                     ty_fold::super_fold_ty(self, t)
index 2aacc863f54c9ea1780193f4d1fc96f60dd0bb6d..3f3e4c50e70479591b86bb15a3b67ac4cc94b8f4 100644 (file)
@@ -184,7 +184,7 @@ pub fn types_escaping_snapshot(&self, s: &Snapshot) -> Vec<Ty<'tcx>> {
                         let escaping_type = self.probe(vid).unwrap();
                         escaping_types.push(escaping_type);
                     }
-                    debug!("SpecifyVar({}) new_elem_threshold={}", vid, new_elem_threshold);
+                    debug!("SpecifyVar({:?}) new_elem_threshold={}", vid, new_elem_threshold);
                 }
 
                 _ => { }
index 73da96445934c53e51da700b17e5483b47a2cc8b..4fa8e07ddd4f1ddd3d702d75d71f950a6d052bb8 100644 (file)
@@ -10,7 +10,7 @@
 
 pub use self::VarValue::*;
 
-use std::kinds::marker;
+use std::marker;
 
 use middle::ty::{expected_found, IntVarValue};
 use middle::ty::{self, Ty};
@@ -129,7 +129,7 @@ pub fn commit(&mut self, snapshot: Snapshot<K>) {
     pub fn new_key(&mut self, value: V) -> K {
         let index = self.values.push(Root(value, 0));
         let k = UnifyKey::from_index(index);
-        debug!("{}: created new key: {}",
+        debug!("{}: created new key: {:?}",
                UnifyKey::tag(None::<K>),
                k);
         k
index a83416667abdc331eaf8534011977c4826e8fa00..bd96a8a0f2cd78f980ea42ecb19fcb9749f59321 100644 (file)
@@ -205,11 +205,11 @@ fn with_each_combination(&self,
                 debug!("with_each_combination(substs={})",
                        substs.repr(self.tcx));
 
-                callback.call_mut((substs,));
+                callback(substs);
             }
 
             Some((space, index, &param_ty)) => {
-                debug!("with_each_combination: space={}, index={}, param_ty={}",
+                debug!("with_each_combination: space={:?}, index={}, param_ty={}",
                        space, index, param_ty.repr(self.tcx));
 
                 if !ty::type_is_sized(param_env, span, param_ty) {
index bbb11b9f93bbdde2f3e805ed32210c8dcc021b7f..2f81d8c0f701e4f10611bd0374e6e524a3343ae0 100644 (file)
@@ -266,8 +266,6 @@ pub fn collect_language_items(krate: &ast::Crate,
     ShrTraitLangItem,                "shr",                     shr_trait;
     IndexTraitLangItem,              "index",                   index_trait;
     IndexMutTraitLangItem,           "index_mut",               index_mut_trait;
-    SliceTraitLangItem,              "slice",                   slice_trait;
-    SliceMutTraitLangItem,           "slice_mut",               slice_mut_trait;
     RangeStructLangItem,             "range",                   range_struct;
     RangeFromStructLangItem,         "range_from",              range_from_struct;
     RangeToStructLangItem,           "range_to",                range_to_struct;
index 77875139be3a3fd5f22d9436a019b44afaba3971..850033b3ed126a0c65d0db7cceaf020561a01b55 100644 (file)
 use middle::def::*;
 use middle::mem_categorization::Typer;
 use middle::pat_util;
+use middle::region::CodeExtent;
 use middle::ty;
 use middle::ty::UnboxedClosureTyper;
 use lint;
@@ -289,7 +290,7 @@ fn add_live_node(&mut self, lnk: LiveNodeKind) -> LiveNode {
         self.lnks.push(lnk);
         self.num_live_nodes += 1;
 
-        debug!("{} is of kind {}", ln.to_string(),
+        debug!("{:?} is of kind {}", ln,
                live_node_kind_to_string(lnk, self.tcx));
 
         ln
@@ -299,7 +300,7 @@ fn add_live_node_for_node(&mut self, node_id: NodeId, lnk: LiveNodeKind) {
         let ln = self.add_live_node(lnk);
         self.live_node_map.insert(node_id, ln);
 
-        debug!("{} is node {}", ln.to_string(), node_id);
+        debug!("{:?} is node {}", ln, node_id);
     }
 
     fn add_variable(&mut self, vk: VarKind) -> Variable {
@@ -314,7 +315,7 @@ fn add_variable(&mut self, vk: VarKind) -> Variable {
             ImplicitRet | CleanExit => {}
         }
 
-        debug!("{} is {}", v.to_string(), vk);
+        debug!("{:?} is {:?}", v, vk);
 
         v
     }
@@ -326,7 +327,7 @@ fn variable(&self, node_id: NodeId, span: Span) -> Variable {
             self.tcx
                 .sess
                 .span_bug(span, format!("no variable registered for id {}",
-                                        node_id)[]);
+                                        node_id).index(&FullRange));
           }
         }
     }
@@ -377,7 +378,7 @@ fn visit_fn(ir: &mut IrMaps,
     // swap in a new set of IR maps for this function body:
     let mut fn_maps = IrMaps::new(ir.tcx);
 
-    debug!("creating fn_maps: {}", &fn_maps as *const IrMaps);
+    debug!("creating fn_maps: {:?}", &fn_maps as *const IrMaps);
 
     for arg in decl.inputs.iter() {
         pat_util::pat_bindings(&ir.tcx.def_map,
@@ -430,7 +431,7 @@ fn visit_local(ir: &mut IrMaps, local: &ast::Local) {
 fn visit_arm(ir: &mut IrMaps, arm: &ast::Arm) {
     for pat in arm.pats.iter() {
         pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
-            debug!("adding local variable {} from match with bm {}",
+            debug!("adding local variable {} from match with bm {:?}",
                    p_id, bm);
             let name = path1.node;
             ir.add_live_node_for_node(p_id, VarDefNode(sp));
@@ -448,7 +449,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
       // live nodes required for uses or definitions of variables:
       ast::ExprPath(_) => {
         let def = ir.tcx.def_map.borrow()[expr.id].clone();
-        debug!("expr {}: path that leads to {}", expr.id, def);
+        debug!("expr {}: path that leads to {:?}", expr.id, def);
         if let DefLocal(..) = def {
             ir.add_live_node_for_node(expr.id, ExprNode(expr.span));
         }
@@ -491,7 +492,7 @@ fn visit_expr(ir: &mut IrMaps, expr: &Expr) {
       }
       ast::ExprForLoop(ref pat, _, _, _) => {
         pat_util::pat_bindings(&ir.tcx.def_map, &**pat, |bm, p_id, sp, path1| {
-            debug!("adding local variable {} from for loop with bm {}",
+            debug!("adding local variable {} from for loop with bm {:?}",
                    p_id, bm);
             let name = path1.node;
             ir.add_live_node_for_node(p_id, VarDefNode(sp));
@@ -597,7 +598,7 @@ fn live_node(&self, node_id: NodeId, span: Span) -> LiveNode {
             self.ir.tcx.sess.span_bug(
                 span,
                 format!("no live node registered for node {}",
-                        node_id)[]);
+                        node_id).index(&FullRange));
           }
         }
     }
@@ -702,7 +703,7 @@ fn write_vars<F>(&self,
         for var_idx in range(0u, self.ir.num_vars) {
             let idx = node_base_idx + var_idx;
             if test(idx).is_valid() {
-                try!(write!(wr, " {}", Variable(var_idx).to_string()));
+                try!(write!(wr, " {:?}", Variable(var_idx)));
             }
         }
         Ok(())
@@ -740,11 +741,11 @@ fn ln_str(&self, ln: LiveNode) -> String {
         let mut wr = Vec::new();
         {
             let wr = &mut wr as &mut io::Writer;
-            write!(wr, "[ln({}) of kind {} reads", ln.get(), self.ir.lnk(ln));
+            write!(wr, "[ln({:?}) of kind {:?} reads", ln.get(), self.ir.lnk(ln));
             self.write_vars(wr, ln, |idx| self.users[idx].reader);
             write!(wr, "  writes");
             self.write_vars(wr, ln, |idx| self.users[idx].writer);
-            write!(wr, "  precedes {}]", self.successors[ln.get()].to_string());
+            write!(wr, "  precedes {:?}]", self.successors[ln.get()]);
         }
         String::from_utf8(wr).unwrap()
     }
@@ -792,8 +793,8 @@ fn merge_from_succ(&mut self,
             }
         });
 
-        debug!("merge_from_succ(ln={}, succ={}, first_merge={}, changed={})",
-               ln.to_string(), self.ln_str(succ_ln), first_merge, changed);
+        debug!("merge_from_succ(ln={:?}, succ={}, first_merge={}, changed={})",
+               ln, self.ln_str(succ_ln), first_merge, changed);
         return changed;
 
         fn copy_if_invalid(src: LiveNode, dst: &mut LiveNode) -> bool {
@@ -814,14 +815,14 @@ fn define(&mut self, writer: LiveNode, var: Variable) {
         self.users[idx].reader = invalid_node();
         self.users[idx].writer = invalid_node();
 
-        debug!("{} defines {} (idx={}): {}", writer.to_string(), var.to_string(),
+        debug!("{:?} defines {:?} (idx={}): {}", writer, var,
                idx, self.ln_str(writer));
     }
 
     // Either read, write, or both depending on the acc bitset
     fn acc(&mut self, ln: LiveNode, var: Variable, acc: uint) {
-        debug!("{} accesses[{:x}] {}: {}",
-               ln.to_string(), acc, var.to_string(), self.ln_str(ln));
+        debug!("{:?} accesses[{:x}] {:?}: {}",
+               ln, acc, var, self.ln_str(ln));
 
         let idx = self.idx(ln, var);
         let user = &mut self.users[idx];
@@ -857,14 +858,14 @@ fn compute(&mut self, decl: &ast::FnDecl, body: &ast::Block) -> LiveNode {
               |this| this.propagate_through_fn_block(decl, body));
 
         // hack to skip the loop unless debug! is enabled:
-        debug!("^^ liveness computation results for body {} (entry={})",
+        debug!("^^ liveness computation results for body {} (entry={:?})",
                {
                    for ln_idx in range(0u, self.ir.num_live_nodes) {
-                       debug!("{}", self.ln_str(LiveNode(ln_idx)));
+                       debug!("{:?}", self.ln_str(LiveNode(ln_idx)));
                    }
                    body.id
                },
-               entry_ln.to_string());
+               entry_ln);
 
         entry_ln
     }
@@ -1132,7 +1133,7 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
           // Uninteresting cases: just propagate in rev exec order
 
           ast::ExprVec(ref exprs) => {
-            self.propagate_through_exprs(exprs[], succ)
+            self.propagate_through_exprs(exprs.index(&FullRange), succ)
           }
 
           ast::ExprRepeat(ref element, ref count) => {
@@ -1149,32 +1150,31 @@ fn propagate_through_expr(&mut self, expr: &Expr, succ: LiveNode)
 
           ast::ExprCall(ref f, ref args) => {
             let diverges = !self.ir.tcx.is_method_call(expr.id) && {
-                let t_ret = ty::ty_fn_ret(ty::expr_ty_adjusted(self.ir.tcx, &**f));
-                t_ret == ty::FnDiverging
+                ty::ty_fn_ret(ty::expr_ty_adjusted(self.ir.tcx, &**f)).diverges()
             };
             let succ = if diverges {
                 self.s.exit_ln
             } else {
                 succ
             };
-            let succ = self.propagate_through_exprs(args[], succ);
+            let succ = self.propagate_through_exprs(args.index(&FullRange), succ);
             self.propagate_through_expr(&**f, succ)
           }
 
           ast::ExprMethodCall(_, _, ref args) => {
             let method_call = ty::MethodCall::expr(expr.id);
             let method_ty = self.ir.tcx.method_map.borrow().get(&method_call).unwrap().ty;
-            let diverges = ty::ty_fn_ret(method_ty) == ty::FnDiverging;
+            let diverges = ty::ty_fn_ret(method_ty).diverges();
             let succ = if diverges {
                 self.s.exit_ln
             } else {
                 succ
             };
-            self.propagate_through_exprs(args[], succ)
+            self.propagate_through_exprs(args.index(&FullRange), succ)
           }
 
           ast::ExprTup(ref exprs) => {
-            self.propagate_through_exprs(exprs[], succ)
+            self.propagate_through_exprs(exprs.index(&FullRange), succ)
           }
 
           ast::ExprBinary(op, ref l, ref r) if ast_util::lazy_binop(op) => {
@@ -1514,11 +1514,11 @@ fn check_fn(_v: &Liveness,
 }
 
 impl<'a, 'tcx> Liveness<'a, 'tcx> {
-    fn fn_ret(&self, id: NodeId) -> ty::FnOutput<'tcx> {
+    fn fn_ret(&self, id: NodeId) -> ty::PolyFnOutput<'tcx> {
         let fn_ty = ty::node_id_to_type(self.ir.tcx, id);
         match fn_ty.sty {
             ty::ty_unboxed_closure(closure_def_id, _, substs) =>
-                self.ir.tcx.unboxed_closure_type(closure_def_id, substs).sig.0.output,
+                self.ir.tcx.unboxed_closure_type(closure_def_id, substs).sig.output(),
             _ =>
                 ty::ty_fn_ret(fn_ty),
         }
@@ -1529,8 +1529,16 @@ fn check_ret(&self,
                  sp: Span,
                  _fk: FnKind,
                  entry_ln: LiveNode,
-                 body: &ast::Block) {
-        match self.fn_ret(id) {
+                 body: &ast::Block)
+    {
+        // within the fn body, late-bound regions are liberated:
+        let fn_ret =
+            ty::liberate_late_bound_regions(
+                self.ir.tcx,
+                CodeExtent::from_node_id(body.id),
+                &self.fn_ret(id));
+
+        match fn_ret {
             ty::FnConverging(t_ret)
                 if self.live_on_entry(entry_ln, self.s.no_ret_var).is_some() => {
 
index 2b8c9b532e593270e035fbac2fde45769f3a6e42..b29c24c586114ff6492c2a32e89647bf069c4564 100644 (file)
@@ -482,28 +482,20 @@ pub fn cat_expr_unadjusted(&self, expr: &ast::Expr) -> McResult<cmt<'tcx>> {
             Ok(self.cat_tup_field(expr, base_cmt, idx.node, expr_ty))
           }
 
-          ast::ExprIndex(ref base, ref idx) => {
-            match idx.node {
-                ast::ExprRange(..) => {
-                    // Slicing syntax special case (KILLME).
-                    Ok(self.cat_rvalue_node(expr.id(), expr.span(), expr_ty))
+          ast::ExprIndex(ref base, _) => {
+            let method_call = ty::MethodCall::expr(expr.id());
+            match self.typer.node_method_ty(method_call) {
+                Some(method_ty) => {
+                    // If this is an index implemented by a method call, then it
+                    // will include an implicit deref of the result.
+                    let ret_ty = self.overloaded_method_return_ty(method_ty);
+                    self.cat_deref(expr,
+                                   self.cat_rvalue_node(expr.id(),
+                                                        expr.span(),
+                                                        ret_ty), 1, true)
                 }
-                _ => {
-                    let method_call = ty::MethodCall::expr(expr.id());
-                    match self.typer.node_method_ty(method_call) {
-                        Some(method_ty) => {
-                            // If this is an index implemented by a method call, then it will
-                            // include an implicit deref of the result.
-                            let ret_ty = ty::ty_fn_ret(method_ty).unwrap();
-                            self.cat_deref(expr,
-                                           self.cat_rvalue_node(expr.id(),
-                                                                expr.span(),
-                                                                ret_ty), 1, true)
-                        }
-                        None => {
-                            self.cat_index(expr, try!(self.cat_expr(&**base)))
-                        }
-                    }
+                None => {
+                    self.cat_index(expr, try!(self.cat_expr(&**base)))
                 }
             }
           }
@@ -547,7 +539,7 @@ pub fn cat_def(&self,
                    expr_ty: Ty<'tcx>,
                    def: def::Def)
                    -> McResult<cmt<'tcx>> {
-        debug!("cat_def: id={} expr={} def={}",
+        debug!("cat_def: id={} expr={} def={:?}",
                id, expr_ty.repr(self.tcx()), def);
 
         match def {
@@ -594,7 +586,7 @@ pub fn cat_def(&self,
                           span,
                           format!("Upvar of non-closure {} - {}",
                                   fn_node_id,
-                                  ty.repr(self.tcx()))[]);
+                                  ty.repr(self.tcx())).index(&FullRange));
                   }
               }
           }
@@ -860,12 +852,14 @@ fn cat_deref<N:ast_node>(&self,
         };
         let method_ty = self.typer.node_method_ty(method_call);
 
-        debug!("cat_deref: method_call={} method_ty={}",
+        debug!("cat_deref: method_call={:?} method_ty={:?}",
                method_call, method_ty.map(|ty| ty.repr(self.tcx())));
 
         let base_cmt = match method_ty {
             Some(method_ty) => {
-                let ref_ty = ty::ty_fn_ret(method_ty).unwrap();
+                let ref_ty =
+                    ty::assert_no_late_bound_regions(
+                        self.tcx(), &ty::ty_fn_ret(method_ty)).unwrap();
                 self.cat_rvalue_node(node.id(), node.span(), ref_ty)
             }
             None => base_cmt
@@ -945,9 +939,12 @@ pub fn cat_index<N:ast_node>(&self,
 
         let element_ty = match method_ty {
             Some(method_ty) => {
-                let ref_ty = ty::ty_fn_ret(method_ty).unwrap();
+                let ref_ty = self.overloaded_method_return_ty(method_ty);
                 base_cmt = self.cat_rvalue_node(elt.id(), elt.span(), ref_ty);
-                ty::ty_fn_args(method_ty)[0]
+
+                // FIXME(#20649) -- why are we using the `self_ty` as the element type...?
+                let self_ty = ty::ty_fn_sig(method_ty).input(0);
+                ty::assert_no_late_bound_regions(self.tcx(), &self_ty)
             }
             None => {
                 match ty::array_element_ty(self.tcx(), base_cmt.ty) {
@@ -1269,6 +1266,19 @@ fn cat_pattern_<F>(&self, cmt: cmt<'tcx>, pat: &ast::Pat, op: &mut F)
 
         Ok(())
     }
+
+    fn overloaded_method_return_ty(&self,
+                                   method_ty: Ty<'tcx>)
+                                   -> Ty<'tcx>
+    {
+        // When we process an overloaded `*` or `[]` etc, we often
+        // need to extract the return type of the method. These method
+        // types are generated by method resolution and always have
+        // all late-bound regions fully instantiated, so we just want
+        // to skip past the binder.
+        ty::assert_no_late_bound_regions(self.tcx(), &ty::ty_fn_ret(method_ty))
+            .unwrap() // overloaded ops do not diverge, either
+    }
 }
 
 #[derive(Copy)]
@@ -1455,7 +1465,7 @@ fn upvar_to_string(upvar: &Upvar, is_copy: bool) -> String {
 
 impl<'tcx> Repr<'tcx> for cmt_<'tcx> {
     fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
-        format!("{{{} id:{} m:{} ty:{}}}",
+        format!("{{{} id:{} m:{:?} ty:{}}}",
                 self.cat.repr(tcx),
                 self.id,
                 self.mutbl,
@@ -1470,7 +1480,7 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
             cat_rvalue(..) |
             cat_local(..) |
             cat_upvar(..) => {
-                format!("{}", *self)
+                format!("{:?}", *self)
             }
             cat_deref(ref cmt, derefs, ptr) => {
                 format!("{}-{}{}->", cmt.cat.repr(tcx), ptr_sigil(ptr), derefs)
index 50e328ef0e3c35b9f4be4ec026fcc9c841ce25c1..861c4a2c85e356b52f6750833e6fe10cc4fc4024 100644 (file)
@@ -435,28 +435,28 @@ fn nodestr(&self, id: ast::NodeId) -> String {
     fn def_privacy(&self, did: ast::DefId) -> PrivacyResult {
         if !is_local(did) {
             if self.external_exports.contains(&did) {
-                debug!("privacy - {} was externally exported", did);
+                debug!("privacy - {:?} was externally exported", did);
                 return Allowable;
             }
-            debug!("privacy - is {} a public method", did);
+            debug!("privacy - is {:?} a public method", did);
 
             return match self.tcx.impl_or_trait_items.borrow().get(&did) {
                 Some(&ty::MethodTraitItem(ref meth)) => {
-                    debug!("privacy - well at least it's a method: {}",
+                    debug!("privacy - well at least it's a method: {:?}",
                            *meth);
                     match meth.container {
                         ty::TraitContainer(id) => {
-                            debug!("privacy - recursing on trait {}", id);
+                            debug!("privacy - recursing on trait {:?}", id);
                             self.def_privacy(id)
                         }
                         ty::ImplContainer(id) => {
                             match ty::impl_trait_ref(self.tcx, id) {
                                 Some(t) => {
-                                    debug!("privacy - impl of trait {}", id);
+                                    debug!("privacy - impl of trait {:?}", id);
                                     self.def_privacy(t.def_id)
                                 }
                                 None => {
-                                    debug!("privacy - found a method {}",
+                                    debug!("privacy - found a method {:?}",
                                             meth.vis);
                                     if meth.vis == ast::Public {
                                         Allowable
@@ -471,17 +471,17 @@ fn def_privacy(&self, did: ast::DefId) -> PrivacyResult {
                 Some(&ty::TypeTraitItem(ref typedef)) => {
                     match typedef.container {
                         ty::TraitContainer(id) => {
-                            debug!("privacy - recursing on trait {}", id);
+                            debug!("privacy - recursing on trait {:?}", id);
                             self.def_privacy(id)
                         }
                         ty::ImplContainer(id) => {
                             match ty::impl_trait_ref(self.tcx, id) {
                                 Some(t) => {
-                                    debug!("privacy - impl of trait {}", id);
+                                    debug!("privacy - impl of trait {:?}", id);
                                     self.def_privacy(t.def_id)
                                 }
                                 None => {
-                                    debug!("privacy - found a typedef {}",
+                                    debug!("privacy - found a typedef {:?}",
                                             typedef.vis);
                                     if typedef.vis == ast::Public {
                                         Allowable
@@ -615,10 +615,10 @@ fn report_error(&self, result: CheckResult) -> bool {
         match result {
             None => true,
             Some((span, msg, note)) => {
-                self.tcx.sess.span_err(span, msg[]);
+                self.tcx.sess.span_err(span, msg.index(&FullRange));
                 match note {
                     Some((span, msg)) => {
-                        self.tcx.sess.span_note(span, msg[])
+                        self.tcx.sess.span_note(span, msg.index(&FullRange))
                     }
                     None => {},
                 }
@@ -696,7 +696,7 @@ fn check_field(&mut self,
         let fields = ty::lookup_struct_fields(self.tcx, id);
         let field = match name {
             NamedField(ident) => {
-                debug!("privacy - check named field {} in struct {}", ident.name, id);
+                debug!("privacy - check named field {} in struct {:?}", ident.name, id);
                 fields.iter().find(|f| f.name == ident.name).unwrap()
             }
             UnnamedField(idx) => &fields[idx]
@@ -720,7 +720,7 @@ fn check_field(&mut self,
             UnnamedField(idx) => format!("field #{} of {} is private",
                                          idx + 1, struct_desc),
         };
-        self.tcx.sess.span_err(span, msg[]);
+        self.tcx.sess.span_err(span, msg.index(&FullRange));
     }
 
     // Given the ID of a method, checks to ensure it's in scope.
@@ -742,7 +742,7 @@ fn check_static_method(&mut self,
                                              method_id,
                                              None,
                                              format!("method `{}`",
-                                                     string)[]));
+                                                     string).index(&FullRange)));
     }
 
     // Checks that a path is in scope.
@@ -756,7 +756,7 @@ fn check_path(&mut self, span: Span, path_id: ast::NodeId, path: &ast::Path) {
                 self.ensure_public(span,
                                    def,
                                    Some(origdid),
-                                   format!("{} `{}`", tyname, name)[])
+                                   format!("{} `{}`", tyname, name).index(&FullRange))
             };
 
             match self.last_private_map[path_id] {
index 5736e3072862aadc9b195f79e8829970cb9439f2..51602e88f9342c3dfe0a84ff545d448b54dcb15c 100644 (file)
@@ -50,7 +50,7 @@ fn generics_require_inlining(generics: &ast::Generics) -> bool {
 // monomorphized or it was marked with `#[inline]`. This will only return
 // true for functions.
 fn item_might_be_inlined(item: &ast::Item) -> bool {
-    if attributes_specify_inlining(item.attrs[]) {
+    if attributes_specify_inlining(item.attrs.index(&FullRange)) {
         return true
     }
 
@@ -65,7 +65,7 @@ fn item_might_be_inlined(item: &ast::Item) -> bool {
 
 fn method_might_be_inlined(tcx: &ty::ctxt, method: &ast::Method,
                            impl_src: ast::DefId) -> bool {
-    if attributes_specify_inlining(method.attrs[]) ||
+    if attributes_specify_inlining(method.attrs.index(&FullRange)) ||
         generics_require_inlining(method.pe_generics()) {
         return true
     }
@@ -202,7 +202,7 @@ fn def_id_represents_local_inlined_item(&self, def_id: ast::DefId) -> bool {
                     ast::MethodImplItem(ref method) => {
                         if generics_require_inlining(method.pe_generics()) ||
                                 attributes_specify_inlining(
-                                    method.attrs[]) {
+                                    method.attrs.index(&FullRange)) {
                             true
                         } else {
                             let impl_did = self.tcx
@@ -249,7 +249,7 @@ fn propagate(&mut self) {
                 None => {
                     self.tcx.sess.bug(format!("found unmapped ID in worklist: \
                                                {}",
-                                              search_item)[])
+                                              search_item).index(&FullRange))
                 }
             }
         }
@@ -341,7 +341,7 @@ fn propagate_node(&mut self, node: &ast_map::Node,
                     .bug(format!("found unexpected thingy in worklist: {}",
                                  self.tcx
                                      .map
-                                     .node_to_string(search_item))[])
+                                     .node_to_string(search_item)).index(&FullRange))
             }
         }
     }
index 68e257bc0c5ec3079aacf457fa253bbad9e62024..5d18843097f37f7f4491faba54220232a2347c36 100644 (file)
@@ -146,24 +146,24 @@ pub fn relate_free_regions(&self, sub: FreeRegion, sup: FreeRegion) {
             None => {}
         }
 
-        debug!("relate_free_regions(sub={}, sup={})", sub, sup);
+        debug!("relate_free_regions(sub={:?}, sup={:?})", sub, sup);
         self.free_region_map.borrow_mut().insert(sub, vec!(sup));
     }
 
     pub fn record_encl_scope(&self, sub: CodeExtent, sup: CodeExtent) {
-        debug!("record_encl_scope(sub={}, sup={})", sub, sup);
+        debug!("record_encl_scope(sub={:?}, sup={:?})", sub, sup);
         assert!(sub != sup);
         self.scope_map.borrow_mut().insert(sub, sup);
     }
 
     pub fn record_var_scope(&self, var: ast::NodeId, lifetime: CodeExtent) {
-        debug!("record_var_scope(sub={}, sup={})", var, lifetime);
+        debug!("record_var_scope(sub={:?}, sup={:?})", var, lifetime);
         assert!(var != lifetime.node_id());
         self.var_map.borrow_mut().insert(var, lifetime);
     }
 
     pub fn record_rvalue_scope(&self, var: ast::NodeId, lifetime: CodeExtent) {
-        debug!("record_rvalue_scope(sub={}, sup={})", var, lifetime);
+        debug!("record_rvalue_scope(sub={:?}, sup={:?})", var, lifetime);
         assert!(var != lifetime.node_id());
         self.rvalue_scopes.borrow_mut().insert(var, lifetime);
     }
@@ -172,7 +172,7 @@ pub fn record_rvalue_scope(&self, var: ast::NodeId, lifetime: CodeExtent) {
     /// e.g. by an expression like `a().f` -- they will be freed within the innermost terminating
     /// scope.
     pub fn mark_as_terminating_scope(&self, scope_id: CodeExtent) {
-        debug!("record_terminating_scope(scope_id={})", scope_id);
+        debug!("record_terminating_scope(scope_id={:?})", scope_id);
         self.terminating_scopes.borrow_mut().insert(scope_id);
     }
 
@@ -186,7 +186,7 @@ pub fn encl_scope(&self, id: CodeExtent) -> CodeExtent {
         //! Returns the narrowest scope that encloses `id`, if any.
         match self.scope_map.borrow().get(&id) {
             Some(&r) => r,
-            None => { panic!("no enclosing scope for id {}", id); }
+            None => { panic!("no enclosing scope for id {:?}", id); }
         }
     }
 
@@ -194,7 +194,7 @@ pub fn encl_scope(&self, id: CodeExtent) -> CodeExtent {
     pub fn var_scope(&self, var_id: ast::NodeId) -> CodeExtent {
         match self.var_map.borrow().get(&var_id) {
             Some(&r) => r,
-            None => { panic!("no enclosing scope for id {}", var_id); }
+            None => { panic!("no enclosing scope for id {:?}", var_id); }
         }
     }
 
@@ -204,7 +204,7 @@ pub fn temporary_scope(&self, expr_id: ast::NodeId) -> Option<CodeExtent> {
         // check for a designated rvalue scope
         match self.rvalue_scopes.borrow().get(&expr_id) {
             Some(&s) => {
-                debug!("temporary_scope({}) = {} [custom]", expr_id, s);
+                debug!("temporary_scope({:?}) = {:?} [custom]", expr_id, s);
                 return Some(s);
             }
             None => { }
@@ -225,12 +225,12 @@ pub fn temporary_scope(&self, expr_id: ast::NodeId) -> Option<CodeExtent> {
                     id = p;
                 }
                 None => {
-                    debug!("temporary_scope({}) = None", expr_id);
+                    debug!("temporary_scope({:?}) = None", expr_id);
                     return None;
                 }
             }
         }
-        debug!("temporary_scope({}) = {} [enclosing]", expr_id, id);
+        debug!("temporary_scope({:?}) = {:?} [enclosing]", expr_id, id);
         return Some(id);
     }
 
@@ -238,7 +238,7 @@ pub fn var_region(&self, id: ast::NodeId) -> ty::Region {
         //! Returns the lifetime of the variable `id`.
 
         let scope = ty::ReScope(self.var_scope(id));
-        debug!("var_region({}) = {}", id, scope);
+        debug!("var_region({:?}) = {:?}", id, scope);
         scope
     }
 
@@ -258,7 +258,7 @@ pub fn is_subscope_of(&self,
         while superscope != s {
             match self.scope_map.borrow().get(&s) {
                 None => {
-                    debug!("is_subscope_of({}, {}, s={})=false",
+                    debug!("is_subscope_of({:?}, {:?}, s={:?})=false",
                            subscope, superscope, s);
 
                     return false;
@@ -267,7 +267,7 @@ pub fn is_subscope_of(&self,
             }
         }
 
-        debug!("is_subscope_of({}, {})=true",
+        debug!("is_subscope_of({:?}, {:?})=true",
                subscope, superscope);
 
         return true;
@@ -287,7 +287,7 @@ pub fn is_subregion_of(&self,
                            sub_region: ty::Region,
                            super_region: ty::Region)
                            -> bool {
-        debug!("is_subregion_of(sub_region={}, super_region={})",
+        debug!("is_subregion_of(sub_region={:?}, super_region={:?})",
                sub_region, super_region);
 
         sub_region == super_region || {
@@ -365,7 +365,7 @@ pub fn nearest_common_ancestor(&self,
 
         fn ancestors_of(this: &RegionMaps, scope: CodeExtent)
             -> Vec<CodeExtent> {
-            // debug!("ancestors_of(scope={})", scope);
+            // debug!("ancestors_of(scope={:?})", scope);
             let mut result = vec!(scope);
             let mut scope = scope;
             loop {
@@ -376,7 +376,7 @@ fn ancestors_of(this: &RegionMaps, scope: CodeExtent)
                         scope = superscope;
                     }
                 }
-                // debug!("ancestors_of_loop(scope={})", scope);
+                // debug!("ancestors_of_loop(scope={:?})", scope);
             }
         }
     }
@@ -414,7 +414,7 @@ fn record_var_lifetime(visitor: &mut RegionResolutionVisitor,
 }
 
 fn resolve_block(visitor: &mut RegionResolutionVisitor, blk: &ast::Block) {
-    debug!("resolve_block(blk.id={})", blk.id);
+    debug!("resolve_block(blk.id={:?})", blk.id);
 
     // Record the parent of this block.
     record_superlifetime(visitor, blk.id, blk.span);
@@ -466,7 +466,7 @@ fn resolve_pat(visitor: &mut RegionResolutionVisitor, pat: &ast::Pat) {
 
 fn resolve_stmt(visitor: &mut RegionResolutionVisitor, stmt: &ast::Stmt) {
     let stmt_id = stmt_id(stmt);
-    debug!("resolve_stmt(stmt.id={})", stmt_id);
+    debug!("resolve_stmt(stmt.id={:?})", stmt_id);
 
     let stmt_scope = CodeExtent::from_node_id(stmt_id);
     visitor.region_maps.mark_as_terminating_scope(stmt_scope);
@@ -479,7 +479,7 @@ fn resolve_stmt(visitor: &mut RegionResolutionVisitor, stmt: &ast::Stmt) {
 }
 
 fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &ast::Expr) {
-    debug!("resolve_expr(expr.id={})", expr.id);
+    debug!("resolve_expr(expr.id={:?})", expr.id);
 
     record_superlifetime(visitor, expr.id, expr.span);
 
@@ -566,7 +566,7 @@ fn resolve_expr(visitor: &mut RegionResolutionVisitor, expr: &ast::Expr) {
 }
 
 fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &ast::Local) {
-    debug!("resolve_local(local.id={},local.init={})",
+    debug!("resolve_local(local.id={:?},local.init={:?})",
            local.id,local.init.is_some());
 
     let blk_id = match visitor.cx.var_parent {
@@ -643,7 +643,7 @@ fn resolve_local(visitor: &mut RegionResolutionVisitor, local: &ast::Local) {
     // A, but the inner rvalues `a()` and `b()` have an extended lifetime
     // due to rule C.
     //
-    // FIXME(#6308) -- Note that `[]` patterns work more smoothly post-DST.
+    // FIXME(#6308) -- Note that `.index(&FullRange)` patterns work more smoothly post-DST.
 
     match local.init {
         Some(ref expr) => {
@@ -815,10 +815,10 @@ fn resolve_fn(visitor: &mut RegionResolutionVisitor,
               body: &ast::Block,
               sp: Span,
               id: ast::NodeId) {
-    debug!("region::resolve_fn(id={}, \
-                               span={}, \
-                               body.id={}, \
-                               cx.parent={})",
+    debug!("region::resolve_fn(id={:?}, \
+                               span={:?}, \
+                               body.id={:?}, \
+                               cx.parent={:?})",
            id,
            visitor.sess.codemap().span_to_string(sp),
            body.id,
index 68cb8ca39b492c323c833f5a1069daaa05cf05c0..8e03d774b812418544b92ac685941282cf1dfdf1 100644 (file)
@@ -223,7 +223,7 @@ fn visit_generics(&mut self, generics: &ast::Generics) {
     fn visit_poly_trait_ref(&mut self, trait_ref:
                             &ast::PolyTraitRef,
                             _modifier: &ast::TraitBoundModifier) {
-        debug!("visit_poly_trait_ref trait_ref={}", trait_ref);
+        debug!("visit_poly_trait_ref trait_ref={:?}", trait_ref);
 
         self.with(LateScope(&trait_ref.bound_lifetimes, self.scope), |old_scope, this| {
             this.check_lifetime_defs(old_scope, &trait_ref.bound_lifetimes);
@@ -250,9 +250,9 @@ fn with<F>(&mut self, wrap_scope: ScopeChain, f: F) where
             scope: &wrap_scope,
             def_map: self.def_map,
         };
-        debug!("entering scope {}", this.scope);
+        debug!("entering scope {:?}", this.scope);
         f(self.scope, &mut this);
-        debug!("exiting scope {}", this.scope);
+        debug!("exiting scope {:?}", this.scope);
     }
 
     /// Visits self by adding a scope and handling recursive walk over the contents with `walk`.
@@ -281,7 +281,7 @@ fn visit_early_late<F>(&mut self,
     {
         let referenced_idents = early_bound_lifetime_names(generics);
 
-        debug!("visit_early_late: referenced_idents={}",
+        debug!("visit_early_late: referenced_idents={:?}",
                referenced_idents);
 
         let (early, late): (Vec<_>, _) = generics.lifetimes.iter().cloned().partition(
@@ -399,7 +399,7 @@ fn unresolved_lifetime_ref(&self, lifetime_ref: &ast::Lifetime) {
         self.sess.span_err(
             lifetime_ref.span,
             format!("use of undeclared lifetime name `{}`",
-                    token::get_name(lifetime_ref.name))[]);
+                    token::get_name(lifetime_ref.name)).index(&FullRange));
     }
 
     fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::LifetimeDef>) {
@@ -413,7 +413,7 @@ fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::Lifetim
                         lifetime.lifetime.span,
                         format!("illegal lifetime parameter name: `{}`",
                                 token::get_name(lifetime.lifetime.name))
-                            []);
+                            .index(&FullRange));
                 }
             }
 
@@ -427,7 +427,7 @@ fn check_lifetime_defs(&mut self, old_scope: Scope, lifetimes: &Vec<ast::Lifetim
                         format!("lifetime name `{}` declared twice in \
                                 the same scope",
                                 token::get_name(lifetime_j.lifetime.name))
-                            []);
+                            .index(&FullRange));
                 }
             }
 
@@ -488,7 +488,7 @@ fn insert_lifetime(&mut self,
                                probably a bug in syntax::fold");
         }
 
-        debug!("lifetime_ref={} id={} resolved to {}",
+        debug!("lifetime_ref={:?} id={:?} resolved to {:?}",
                 lifetime_to_string(lifetime_ref),
                 lifetime_ref.id,
                 def);
@@ -605,9 +605,9 @@ fn shuffle(early_bound: &mut Vec<ast::Name>,
 impl<'a> fmt::Show for ScopeChain<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         match *self {
-            EarlyScope(space, defs, _) => write!(fmt, "EarlyScope({}, {})", space, defs),
-            LateScope(defs, _) => write!(fmt, "LateScope({})", defs),
-            BlockScope(id, _) => write!(fmt, "BlockScope({})", id),
+            EarlyScope(space, defs, _) => write!(fmt, "EarlyScope({:?}, {:?})", space, defs),
+            LateScope(defs, _) => write!(fmt, "LateScope({:?})", defs),
+            BlockScope(id, _) => write!(fmt, "BlockScope({:?})", id),
             RootScope => write!(fmt, "RootScope"),
         }
     }
index 362d5fedaa376f7463d235e7255947d0df1db1cb..359ad8d394129c09b027f503c0201de8b6827928 100644 (file)
@@ -161,7 +161,7 @@ pub fn lookup(tcx: &ty::ctxt, id: DefId) -> Option<Stability> {
     // is this definition the implementation of a trait method?
     match ty::trait_item_of_item(tcx, id) {
         Some(ty::MethodTraitItemId(trait_method_id)) if trait_method_id != id => {
-            debug!("lookup: trait_method_id={}", trait_method_id);
+            debug!("lookup: trait_method_id={:?}", trait_method_id);
             return lookup(tcx, trait_method_id)
         }
         _ => {}
@@ -182,7 +182,7 @@ pub fn lookup(tcx: &ty::ctxt, id: DefId) -> Option<Stability> {
             // stability of the trait to determine the stability of any
             // unmarked impls for it. See FIXME above for more details.
 
-            debug!("lookup: trait_id={}", trait_id);
+            debug!("lookup: trait_id={:?}", trait_id);
             lookup(tcx, trait_id)
         } else {
             None
index cd29ce28ac174f6aa15563fea3fe657694b74747..98bb0645befd10f488e7c0844f5926fe08a59ab7 100644 (file)
@@ -242,7 +242,7 @@ impl<T:fmt::Show> fmt::Show for VecPerParamSpace<T> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         try!(write!(fmt, "VecPerParamSpace {{"));
         for space in ParamSpace::all().iter() {
-            try!(write!(fmt, "{}: {}, ", *space, self.get_slice(*space)));
+            try!(write!(fmt, "{:?}: {:?}, ", *space, self.get_slice(*space)));
         }
         try!(write!(fmt, "}}"));
         Ok(())
@@ -601,10 +601,10 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
                                     span,
                                     format!("Type parameter out of range \
                                      when substituting in region {} (root type={}) \
-                                     (space={}, index={})",
+                                     (space={:?}, index={})",
                                     region_name.as_str(),
                                     self.root_ty.repr(self.tcx()),
-                                    space, i)[]);
+                                    space, i).index(&FullRange));
                             }
                         }
                 }
@@ -654,14 +654,14 @@ fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> {
                 let span = self.span.unwrap_or(DUMMY_SP);
                 self.tcx().sess.span_bug(
                     span,
-                    format!("Type parameter `{}` ({}/{}/{}) out of range \
+                    format!("Type parameter `{}` ({}/{:?}/{}) out of range \
                                  when substituting (root type={}) substs={}",
                             p.repr(self.tcx()),
                             source_ty.repr(self.tcx()),
                             p.space,
                             p.idx,
                             self.root_ty.repr(self.tcx()),
-                            self.substs.repr(self.tcx()))[]);
+                            self.substs.repr(self.tcx())).index(&FullRange));
             }
         };
 
@@ -711,7 +711,7 @@ fn ty_for_param(&self, p: ty::ParamTy, source_ty: Ty<'tcx>) -> Ty<'tcx> {
     /// first case we do not increase the Debruijn index and in the second case we do. The reason
     /// is that only in the second case have we passed through a fn binder.
     fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
-        debug!("shift_regions(ty={}, region_binders_passed={}, type_has_escaping_regions={})",
+        debug!("shift_regions(ty={:?}, region_binders_passed={:?}, type_has_escaping_regions={:?})",
                ty.repr(self.tcx()), self.region_binders_passed, ty::type_has_escaping_regions(ty));
 
         if self.region_binders_passed == 0 || !ty::type_has_escaping_regions(ty) {
@@ -719,7 +719,7 @@ fn shift_regions_through_binders(&self, ty: Ty<'tcx>) -> Ty<'tcx> {
         }
 
         let result = ty_fold::shift_regions(self.tcx(), self.region_binders_passed, &ty);
-        debug!("shift_regions: shifted result = {}", result.repr(self.tcx()));
+        debug!("shift_regions: shifted result = {:?}", result.repr(self.tcx()));
 
         result
     }
index 42b6e54420b409ed9e014e793f8e7e93e597a2a5..49c7d6aafaa5e4583057a7a5cad507d3f2a593c9 100644 (file)
@@ -137,7 +137,7 @@ fn ty_is_local_constructor<'tcx>(tcx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
         ty::ty_err => {
             tcx.sess.bug(
                 format!("ty_is_local invoked on unexpected type: {}",
-                        ty.repr(tcx))[])
+                        ty.repr(tcx)).index(&FullRange))
         }
     }
 }
index 59322fcc632e8296e99b07853cb94553ccf07c9d..fd6773afb765d055ed795aaa26feb21b25069ffe 100644 (file)
@@ -339,5 +339,5 @@ pub fn suggest_new_overflow_limit(tcx: &ty::ctxt, span: Span) {
         span,
         format!(
             "consider adding a `#![recursion_limit=\"{}\"]` attribute to your crate",
-            suggested_limit)[]);
+            suggested_limit).index(&FullRange));
 }
index c2327adece8e04dc274e6df1ad68fbfe6a6b2469..71a3ad64faf9ba965bd0d02fdbbae8604fc8a4c9 100644 (file)
@@ -227,7 +227,7 @@ pub fn select_where_possible<'a>(&mut self,
     }
 
     pub fn pending_obligations(&self) -> &[PredicateObligation<'tcx>] {
-        self.predicates[]
+        self.predicates.index(&FullRange)
     }
 
     /// Attempts to select obligations using `selcx`. If `only_new_obligations` is true, then it
@@ -437,11 +437,9 @@ fn register_region_obligation<'tcx>(tcx: &ty::ctxt<'tcx>,
     debug!("register_region_obligation({})",
            region_obligation.repr(tcx));
 
-    let body_id = region_obligation.cause.body_id;
-    match region_obligations.entry(&body_id) {
+    match region_obligations.entry(region_obligation.cause.body_id) {
         Vacant(entry) => { entry.insert(vec![region_obligation]); },
         Occupied(mut entry) => { entry.get_mut().push(region_obligation); },
     }
 
 }
-
index ce926fd8d10de3b1a6be0e54d0f4b2f611aa0867..3ef6694ce31c76f3793920dae07c55b44b47c02a 100644 (file)
@@ -297,7 +297,7 @@ pub fn evaluate_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
                                        span: Span)
                                        -> SelectionResult<'tcx, ()>
 {
-    debug!("type_known_to_meet_builtin_bound(ty={}, bound={})",
+    debug!("type_known_to_meet_builtin_bound(ty={}, bound={:?})",
            ty.repr(infcx.tcx),
            bound);
 
@@ -347,7 +347,7 @@ pub fn evaluate_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
         }
     };
 
-    debug!("type_known_to_meet_builtin_bound: ty={} bound={} result={}",
+    debug!("type_known_to_meet_builtin_bound: ty={} bound={:?} result={:?}",
            ty.repr(infcx.tcx),
            bound,
            result);
@@ -378,7 +378,7 @@ pub fn type_known_to_meet_builtin_bound<'a,'tcx>(infcx: &InferCtxt<'a,'tcx>,
                 span,
                 format!("overflow evaluating whether `{}` is `{}`",
                         ty.user_string(infcx.tcx),
-                        bound.user_string(infcx.tcx))[]);
+                        bound.user_string(infcx.tcx)).as_slice());
             suggest_new_overflow_limit(infcx.tcx, span);
             false
         }
index 60b7a90d27d05221b1febcb2212b93d2845275a3..aaf0d4fcb33ebdbeb63ae910b30a6c2ffeff7ab1 100644 (file)
@@ -178,7 +178,7 @@ fn object_safety_violations_for_method<'tcx>(tcx: &ty::ctxt<'tcx>,
     // The `Self` type is erased, so it should not appear in list of
     // arguments or return type apart from the receiver.
     let ref sig = method.fty.sig;
-    for &input_ty in sig.0.inputs[1..].iter() {
+    for &input_ty in sig.0.inputs.index(&(1..)).iter() {
         if contains_illegal_self_type_reference(tcx, trait_def_id, input_ty) {
             return Some(MethodViolationCode::ReferencesSelf);
         }
@@ -295,7 +295,7 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
             ObjectSafetyViolation::SizedSelf =>
                 format!("SizedSelf"),
             ObjectSafetyViolation::Method(ref m, code) =>
-                format!("Method({},{})", m.repr(tcx), code),
+                format!("Method({},{:?})", m.repr(tcx), code),
         }
     }
 }
index 165976ef7a322e54ad7356bc69f87133fdebe602..3e16e2965a665acbf019f3b461ecfb6804c4f0d6 100644 (file)
@@ -490,7 +490,7 @@ 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()))[]);
+                        object_ty.repr(selcx.tcx())).as_slice());
         }
     };
     let projection_bounds = data.projection_bounds_with_self_ty(selcx.tcx(), object_ty);
index 2db8e28616f91bd199a6732a1e5c455516724c49..7c8e0d90e11f70a4d69546d4c1a7b0ad5a50cc49 100644 (file)
@@ -368,7 +368,7 @@ fn evaluate_obligation_recursively<'o>(&mut self,
 
         let result = self.evaluate_stack(&stack);
 
-        debug!("result: {}", result);
+        debug!("result: {:?}", result);
         result
     }
 
@@ -903,7 +903,7 @@ fn assemble_candidates_from_caller_bounds(&mut self,
 
         let all_bounds =
             util::transitive_bounds(
-                self.tcx(), caller_trait_refs[]);
+                self.tcx(), caller_trait_refs.index(&FullRange));
 
         let matching_bounds =
             all_bounds.filter(
@@ -944,14 +944,14 @@ fn assemble_unboxed_closure_candidates(&mut self,
             _ => { return Ok(()); }
         };
 
-        debug!("assemble_unboxed_candidates: self_ty={} kind={} obligation={}",
+        debug!("assemble_unboxed_candidates: self_ty={} kind={:?} obligation={}",
                self_ty.repr(self.tcx()),
                kind,
                obligation.repr(self.tcx()));
 
         let closure_kind = self.closure_typer.unboxed_closure_kind(closure_def_id);
 
-        debug!("closure_kind = {}", closure_kind);
+        debug!("closure_kind = {:?}", closure_kind);
 
         if closure_kind == kind {
             candidates.vec.push(UnboxedClosureCandidate(closure_def_id, substs.clone()));
@@ -1102,7 +1102,7 @@ fn winnow_candidate<'o>(&mut self,
                 Err(error) => EvaluatedToErr(error),
             }
         });
-        debug!("winnow_candidate depth={} result={}",
+        debug!("winnow_candidate depth={} result={:?}",
                stack.obligation.recursion_depth, result);
         result
     }
@@ -1467,7 +1467,7 @@ fn builtin_bound(&mut self,
                 self.tcx().sess.bug(
                     format!(
                         "asked to assemble builtin bounds of unexpected type: {}",
-                        self_ty.repr(self.tcx()))[]);
+                        self_ty.repr(self.tcx())).index(&FullRange));
             }
         };
 
@@ -1637,7 +1637,7 @@ fn confirm_builtin_candidate(&mut self,
                 self.tcx().sess.span_bug(
                     obligation.cause.span,
                     format!("builtin bound for {} was ambig",
-                            obligation.repr(self.tcx()))[]);
+                            obligation.repr(self.tcx())).index(&FullRange));
             }
         }
     }
@@ -1716,7 +1716,7 @@ fn confirm_impl_candidate(&mut self,
             let substs =
                 self.rematch_impl(impl_def_id, obligation,
                                   snapshot, &skol_map, skol_obligation_trait_ref.trait_ref);
-            debug!("confirm_impl_candidate substs={}", substs);
+            debug!("confirm_impl_candidate substs={:?}", substs);
             Ok(self.vtable_impl(impl_def_id, substs, obligation.cause.clone(),
                                 obligation.recursion_depth + 1, skol_map, snapshot))
         })
@@ -1816,7 +1816,7 @@ fn confirm_fn_pointer_candidate(&mut self,
                 self.tcx().sess.span_bug(
                     obligation.cause.span,
                     format!("Fn pointer candidate for inappropriate self type: {}",
-                            self_ty.repr(self.tcx()))[]);
+                            self_ty.repr(self.tcx())).index(&FullRange));
             }
         };
 
@@ -1946,7 +1946,7 @@ fn rematch_impl(&mut self,
                 self.tcx().sess.bug(
                     format!("Impl {} was matchable against {} but now is not",
                             impl_def_id.repr(self.tcx()),
-                            obligation.repr(self.tcx()))[]);
+                            obligation.repr(self.tcx())).index(&FullRange));
             }
         }
     }
@@ -2225,7 +2225,7 @@ impl<'tcx> Repr<'tcx> for SelectionCandidate<'tcx> {
     fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             ErrorCandidate => format!("ErrorCandidate"),
-            BuiltinCandidate(b) => format!("BuiltinCandidate({})", b),
+            BuiltinCandidate(b) => format!("BuiltinCandidate({:?})", b),
             ParamCandidate(ref a) => format!("ParamCandidate({})", a.repr(tcx)),
             ImplCandidate(a) => format!("ImplCandidate({})", a.repr(tcx)),
             ProjectionCandidate => format!("ProjectionCandidate"),
@@ -2234,7 +2234,7 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
                 format!("ObjectCandidate")
             }
             UnboxedClosureCandidate(c, ref s) => {
-                format!("UnboxedClosureCandidate({},{})", c, s.repr(tcx))
+                format!("UnboxedClosureCandidate({:?},{})", c, s.repr(tcx))
             }
         }
     }
index 229d34fe4237c22df7a49a2cb08740c3f89c1fd7..272447027afd8f6d56e4269d44962e2560731274 100644 (file)
@@ -238,7 +238,7 @@ pub fn fresh_substs_for_impl<'a, 'tcx>(infcx: &InferCtxt<'a, 'tcx>,
 
 impl<'tcx, N> fmt::Show for VtableImplData<'tcx, N> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "VtableImpl({})", self.impl_def_id)
+        write!(f, "VtableImpl({:?})", self.impl_def_id)
     }
 }
 
@@ -451,8 +451,8 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
 impl<'tcx> fmt::Show for super::FulfillmentErrorCode<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
-            super::CodeSelectionError(ref e) => write!(f, "{}", e),
-            super::CodeProjectionError(ref e) => write!(f, "{}", e),
+            super::CodeSelectionError(ref e) => write!(f, "{:?}", e),
+            super::CodeProjectionError(ref e) => write!(f, "{:?}", e),
             super::CodeAmbiguity => write!(f, "Ambiguity")
         }
     }
index 864caf8a3fd780d47785e848370d874076a67c70..9b9a58178cc3487907a4ad4fb7fcbd6f21af299c 100644 (file)
@@ -1047,13 +1047,17 @@ pub struct ClosureTy<'tcx> {
     pub abi: abi::Abi,
 }
 
-#[derive(Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Clone, Copy, PartialEq, Eq, Hash, Show)]
 pub enum FnOutput<'tcx> {
     FnConverging(Ty<'tcx>),
     FnDiverging
 }
 
 impl<'tcx> FnOutput<'tcx> {
+    pub fn diverges(&self) -> bool {
+        *self == FnDiverging
+    }
+
     pub fn unwrap(self) -> Ty<'tcx> {
         match self {
             ty::FnConverging(t) => t,
@@ -1062,6 +1066,14 @@ pub fn unwrap(self) -> Ty<'tcx> {
     }
 }
 
+pub type PolyFnOutput<'tcx> = Binder<FnOutput<'tcx>>;
+
+impl<'tcx> PolyFnOutput<'tcx> {
+    pub fn diverges(&self) -> bool {
+        self.0.diverges()
+    }
+}
+
 /// Signature of a function type, which I have arbitrarily
 /// decided to use to refer to the input/output types.
 ///
@@ -1077,6 +1089,21 @@ pub struct FnSig<'tcx> {
 
 pub type PolyFnSig<'tcx> = Binder<FnSig<'tcx>>;
 
+impl<'tcx> PolyFnSig<'tcx> {
+    pub fn inputs(&self) -> ty::Binder<Vec<Ty<'tcx>>> {
+        ty::Binder(self.0.inputs.clone())
+    }
+    pub fn input(&self, index: uint) -> ty::Binder<Ty<'tcx>> {
+        ty::Binder(self.0.inputs[index])
+    }
+    pub fn output(&self) -> ty::Binder<FnOutput<'tcx>> {
+        ty::Binder(self.0.output.clone())
+    }
+    pub fn variadic(&self) -> bool {
+        self.0.variadic
+    }
+}
+
 #[derive(Clone, Copy, PartialEq, Eq, Hash, Show)]
 pub struct ParamTy {
     pub space: subst::ParamSpace,
@@ -1699,8 +1726,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 
 impl<'tcx> fmt::Show for FnSig<'tcx> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        // grr, without tcx not much we can do.
-        write!(f, "(...)")
+        write!(f, "({:?}; variadic: {})->{:?}", self.inputs, self.variadic, self.output)
     }
 }
 
@@ -1710,8 +1736,8 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             TyVar(ref v) => v.fmt(f),
             IntVar(ref v) => v.fmt(f),
             FloatVar(ref v) => v.fmt(f),
-            FreshTy(v) => write!(f, "FreshTy({})", v),
-            FreshIntTy(v) => write!(f, "FreshIntTy({})", v),
+            FreshTy(v) => write!(f, "FreshTy({:?})", v),
+            FreshIntTy(v) => write!(f, "FreshIntTy({:?})", v),
         }
     }
 }
@@ -2006,8 +2032,8 @@ pub fn to_opt_poly_trait_ref(&self) -> Option<PolyTraitRef<'tcx>> {
 ///     struct Foo<T,U:Bar<T>> { ... }
 ///
 /// Here, the `Generics` for `Foo` would contain a list of bounds like
-/// `[[], [U:Bar<T>]]`.  Now if there were some particular reference
-/// like `Foo<int,uint>`, then the `GenericBounds` would be `[[],
+/// `[.index(&FullRange), [U:Bar<T>]]`.  Now if there were some particular reference
+/// like `Foo<int,uint>`, then the `GenericBounds` would be `[.index(&FullRange),
 /// [uint:Bar<int>]]`.
 #[derive(Clone, Show)]
 pub struct GenericBounds<'tcx> {
@@ -2184,7 +2210,7 @@ pub fn for_item(cx: &'a ctxt<'tcx>, id: NodeId) -> ParameterEnvironment<'a, 'tcx
             _ => {
                 cx.sess.bug(format!("ParameterEnvironment::from_item(): \
                                      `{}` is not an item",
-                                    cx.map.node_to_string(id))[])
+                                    cx.map.node_to_string(id)).index(&FullRange))
             }
         }
     }
@@ -2269,7 +2295,7 @@ pub fn trait_did(&self, cx: &ctxt) -> ast::DefId {
         };
         match result {
             Ok(trait_did) => trait_did,
-            Err(err) => cx.sess.fatal(err[]),
+            Err(err) => cx.sess.fatal(err.index(&FullRange)),
         }
     }
 }
@@ -2302,12 +2328,12 @@ fn new(arena: &'tcx TypedArena<TyS<'tcx>>,
             bool: intern_ty(arena, interner, ty_bool),
             char: intern_ty(arena, interner, ty_char),
             err: intern_ty(arena, interner, ty_err),
-            int: intern_ty(arena, interner, ty_int(ast::TyI)),
+            int: intern_ty(arena, interner, ty_int(ast::TyIs)),
             i8: intern_ty(arena, interner, ty_int(ast::TyI8)),
             i16: intern_ty(arena, interner, ty_int(ast::TyI16)),
             i32: intern_ty(arena, interner, ty_int(ast::TyI32)),
             i64: intern_ty(arena, interner, ty_int(ast::TyI64)),
-            uint: intern_ty(arena, interner, ty_uint(ast::TyU)),
+            uint: intern_ty(arena, interner, ty_uint(ast::TyUs)),
             u8: intern_ty(arena, interner, ty_uint(ast::TyU8)),
             u16: intern_ty(arena, interner, ty_uint(ast::TyU16)),
             u32: intern_ty(arena, interner, ty_uint(ast::TyU32)),
@@ -2471,7 +2497,7 @@ fn intern_ty<'tcx>(type_arena: &'tcx TypedArena<TyS<'tcx>>,
         region_depth: flags.depth,
     });
 
-    debug!("Interned type: {} Pointer: {}",
+    debug!("Interned type: {:?} Pointer: {:?}",
            ty, ty as *const _);
 
     interner.insert(InternedTy { ty: ty }, ty);
@@ -2590,7 +2616,7 @@ fn add_sty(&mut self, st: &sty) {
             }
 
             &ty_tup(ref ts) => {
-                self.add_tys(ts[]);
+                self.add_tys(ts.index(&FullRange));
             }
 
             &ty_bare_fn(_, ref f) => {
@@ -2613,7 +2639,7 @@ fn add_tys(&mut self, tys: &[Ty]) {
     fn add_fn_sig(&mut self, fn_sig: &PolyFnSig) {
         let mut computation = FlagComputation::new();
 
-        computation.add_tys(fn_sig.0.inputs[]);
+        computation.add_tys(fn_sig.0.inputs.index(&FullRange));
 
         if let ty::FnConverging(output) = fn_sig.0.output {
             computation.add_ty(output);
@@ -2653,7 +2679,7 @@ fn add_bounds(&mut self, bounds: &ExistentialBounds) {
 
 pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
     match tm {
-        ast::TyI    => tcx.types.int,
+        ast::TyIs   => tcx.types.int,
         ast::TyI8   => tcx.types.i8,
         ast::TyI16  => tcx.types.i16,
         ast::TyI32  => tcx.types.i32,
@@ -2663,7 +2689,7 @@ pub fn mk_mach_int<'tcx>(tcx: &ctxt<'tcx>, tm: ast::IntTy) -> Ty<'tcx> {
 
 pub fn mk_mach_uint<'tcx>(tcx: &ctxt<'tcx>, tm: ast::UintTy) -> Ty<'tcx> {
     match tm {
-        ast::TyU    => tcx.types.uint,
+        ast::TyUs   => tcx.types.uint,
         ast::TyU8   => tcx.types.u8,
         ast::TyU16  => tcx.types.u16,
         ast::TyU32  => tcx.types.u32,
@@ -2782,7 +2808,7 @@ pub fn mk_trait<'tcx>(cx: &ctxt<'tcx>,
 
 fn bound_list_is_sorted(bounds: &[ty::PolyProjectionPredicate]) -> bool {
     bounds.len() == 0 ||
-        bounds[1..].iter().enumerate().all(
+        bounds.index(&(1..)).iter().enumerate().all(
             |(index, bound)| bounds[index].sort_key() <= bound.sort_key())
 }
 
@@ -3037,7 +3063,7 @@ pub fn sequence_element_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
         ty_str => mk_mach_uint(cx, ast::TyU8),
         ty_open(ty) => sequence_element_type(cx, ty),
         _ => cx.sess.bug(format!("sequence_element_type called on non-sequence value: {}",
-                                 ty_to_string(cx, ty))[]),
+                                 ty_to_string(cx, ty)).index(&FullRange)),
     }
 }
 
@@ -3324,7 +3350,7 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
 
         let result = match ty.sty {
             // uint and int are ffi-unsafe
-            ty_uint(ast::TyU) | ty_int(ast::TyI) => {
+            ty_uint(ast::TyUs) | ty_int(ast::TyIs) => {
                 TC::ReachesFfiUnsafe
             }
 
@@ -3371,7 +3397,7 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
             ty_struct(did, substs) => {
                 let flds = struct_fields(cx, did, substs);
                 let mut res =
-                    TypeContents::union(flds[],
+                    TypeContents::union(flds.index(&FullRange),
                                         |f| tc_mt(cx, f.mt, cache));
 
                 if !lookup_repr_hints(cx, did).contains(&attr::ReprExtern) {
@@ -3395,15 +3421,15 @@ fn tc_ty<'tcx>(cx: &ctxt<'tcx>,
             }
 
             ty_tup(ref tys) => {
-                TypeContents::union(tys[],
+                TypeContents::union(tys.index(&FullRange),
                                     |ty| tc_ty(cx, *ty, cache))
             }
 
             ty_enum(did, substs) => {
                 let variants = substd_enum_variants(cx, did, substs);
                 let mut res =
-                    TypeContents::union(variants[], |variant| {
-                        TypeContents::union(variant.args[],
+                    TypeContents::union(variants.index(&FullRange), |variant| {
+                        TypeContents::union(variant.args.index(&FullRange),
                                             |arg_ty| {
                             tc_ty(cx, *arg_ty, cache)
                         })
@@ -3533,7 +3559,7 @@ fn type_impls_bound<'a,'tcx>(param_env: &ParameterEnvironment<'a,'tcx>,
         match cache.borrow().get(&ty) {
             None => {}
             Some(&result) => {
-                debug!("type_impls_bound({}, {}) = {} (cached)",
+                debug!("type_impls_bound({}, {:?}) = {:?} (cached)",
                        ty.repr(param_env.tcx),
                        bound,
                        result);
@@ -3546,7 +3572,7 @@ fn type_impls_bound<'a,'tcx>(param_env: &ParameterEnvironment<'a,'tcx>,
 
     let is_impld = traits::type_known_to_meet_builtin_bound(&infcx, param_env, ty, bound, span);
 
-    debug!("type_impls_bound({}, {}) = {}",
+    debug!("type_impls_bound({}, {:?}) = {:?}",
            ty.repr(param_env.tcx),
            bound,
            is_impld);
@@ -3585,13 +3611,13 @@ pub fn is_ffi_safe<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
 pub fn is_instantiable<'tcx>(cx: &ctxt<'tcx>, r_ty: Ty<'tcx>) -> bool {
     fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
                            r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
-        debug!("type_requires({}, {})?",
+        debug!("type_requires({:?}, {:?})?",
                ::util::ppaux::ty_to_string(cx, r_ty),
                ::util::ppaux::ty_to_string(cx, ty));
 
         let r = r_ty == ty || subtypes_require(cx, seen, r_ty, ty);
 
-        debug!("type_requires({}, {})? {}",
+        debug!("type_requires({:?}, {:?})? {:?}",
                ::util::ppaux::ty_to_string(cx, r_ty),
                ::util::ppaux::ty_to_string(cx, ty),
                r);
@@ -3600,7 +3626,7 @@ fn type_requires<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
 
     fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
                               r_ty: Ty<'tcx>, ty: Ty<'tcx>) -> bool {
-        debug!("subtypes_require({}, {})?",
+        debug!("subtypes_require({:?}, {:?})?",
                ::util::ppaux::ty_to_string(cx, r_ty),
                ::util::ppaux::ty_to_string(cx, ty));
 
@@ -3655,7 +3681,8 @@ fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
             ty_unboxed_closure(..) => {
                 // this check is run on type definitions, so we don't expect to see
                 // inference by-products or unboxed closure types
-                cx.sess.bug(format!("requires check invoked on inapplicable type: {}", ty)[])
+                cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
+                                    ty).as_slice())
             }
 
             ty_tup(ref ts) => {
@@ -3680,7 +3707,7 @@ fn subtypes_require<'tcx>(cx: &ctxt<'tcx>, seen: &mut Vec<DefId>,
             }
         };
 
-        debug!("subtypes_require({}, {})? {}",
+        debug!("subtypes_require({:?}, {:?})? {:?}",
                ::util::ppaux::ty_to_string(cx, r_ty),
                ::util::ppaux::ty_to_string(cx, ty),
                r);
@@ -3748,7 +3775,8 @@ fn are_inner_types_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
             ty_unboxed_closure(..) => {
                 // this check is run on type definitions, so we don't expect to see
                 // unboxed closure types
-                cx.sess.bug(format!("requires check invoked on inapplicable type: {}", ty)[])
+                cx.sess.bug(format!("requires check invoked on inapplicable type: {:?}",
+                                    ty).as_slice())
             }
             _ => Representable,
         }
@@ -3789,7 +3817,7 @@ fn same_type<'tcx>(a: Ty<'tcx>, b: Ty<'tcx>) -> bool {
     fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
                                             seen: &mut Vec<Ty<'tcx>>,
                                             ty: Ty<'tcx>) -> Representability {
-        debug!("is_type_structurally_recursive: {}",
+        debug!("is_type_structurally_recursive: {:?}",
                ::util::ppaux::ty_to_string(cx, ty));
 
         match ty.sty {
@@ -3809,7 +3837,7 @@ fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
                     match iter.next() {
                         Some(&seen_type) => {
                             if same_struct_or_enum_def_id(seen_type, did) {
-                                debug!("SelfRecursive: {} contains {}",
+                                debug!("SelfRecursive: {:?} contains {:?}",
                                        ::util::ppaux::ty_to_string(cx, seen_type),
                                        ::util::ppaux::ty_to_string(cx, ty));
                                 return SelfRecursive;
@@ -3829,7 +3857,7 @@ fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
 
                     for &seen_type in iter {
                         if same_type(ty, seen_type) {
-                            debug!("ContainsRecursive: {} contains {}",
+                            debug!("ContainsRecursive: {:?} contains {:?}",
                                    ::util::ppaux::ty_to_string(cx, seen_type),
                                    ::util::ppaux::ty_to_string(cx, ty));
                             return ContainsRecursive;
@@ -3851,7 +3879,7 @@ fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
         }
     }
 
-    debug!("is_type_representable: {}",
+    debug!("is_type_representable: {:?}",
            ::util::ppaux::ty_to_string(cx, ty));
 
     // To avoid a stack overflow when checking an enum variant or struct that
@@ -3859,7 +3887,7 @@ fn is_type_structurally_recursive<'tcx>(cx: &ctxt<'tcx>, sp: Span,
     // of seen types and check recursion for each of them (issues #3008, #3779).
     let mut seen: Vec<Ty> = Vec::new();
     let r = is_type_structurally_recursive(cx, sp, &mut seen, ty);
-    debug!("is_type_representable: {} is {}",
+    debug!("is_type_representable: {:?} is {:?}",
            ::util::ppaux::ty_to_string(cx, ty), r);
     r
 }
@@ -3896,7 +3924,7 @@ pub fn type_is_fresh(ty: Ty) -> bool {
 
 pub fn type_is_uint(ty: Ty) -> bool {
     match ty.sty {
-      ty_infer(IntVar(_)) | ty_uint(ast::TyU) => true,
+      ty_infer(IntVar(_)) | ty_uint(ast::TyUs) => true,
       _ => false
     }
 }
@@ -3942,7 +3970,7 @@ pub fn type_is_signed(ty: Ty) -> bool {
 
 pub fn type_is_machine(ty: Ty) -> bool {
     match ty.sty {
-        ty_int(ast::TyI) | ty_uint(ast::TyU) => false,
+        ty_int(ast::TyIs) | ty_uint(ast::TyUs) => false,
         ty_int(..) | ty_uint(..) | ty_float(..) => true,
         _ => false
     }
@@ -3986,7 +4014,7 @@ pub fn close_type<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
     match ty.sty {
         ty_open(ty) => mk_rptr(cx, cx.mk_region(ReStatic), mt {ty: ty, mutbl:ast::MutImmutable}),
         _ => cx.sess.bug(format!("Trying to close a non-open type {}",
-                                 ty_to_string(cx, ty))[])
+                                 ty_to_string(cx, ty)).index(&FullRange))
     }
 }
 
@@ -4087,7 +4115,7 @@ pub fn node_id_to_trait_ref<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId)
         Some(ty) => ty.clone(),
         None => cx.sess.bug(
             format!("node_id_to_trait_ref: no trait ref for node `{}`",
-                    cx.map.node_to_string(id))[])
+                    cx.map.node_to_string(id)).index(&FullRange))
     }
 }
 
@@ -4100,7 +4128,7 @@ pub fn node_id_to_type<'tcx>(cx: &ctxt<'tcx>, id: ast::NodeId) -> Ty<'tcx> {
        Some(ty) => ty,
        None => cx.sess.bug(
            format!("node_id_to_type: no type for node `{}`",
-                   cx.map.node_to_string(id))[])
+                   cx.map.node_to_string(id)).index(&FullRange))
     }
 }
 
@@ -4122,7 +4150,7 @@ pub fn fn_is_variadic(fty: Ty) -> bool {
     match fty.sty {
         ty_bare_fn(_, ref f) => f.sig.0.variadic,
         ref s => {
-            panic!("fn_is_variadic() called on non-fn type: {}", s)
+            panic!("fn_is_variadic() called on non-fn type: {:?}", s)
         }
     }
 }
@@ -4131,7 +4159,7 @@ pub fn ty_fn_sig<'tcx>(fty: Ty<'tcx>) -> &'tcx PolyFnSig<'tcx> {
     match fty.sty {
         ty_bare_fn(_, ref f) => &f.sig,
         ref s => {
-            panic!("ty_fn_sig() called on non-fn type: {}", s)
+            panic!("ty_fn_sig() called on non-fn type: {:?}", s)
         }
     }
 }
@@ -4145,8 +4173,8 @@ pub fn ty_fn_abi(fty: Ty) -> abi::Abi {
 }
 
 // Type accessors for substructures of types
-pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> &'tcx [Ty<'tcx>] {
-    ty_fn_sig(fty).0.inputs.as_slice()
+pub fn ty_fn_args<'tcx>(fty: Ty<'tcx>) -> ty::Binder<Vec<Ty<'tcx>>> {
+    ty_fn_sig(fty).inputs()
 }
 
 pub fn ty_closure_store(fty: Ty) -> TraitStore {
@@ -4157,16 +4185,16 @@ pub fn ty_closure_store(fty: Ty) -> TraitStore {
             UniqTraitStore
         }
         ref s => {
-            panic!("ty_closure_store() called on non-closure type: {}", s)
+            panic!("ty_closure_store() called on non-closure type: {:?}", s)
         }
     }
 }
 
-pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> FnOutput<'tcx> {
+pub fn ty_fn_ret<'tcx>(fty: Ty<'tcx>) -> Binder<FnOutput<'tcx>> {
     match fty.sty {
-        ty_bare_fn(_, ref f) => f.sig.0.output,
+        ty_bare_fn(_, ref f) => f.sig.output(),
         ref s => {
-            panic!("ty_fn_ret() called on non-fn type: {}", s)
+            panic!("ty_fn_ret() called on non-fn type: {:?}", s)
         }
     }
 }
@@ -4186,8 +4214,8 @@ pub fn ty_region(tcx: &ctxt,
         ref s => {
             tcx.sess.span_bug(
                 span,
-                format!("ty_region() invoked on an inappropriate ty: {}",
-                        s)[]);
+                format!("ty_region() invoked on an inappropriate ty: {:?}",
+                        s).index(&FullRange));
         }
     }
 }
@@ -4246,13 +4274,13 @@ pub fn expr_span(cx: &ctxt, id: NodeId) -> Span {
             e.span
         }
         Some(f) => {
-            cx.sess.bug(format!("Node id {} is not an expr: {}",
+            cx.sess.bug(format!("Node id {} is not an expr: {:?}",
                                 id,
-                                f)[]);
+                                f).index(&FullRange));
         }
         None => {
             cx.sess.bug(format!("Node id {} is not present \
-                                in the node map", id)[]);
+                                in the node map", id).index(&FullRange));
         }
     }
 }
@@ -4266,16 +4294,16 @@ pub fn local_var_name_str(cx: &ctxt, id: NodeId) -> InternedString {
                 }
                 _ => {
                     cx.sess.bug(
-                        format!("Variable id {} maps to {}, not local",
+                        format!("Variable id {} maps to {:?}, not local",
                                 id,
-                                pat)[]);
+                                pat).index(&FullRange));
                 }
             }
         }
         r => {
-            cx.sess.bug(format!("Variable id {} maps to {}, not local",
+            cx.sess.bug(format!("Variable id {} maps to {:?}, not local",
                                 id,
-                                r)[]);
+                                r).index(&FullRange));
         }
     }
 }
@@ -4297,7 +4325,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
     return match adjustment {
         Some(adjustment) => {
             match *adjustment {
-                AdjustReifyFnPointer(_) => {
+               AdjustReifyFnPointer(_) => {
                     match unadjusted_ty.sty {
                         ty::ty_bare_fn(Some(_), b) => {
                             ty::mk_bare_fn(cx, None, b)
@@ -4305,8 +4333,8 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
                         ref b => {
                             cx.sess.bug(
                                 format!("AdjustReifyFnPointer adjustment on non-fn-item: \
-                                         {}",
-                                        b)[]);
+                                         {:?}",
+                                        b).index(&FullRange));
                         }
                     }
                 }
@@ -4319,9 +4347,12 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
                             let method_call = MethodCall::autoderef(expr_id, i);
                             match method_type(method_call) {
                                 Some(method_ty) => {
-                                    if let ty::FnConverging(result_type) = ty_fn_ret(method_ty) {
-                                        adjusted_ty = result_type;
-                                    }
+                                    // overloaded deref operators have all late-bound
+                                    // regions fully instantiated and coverge
+                                    let fn_ret =
+                                        ty::assert_no_late_bound_regions(cx,
+                                                                         &ty_fn_ret(method_ty));
+                                    adjusted_ty = fn_ret.unwrap();
                                 }
                                 None => {}
                             }
@@ -4334,7 +4365,7 @@ pub fn adjust_ty<'tcx, F>(cx: &ctxt<'tcx>,
                                                 {}",
                                                 i,
                                                 ty_to_string(cx, adjusted_ty))
-                                                          []);
+                                                          .index(&FullRange));
                                 }
                             }
                         }
@@ -4396,8 +4427,8 @@ pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
                 mk_vec(cx, ty, None)
             }
             _ => cx.sess.span_bug(span,
-                                  format!("UnsizeLength with bad sty: {}",
-                                          ty_to_string(cx, ty))[])
+                                  format!("UnsizeLength with bad sty: {:?}",
+                                          ty_to_string(cx, ty)).index(&FullRange))
         },
         &UnsizeStruct(box ref k, tp_index) => match ty.sty {
             ty_struct(did, substs) => {
@@ -4408,8 +4439,8 @@ pub fn unsize_ty<'tcx>(cx: &ctxt<'tcx>,
                 mk_struct(cx, did, cx.mk_substs(unsized_substs))
             }
             _ => cx.sess.span_bug(span,
-                                  format!("UnsizeStruct with bad sty: {}",
-                                          ty_to_string(cx, ty))[])
+                                  format!("UnsizeStruct with bad sty: {:?}",
+                                          ty_to_string(cx, ty)).index(&FullRange))
         },
         &UnsizeVtable(TyTrait { ref principal, ref bounds }, _) => {
             mk_trait(cx, principal.clone(), bounds.clone())
@@ -4422,7 +4453,7 @@ pub fn resolve_expr(tcx: &ctxt, expr: &ast::Expr) -> def::Def {
         Some(&def) => def,
         None => {
             tcx.sess.span_bug(expr.span, format!(
-                "no def-map entry for expr {}", expr.id)[]);
+                "no def-map entry for expr {}", expr.id).index(&FullRange));
         }
     }
 }
@@ -4515,9 +4546,9 @@ pub fn expr_kind(tcx: &ctxt, expr: &ast::Expr) -> ExprKind {
                 def => {
                     tcx.sess.span_bug(
                         expr.span,
-                        format!("uncategorized def for expr {}: {}",
+                        format!("uncategorized def for expr {}: {:?}",
                                 expr.id,
-                                def)[]);
+                                def).index(&FullRange));
                 }
             }
         }
@@ -4638,11 +4669,11 @@ pub fn field_idx_strict(tcx: &ctxt, name: ast::Name, fields: &[field])
     let mut i = 0u;
     for f in fields.iter() { if f.name == name { return i; } i += 1u; }
     tcx.sess.bug(format!(
-        "no field named `{}` found in the list of fields `{}`",
+        "no field named `{}` found in the list of fields `{:?}`",
         token::get_name(name),
         fields.iter()
               .map(|f| token::get_name(f.name).get().to_string())
-              .collect::<Vec<String>>())[]);
+              .collect::<Vec<String>>()).index(&FullRange));
 }
 
 pub fn impl_or_trait_item_idx(id: ast::Name, trait_items: &[ImplOrTraitItem])
@@ -4715,18 +4746,18 @@ fn tstore_to_closure(s: &TraitStore) -> String {
         terr_mismatch => "types differ".to_string(),
         terr_unsafety_mismatch(values) => {
             format!("expected {} fn, found {} fn",
-                    values.expected.to_string(),
-                    values.found.to_string())
+                    values.expected,
+                    values.found)
         }
         terr_abi_mismatch(values) => {
             format!("expected {} fn, found {} fn",
-                    values.expected.to_string(),
-                    values.found.to_string())
+                    values.expected,
+                    values.found)
         }
         terr_onceness_mismatch(values) => {
             format!("expected {} fn, found {} fn",
-                    values.expected.to_string(),
-                    values.found.to_string())
+                    values.expected,
+                    values.found)
         }
         terr_sigil_mismatch(values) => {
             format!("expected {}, found {}",
@@ -4818,14 +4849,14 @@ fn tstore_to_closure(s: &TraitStore) -> String {
             "expected an integral type, found `char`".to_string()
         }
         terr_int_mismatch(ref values) => {
-            format!("expected `{}`, found `{}`",
-                    values.expected.to_string(),
-                    values.found.to_string())
+            format!("expected `{:?}`, found `{:?}`",
+                    values.expected,
+                    values.found)
         }
         terr_float_mismatch(ref values) => {
-            format!("expected `{}`, found `{}`",
-                    values.expected.to_string(),
-                    values.found.to_string())
+            format!("expected `{:?}`, found `{:?}`",
+                    values.expected,
+                    values.found)
         }
         terr_variadic_mismatch(ref values) => {
             format!("expected {} fn, found {} function",
@@ -4897,7 +4928,7 @@ pub fn provided_trait_methods<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
                 match item.node {
                     ItemTrait(_, _, _, ref ms) => {
                         let (_, p) =
-                            ast_util::split_trait_methods(ms[]);
+                            ast_util::split_trait_methods(ms.index(&FullRange));
                         p.iter()
                          .map(|m| {
                             match impl_or_trait_item(
@@ -4914,16 +4945,16 @@ pub fn provided_trait_methods<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
                          }).collect()
                     }
                     _ => {
-                        cx.sess.bug(format!("provided_trait_methods: `{}` is \
+                        cx.sess.bug(format!("provided_trait_methods: `{:?}` is \
                                              not a trait",
-                                            id)[])
+                                            id).index(&FullRange))
                     }
                 }
             }
             _ => {
-                cx.sess.bug(format!("provided_trait_methods: `{}` is not a \
+                cx.sess.bug(format!("provided_trait_methods: `{:?}` is not a \
                                      trait",
-                                    id)[])
+                                    id).index(&FullRange))
             }
         }
     } else {
@@ -4950,7 +4981,7 @@ fn lookup_locally_or_in_crate_store<V, F>(descr: &str,
     }
 
     if def_id.krate == ast::LOCAL_CRATE {
-        panic!("No def'n found for {} in tcx.{}", def_id, descr);
+        panic!("No def'n found for {:?} in tcx.{}", def_id, descr);
     }
     let v = load_external();
     map.insert(def_id, v.clone());
@@ -5057,7 +5088,7 @@ pub fn impl_trait_ref<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
                             -> Option<Rc<TraitRef<'tcx>>> {
     memoized(&cx.impl_trait_cache, id, |id: ast::DefId| {
         if id.krate == ast::LOCAL_CRATE {
-            debug!("(impl_trait_ref) searching for trait impl {}", id);
+            debug!("(impl_trait_ref) searching for trait impl {:?}", id);
             match cx.map.find(id.node) {
                 Some(ast_map::NodeItem(item)) => {
                     match item.node {
@@ -5143,7 +5174,9 @@ pub fn from_ast_variant(cx: &ctxt<'tcx>,
         match ast_variant.node.kind {
             ast::TupleVariantKind(ref args) => {
                 let arg_tys = if args.len() > 0 {
-                    ty_fn_args(ctor_ty).iter().map(|a| *a).collect()
+                    // the regions in the argument types come from the
+                    // enum def'n, and hence will all be early bound
+                    ty::assert_no_late_bound_regions(cx, &ty_fn_args(ctor_ty))
                 } else {
                     Vec::new()
                 };
@@ -5159,8 +5192,7 @@ pub fn from_ast_variant(cx: &ctxt<'tcx>,
                 };
             },
             ast::StructVariantKind(ref struct_def) => {
-
-                let fields: &[StructField] = struct_def.fields[];
+                let fields: &[StructField] = struct_def.fields.index(&FullRange);
 
                 assert!(fields.len() > 0);
 
@@ -5311,7 +5343,7 @@ pub fn enum_variants<'tcx>(cx: &ctxt<'tcx>, id: ast::DefId)
                                                 cx.sess
                                                   .span_err(e.span,
                                                             format!("expected constant: {}",
-                                                                    *err)[]);
+                                                                    *err).index(&FullRange));
                                             }
                                         },
                                     None => {}
@@ -5377,7 +5409,7 @@ pub fn predicates_for_trait_ref<'tcx>(tcx: &ctxt<'tcx>,
 {
     let trait_def = lookup_trait_def(tcx, trait_ref.def_id());
 
-    debug!("bounds_for_trait_ref(trait_def={}, trait_ref={})",
+    debug!("bounds_for_trait_ref(trait_def={:?}, trait_ref={:?})",
            trait_def.repr(tcx), trait_ref.repr(tcx));
 
     // The interaction between HRTB and supertraits is not entirely
@@ -5584,7 +5616,7 @@ pub fn lookup_field_type<'tcx>(tcx: &ctxt<'tcx>,
         node_id_to_type(tcx, id.node)
     } else {
         let mut tcache = tcx.tcache.borrow_mut();
-        let pty = tcache.entry(&id).get().unwrap_or_else(
+        let pty = tcache.entry(id).get().unwrap_or_else(
             |vacant_entry| vacant_entry.insert(csearch::get_field_type(tcx, struct_id, id)));
         pty.ty
     };
@@ -5601,7 +5633,7 @@ pub fn lookup_struct_fields(cx: &ctxt, did: ast::DefId) -> Vec<field_ty> {
             _ => {
                 cx.sess.bug(
                     format!("ID not mapped to struct fields: {}",
-                            cx.map.node_to_string(did.node))[]);
+                            cx.map.node_to_string(did.node)).index(&FullRange));
             }
         }
     } else {
@@ -5634,7 +5666,7 @@ pub fn struct_fields<'tcx>(cx: &ctxt<'tcx>, did: ast::DefId, substs: &Substs<'tc
 pub fn tup_fields<'tcx>(v: &[Ty<'tcx>]) -> Vec<field<'tcx>> {
     v.iter().enumerate().map(|(i, &f)| {
        field {
-            name: token::intern(i.to_string()[]),
+            name: token::intern(i.to_string().index(&FullRange)),
             mt: mt {
                 ty: f,
                 mutbl: MutImmutable
@@ -5791,40 +5823,6 @@ fn tycat<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> int {
     return tbl[tycat(cx, ty) as uint ][opcat(op) as uint];
 }
 
-/// Returns an equivalent type with all the typedefs and self regions removed.
-pub fn normalize_ty<'tcx>(cx: &ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
-    let u = TypeNormalizer(cx).fold_ty(ty);
-    return u;
-
-    struct TypeNormalizer<'a, 'tcx: 'a>(&'a ctxt<'tcx>);
-
-    impl<'a, 'tcx> TypeFolder<'tcx> for TypeNormalizer<'a, 'tcx> {
-        fn tcx(&self) -> &ctxt<'tcx> { let TypeNormalizer(c) = *self; c }
-
-        fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
-            match self.tcx().normalized_cache.borrow().get(&ty).cloned() {
-                None => {}
-                Some(u) => return u
-            }
-
-            let t_norm = ty_fold::super_fold_ty(self, ty);
-            self.tcx().normalized_cache.borrow_mut().insert(ty, t_norm);
-            return t_norm;
-        }
-
-        fn fold_region(&mut self, _: ty::Region) -> ty::Region {
-            ty::ReStatic
-        }
-
-        fn fold_substs(&mut self,
-                       substs: &subst::Substs<'tcx>)
-                       -> subst::Substs<'tcx> {
-            subst::Substs { regions: subst::ErasedRegions,
-                            types: substs.types.fold_with(self) }
-        }
-    }
-}
-
 // Returns the repeat count for a repeating vector expression.
 pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
     match const_eval::eval_const_expr_partial(tcx, count_expr) {
@@ -5845,7 +5843,7 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
             };
             tcx.sess.span_err(count_expr.span, format!(
                 "expected positive integer for repeat count, found {}",
-                found)[]);
+                found).index(&FullRange));
         }
         Err(_) => {
             let found = match count_expr.node {
@@ -5860,7 +5858,7 @@ pub fn eval_repeat_count(tcx: &ctxt, count_expr: &ast::Expr) -> uint {
             };
             tcx.sess.span_err(count_expr.span, format!(
                 "expected constant integer for repeat count, found {}",
-                found)[]);
+                found).index(&FullRange));
         }
     }
     0
@@ -5929,7 +5927,7 @@ pub fn required_region_bounds<'tcx>(tcx: &ctxt<'tcx>,
                                     predicates: Vec<ty::Predicate<'tcx>>)
                                     -> Vec<ty::Region>
 {
-    debug!("required_region_bounds(erased_self_ty={}, predicates={})",
+    debug!("required_region_bounds(erased_self_ty={:?}, predicates={:?})",
            erased_self_ty.repr(tcx),
            predicates.repr(tcx));
 
@@ -6007,7 +6005,7 @@ pub fn populate_implementations_for_type_if_necessary(tcx: &ctxt,
         return
     }
 
-    debug!("populate_implementations_for_type_if_necessary: searching for {}", type_id);
+    debug!("populate_implementations_for_type_if_necessary: searching for {:?}", type_id);
 
     let mut inherent_impls = Vec::new();
     csearch::each_implementation_for_type(&tcx.sess.cstore, type_id,
@@ -6204,7 +6202,7 @@ macro_rules! hash { ($e:expr) => { $e.hash(state) }  }
             mt.mutbl.hash(state);
         };
         let fn_sig = |&: state: &mut sip::SipState, sig: &Binder<FnSig<'tcx>>| {
-            let sig = anonymize_late_bound_regions(tcx, sig);
+            let sig = anonymize_late_bound_regions(tcx, sig).0;
             for a in sig.inputs.iter() { helper(tcx, *a, svh, state); }
             if let ty::FnConverging(output) = sig.output {
                 helper(tcx, output, svh, state);
@@ -6265,7 +6263,7 @@ macro_rules! hash { ($e:expr) => { $e.hash(state) }  }
                     did(state, data.principal_def_id());
                     hash!(data.bounds);
 
-                    let principal = anonymize_late_bound_regions(tcx, &data.principal);
+                    let principal = anonymize_late_bound_regions(tcx, &data.principal).0;
                     for subty in principal.substs.types.iter() {
                         helper(tcx, *subty, svh, state);
                     }
@@ -6368,7 +6366,7 @@ pub fn construct_parameter_environment<'a,'tcx>(
 
     record_region_bounds(tcx, &bounds);
 
-    debug!("construct_parameter_environment: free_id={} free_subst={} bounds={}",
+    debug!("construct_parameter_environment: free_id={:?} free_subst={:?} bounds={:?}",
            free_id,
            free_substs.repr(tcx),
            bounds.repr(tcx));
@@ -6394,15 +6392,15 @@ fn push_types_from_defs<'tcx>(tcx: &ty::ctxt<'tcx>,
                                   types: &mut VecPerParamSpace<Ty<'tcx>>,
                                   defs: &[TypeParameterDef<'tcx>]) {
         for def in defs.iter() {
-            debug!("construct_parameter_environment(): push_types_from_defs: def={}",
+            debug!("construct_parameter_environment(): push_types_from_defs: def={:?}",
                    def.repr(tcx));
             let ty = ty::mk_param_from_def(tcx, def);
             types.push(def.space, ty);
-        }
+       }
     }
 
     fn record_region_bounds<'tcx>(tcx: &ty::ctxt<'tcx>, bounds: &GenericBounds<'tcx>) {
-        debug!("record_region_bounds(bounds={})", bounds.repr(tcx));
+        debug!("record_region_bounds(bounds={:?})", bounds.repr(tcx));
 
         for predicate in bounds.predicates.iter() {
             match *predicate {
@@ -6644,7 +6642,7 @@ pub fn with_freevars<T, F>(tcx: &ty::ctxt, fid: ast::NodeId, f: F) -> T where
 {
     match tcx.freevars.borrow().get(&fid) {
         None => f(&[]),
-        Some(d) => f(d[])
+        Some(d) => f(d.index(&FullRange))
     }
 }
 
@@ -6696,6 +6694,16 @@ pub fn binds_late_bound_regions<'tcx, T>(
     count_late_bound_regions(tcx, value) > 0
 }
 
+pub fn assert_no_late_bound_regions<'tcx, T>(
+    tcx: &ty::ctxt<'tcx>,
+    value: &Binder<T>)
+    -> T
+    where T : TypeFoldable<'tcx> + Repr<'tcx> + Clone
+{
+    assert!(!binds_late_bound_regions(tcx, value));
+    value.0.clone()
+}
+
 /// Replace any late-bound regions bound in `value` with `'static`. Useful in trans but also
 /// method lookup and a few other places where precise region relationships are not required.
 pub fn erase_late_bound_regions<'tcx, T>(
@@ -6718,14 +6726,14 @@ pub fn erase_late_bound_regions<'tcx, T>(
 pub fn anonymize_late_bound_regions<'tcx, T>(
     tcx: &ctxt<'tcx>,
     sig: &Binder<T>)
-    -> T
+    -> Binder<T>
     where T : TypeFoldable<'tcx> + Repr<'tcx>,
 {
     let mut counter = 0;
-    replace_late_bound_regions(tcx, sig, |_, db| {
+    ty::Binder(replace_late_bound_regions(tcx, sig, |_, db| {
         counter += 1;
         ReLateBound(db, BrAnon(counter))
-    }).0
+    }).0)
 }
 
 /// Replaces the late-bound-regions in `value` that are bound by `value`.
@@ -6747,7 +6755,7 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
         debug!("region={}", region.repr(tcx));
         match region {
             ty::ReLateBound(debruijn, br) if debruijn.depth == current_depth => {
-                * map.entry(&br).get().unwrap_or_else(
+                * map.entry(br).get().unwrap_or_else(
                       |vacant_entry| vacant_entry.insert(mapf(br, debruijn)))
             }
             _ => {
@@ -6756,7 +6764,7 @@ pub fn replace_late_bound_regions<'tcx, T, F>(
         }
     });
 
-    debug!("resulting map: {} value: {}", map, value.repr(tcx));
+    debug!("resulting map: {:?} value: {:?}", map, value.repr(tcx));
     (value, map)
 }
 
@@ -6804,7 +6812,7 @@ impl<'tcx> Repr<'tcx> for AutoRef<'tcx> {
     fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         match *self {
             AutoPtr(a, b, ref c) => {
-                format!("AutoPtr({},{},{})", a.repr(tcx), b, c.repr(tcx))
+                format!("AutoPtr({},{:?},{})", a.repr(tcx), b, c.repr(tcx))
             }
             AutoUnsize(ref a) => {
                 format!("AutoUnsize({})", a.repr(tcx))
@@ -6813,7 +6821,7 @@ fn repr(&self, tcx: &ctxt<'tcx>) -> String {
                 format!("AutoUnsizeUniq({})", a.repr(tcx))
             }
             AutoUnsafe(ref a, ref b) => {
-                format!("AutoUnsafe({},{})", a, b.repr(tcx))
+                format!("AutoUnsafe({:?},{})", a, b.repr(tcx))
             }
         }
     }
@@ -6843,7 +6851,7 @@ impl<'tcx> Repr<'tcx> for vtable_origin<'tcx> {
     fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
         match *self {
             vtable_static(def_id, ref tys, ref vtable_res) => {
-                format!("vtable_static({}:{}, {}, {})",
+                format!("vtable_static({:?}:{}, {}, {})",
                         def_id,
                         ty::item_path_str(tcx, def_id),
                         tys.repr(tcx),
@@ -6851,11 +6859,11 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
             }
 
             vtable_param(x, y) => {
-                format!("vtable_param({}, {})", x, y)
+                format!("vtable_param({:?}, {})", x, y)
             }
 
             vtable_unboxed_closure(def_id) => {
-                format!("vtable_unboxed_closure({})", def_id)
+                format!("vtable_unboxed_closure({:?})", def_id)
             }
 
             vtable_error => {
@@ -7286,7 +7294,7 @@ fn references_error(&self) -> bool {
 
 impl<'tcx> Repr<'tcx> for ClosureTy<'tcx> {
     fn repr(&self, tcx: &ctxt<'tcx>) -> String {
-        format!("ClosureTy({},{},{},{},{},{})",
+        format!("ClosureTy({},{},{:?},{},{},{})",
                 self.unsafety,
                 self.onceness,
                 self.store,
index 1421987e3b52615866b7da721bbbcdb9fa65a297..424e357d8d456372112e264dc18909e85380ee74 100644 (file)
@@ -844,7 +844,7 @@ fn fold_region(&mut self, r: ty::Region) -> ty::Region {
             _ => {
                 debug!("RegionFolder.fold_region({}) folding free region (current_depth={})",
                        r.repr(self.tcx()), self.current_depth);
-                self.fld_r.call_mut((r, self.current_depth))
+                (self.fld_r)(r, self.current_depth)
             }
         }
     }
@@ -868,6 +868,9 @@ impl<'a, 'tcx> TypeFolder<'tcx> for RegionEraser<'a, 'tcx> {
     fn tcx(&self) -> &ty::ctxt<'tcx> { self.tcx }
 
     fn fold_region(&mut self, r: ty::Region) -> ty::Region {
+        // because whether or not a region is bound affects subtyping,
+        // we can't erase the bound/free distinction, but we can
+        // replace all free regions with 'static
         match r {
             ty::ReLateBound(..) | ty::ReEarlyBound(..) => r,
             _ => ty::ReStatic
index 4953e9a2ce1d16eee8b4003fdd388945c84078fa..28975c7341659cb9692f5891be91655e3fa331cb 100644 (file)
@@ -95,7 +95,7 @@ impl<'tcx> Iterator for TypeWalker<'tcx> {
     type Item = Ty<'tcx>;
 
     fn next(&mut self) -> Option<Ty<'tcx>> {
-        debug!("next(): stack={}", self.stack);
+        debug!("next(): stack={:?}", self.stack);
         match self.stack.pop() {
             None => {
                 return None;
@@ -103,7 +103,7 @@ fn next(&mut self) -> Option<Ty<'tcx>> {
             Some(ty) => {
                 self.last_subtree = self.stack.len();
                 self.push_subtypes(ty);
-                debug!("next: stack={}", self.stack);
+                debug!("next: stack={:?}", self.stack);
                 Some(ty)
             }
         }
index 44a223954858a76d7089143c981353b2a72a705a..a38298d52dd877a86625433ab9aa585aa857b45b 100644 (file)
@@ -223,17 +223,17 @@ fn dylink_registrar(&mut self,
             // this is fatal: there are almost certainly macros we need
             // inside this crate, so continue would spew "macro undefined"
             // errors
-            Err(err) => self.sess.span_fatal(vi.span, err[])
+            Err(err) => self.sess.span_fatal(vi.span, err.index(&FullRange))
         };
 
         unsafe {
             let registrar =
-                match lib.symbol(symbol[]) {
+                match lib.symbol(symbol.index(&FullRange)) {
                     Ok(registrar) => {
                         mem::transmute::<*mut u8,PluginRegistrarFun>(registrar)
                     }
                     // again fatal if we can't register macros
-                    Err(err) => self.sess.span_fatal(vi.span, err[])
+                    Err(err) => self.sess.span_fatal(vi.span, err.index(&FullRange))
                 };
 
             // Intentionally leak the dynamic library. We can't ever unload it
index 138f648049c73f748e6937474f7e94ff38054148..4968066f7b696b01ba5807cb4902746e3189dd95 100644 (file)
@@ -330,7 +330,7 @@ pub fn debugging_opts_map() -> Vec<(&'static str, &'static str, u64)> {
      ("parse-only", "Parse only; do not compile, assemble, or link", PARSE_ONLY),
      ("no-trans", "Run all passes except translation; no output", NO_TRANS),
      ("no-analysis", "Parse and expand the source, but run no analysis and",
-      NO_TRANS),
+      NO_ANALYSIS),
      ("unstable-options", "Adds unstable command line options to rustc interface",
       UNSTABLE_OPTIONS),
      ("print-enum-sizes", "Print the size of enums and their variants", PRINT_ENUM_SIZES),
@@ -559,17 +559,17 @@ pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
                 match (value, opt_type_desc) {
                     (Some(..), None) => {
                         early_error(format!("codegen option `{}` takes no \
-                                             value", key)[])
+                                             value", key).index(&FullRange))
                     }
                     (None, Some(type_desc)) => {
                         early_error(format!("codegen option `{0}` requires \
                                              {1} (-C {0}=<value>)",
-                                            key, type_desc)[])
+                                            key, type_desc).index(&FullRange))
                     }
                     (Some(value), Some(type_desc)) => {
                         early_error(format!("incorrect value `{}` for codegen \
                                              option `{}` - {} was expected",
-                                             value, key, type_desc)[])
+                                             value, key, type_desc).index(&FullRange))
                     }
                     (None, None) => unreachable!()
                 }
@@ -579,7 +579,7 @@ pub fn build_codegen_options(matches: &getopts::Matches) -> CodegenOptions
         }
         if !found {
             early_error(format!("unknown codegen option: `{}`",
-                                key)[]);
+                                key).index(&FullRange));
         }
     }
     return cg;
@@ -592,10 +592,10 @@ pub fn default_lib_output() -> CrateType {
 pub fn default_configuration(sess: &Session) -> ast::CrateConfig {
     use syntax::parse::token::intern_and_get_ident as intern;
 
-    let end = sess.target.target.target_endian[];
-    let arch = sess.target.target.arch[];
-    let wordsz = sess.target.target.target_word_size[];
-    let os = sess.target.target.target_os[];
+    let end = sess.target.target.target_endian.index(&FullRange);
+    let arch = sess.target.target.arch.index(&FullRange);
+    let wordsz = sess.target.target.target_word_size.index(&FullRange);
+    let os = sess.target.target.target_os.index(&FullRange);
 
     let fam = match sess.target.target.options.is_like_windows {
         true  => InternedString::new("windows"),
@@ -631,23 +631,23 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig {
         append_configuration(&mut user_cfg, InternedString::new("test"))
     }
     let mut v = user_cfg.into_iter().collect::<Vec<_>>();
-    v.push_all(default_cfg[]);
+    v.push_all(default_cfg.index(&FullRange));
     v
 }
 
 pub fn build_target_config(opts: &Options, sp: &SpanHandler) -> Config {
-    let target = match Target::search(opts.target_triple[]) {
+    let target = match Target::search(opts.target_triple.index(&FullRange)) {
         Ok(t) => t,
         Err(e) => {
-            sp.handler().fatal((format!("Error loading target specification: {}", e))[]);
+            sp.handler().fatal((format!("Error loading target specification: {}", e)).as_slice());
     }
     };
 
-    let (int_type, uint_type) = match target.target_word_size[] {
+    let (int_type, uint_type) = match target.target_word_size.index(&FullRange) {
         "32" => (ast::TyI32, ast::TyU32),
         "64" => (ast::TyI64, ast::TyU64),
         w    => sp.handler().fatal((format!("target specification was invalid: unrecognized \
-                                            target-word-size {}", w))[])
+                                            target-word-size {}", w)).index(&FullRange))
     };
 
     Config {
@@ -845,7 +845,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
 
     let unparsed_crate_types = matches.opt_strs("crate-type");
     let crate_types = parse_crate_types_from_list(unparsed_crate_types)
-        .unwrap_or_else(|e| early_error(e[]));
+        .unwrap_or_else(|e| early_error(e.index(&FullRange)));
 
     let mut lint_opts = vec!();
     let mut describe_lints = false;
@@ -873,7 +873,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         }
         if this_bit == 0 {
             early_error(format!("unknown debug flag: {}",
-                                *debug_flag)[])
+                                *debug_flag).index(&FullRange))
         }
         debugging_opts |= this_bit;
     }
@@ -918,7 +918,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                     "dep-info" => OutputTypeDepInfo,
                     _ => {
                         early_error(format!("unknown emission type: `{}`",
-                                            part)[])
+                                            part).index(&FullRange))
                     }
                 };
                 output_types.push(output_type)
@@ -957,7 +957,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                 Some(arg) => {
                     early_error(format!("optimization level needs to be \
                                          between 0-3 (instead was `{}`)",
-                                        arg)[]);
+                                        arg).index(&FullRange));
                 }
             }
         } else {
@@ -995,7 +995,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             Some(arg) => {
                 early_error(format!("debug info level needs to be between \
                                      0-2 (instead was `{}`)",
-                                    arg)[]);
+                                    arg).index(&FullRange));
             }
         }
     } else {
@@ -1013,7 +1013,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
 
     let mut search_paths = SearchPaths::new();
     for s in matches.opt_strs("L").iter() {
-        search_paths.add_path(s[]);
+        search_paths.add_path(s.index(&FullRange));
     }
 
     let libs = matches.opt_strs("l").into_iter().map(|s| {
@@ -1027,7 +1027,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                 s => {
                     early_error(format!("unknown library kind `{}`, expected \
                                          one of dylib, framework, or static",
-                                        s)[]);
+                                        s).as_slice());
                 }
             };
             return (name.to_string(), kind)
@@ -1045,7 +1045,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             (_, s) => {
                 early_error(format!("unknown library kind `{}`, expected \
                                      one of dylib, framework, or static",
-                                    s)[]);
+                                    s).index(&FullRange));
             }
         };
         (name.to_string(), kind)
@@ -1089,7 +1089,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
                     --debuginfo");
     }
 
-    let color = match matches.opt_str("color").as_ref().map(|s| s[]) {
+    let color = match matches.opt_str("color").as_ref().map(|s| s.index(&FullRange)) {
         Some("auto")   => Auto,
         Some("always") => Always,
         Some("never")  => Never,
@@ -1099,7 +1099,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
         Some(arg) => {
             early_error(format!("argument for --color must be auto, always \
                                  or never (instead was `{}`)",
-                                arg)[])
+                                arg).index(&FullRange))
         }
     };
 
@@ -1115,7 +1115,7 @@ pub fn build_session_options(matches: &getopts::Matches) -> Options {
             None => early_error("--extern value must be of the format `foo=bar`"),
         };
 
-        match externs.entry(&name.to_string()) {
+        match externs.entry(name.to_string()) {
             Vacant(entry) => { entry.insert(vec![location.to_string()]); },
             Occupied(mut entry) => { entry.get_mut().push(location.to_string()); },
         }
@@ -1201,7 +1201,7 @@ mod test {
     #[test]
     fn test_switch_implies_cfg_test() {
         let matches =
-            &match getopts(&["--test".to_string()], optgroups()[]) {
+            &match getopts(&["--test".to_string()], optgroups().index(&FullRange)) {
               Ok(m) => m,
               Err(f) => panic!("test_switch_implies_cfg_test: {}", f)
             };
@@ -1209,7 +1209,7 @@ fn test_switch_implies_cfg_test() {
         let sessopts = build_session_options(matches);
         let sess = build_session(sessopts, None, registry);
         let cfg = build_configuration(&sess);
-        assert!((attr::contains_name(cfg[], "test")));
+        assert!((attr::contains_name(cfg.index(&FullRange), "test")));
     }
 
     // When the user supplies --test and --cfg test, don't implicitly add
@@ -1218,7 +1218,7 @@ fn test_switch_implies_cfg_test() {
     fn test_switch_implies_cfg_test_unless_cfg_test() {
         let matches =
             &match getopts(&["--test".to_string(), "--cfg=test".to_string()],
-                           optgroups()[]) {
+                           optgroups().index(&FullRange)) {
               Ok(m) => m,
               Err(f) => {
                 panic!("test_switch_implies_cfg_test_unless_cfg_test: {}", f)
@@ -1238,7 +1238,7 @@ fn test_can_print_warnings() {
         {
             let matches = getopts(&[
                 "-Awarnings".to_string()
-            ], optgroups()[]).unwrap();
+            ], optgroups().index(&FullRange)).unwrap();
             let registry = diagnostics::registry::Registry::new(&[]);
             let sessopts = build_session_options(&matches);
             let sess = build_session(sessopts, None, registry);
@@ -1249,7 +1249,7 @@ fn test_can_print_warnings() {
             let matches = getopts(&[
                 "-Awarnings".to_string(),
                 "-Dwarnings".to_string()
-            ], optgroups()[]).unwrap();
+            ], optgroups().index(&FullRange)).unwrap();
             let registry = diagnostics::registry::Registry::new(&[]);
             let sessopts = build_session_options(&matches);
             let sess = build_session(sessopts, None, registry);
@@ -1259,7 +1259,7 @@ fn test_can_print_warnings() {
         {
             let matches = getopts(&[
                 "-Adead_code".to_string()
-            ], optgroups()[]).unwrap();
+            ], optgroups().index(&FullRange)).unwrap();
             let registry = diagnostics::registry::Registry::new(&[]);
             let sessopts = build_session_options(&matches);
             let sess = build_session(sessopts, None, registry);
index abb780615ae7b8170f6f8801dd660e3368417683..94a6bca4e06e588a6fcd0a31ecea5144f51a99ce 100644 (file)
@@ -174,7 +174,7 @@ pub fn codemap<'a>(&'a self) -> &'a codemap::CodeMap {
     // cases later on
     pub fn impossible_case(&self, sp: Span, msg: &str) -> ! {
         self.span_bug(sp,
-                      format!("impossible case reached: {}", msg)[]);
+                      format!("impossible case reached: {}", msg).index(&FullRange));
     }
     pub fn verbose(&self) -> bool { self.debugging_opt(config::VERBOSE) }
     pub fn time_passes(&self) -> bool { self.debugging_opt(config::TIME_PASSES) }
@@ -216,7 +216,7 @@ pub fn sysroot<'a>(&'a self) -> &'a Path {
     }
     pub fn target_filesearch(&self, kind: PathKind) -> filesearch::FileSearch {
         filesearch::FileSearch::new(self.sysroot(),
-                                    self.opts.target_triple[],
+                                    self.opts.target_triple.index(&FullRange),
                                     &self.opts.search_paths,
                                     kind)
     }
index 7d2a8509cb5106e1ad14dcc7ae41cb21c97e0ad5..26f98e28a8d950473db969dcbd06af9aee27510e 100644 (file)
@@ -64,7 +64,7 @@ pub fn indent<R, F>(op: F) -> R where
     // to make debug output more readable.
     debug!(">>");
     let r = op();
-    debug!("<< (Result = {})", r);
+    debug!("<< (Result = {:?})", r);
     r
 }
 
index 79bd0d4e306e452a3dd0100fff9dd84cff00d8dc..8f5820d92c589772274043332863a7ddb27d7a66 100644 (file)
@@ -48,7 +48,7 @@ fn test_lev_distance() {
     for c in range(0u32, MAX as u32)
              .filter_map(|i| from_u32(i))
              .map(|i| i.to_string()) {
-        assert_eq!(lev_distance(c[], c[]), 0);
+        assert_eq!(lev_distance(c.index(&FullRange), c.index(&FullRange)), 0);
     }
 
     let a = "\nMäry häd ä little lämb\n\nLittle lämb\n";
index 8c2a9993004d99c4e6d96ff2ca49181aa2d5108f..2d433369366eb9f4d397c0ae851eb1f02eab29ea 100644 (file)
@@ -55,12 +55,12 @@ pub fn note_and_explain_region(cx: &ctxt,
       (ref str, Some(span)) => {
         cx.sess.span_note(
             span,
-            format!("{}{}{}", prefix, *str, suffix)[]);
+            format!("{}{}{}", prefix, *str, suffix).index(&FullRange));
         Some(span)
       }
       (ref str, None) => {
         cx.sess.note(
-            format!("{}{}{}", prefix, *str, suffix)[]);
+            format!("{}{}{}", prefix, *str, suffix).index(&FullRange));
         None
       }
     }
@@ -111,7 +111,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
           }
           Some(_) | None => {
             // this really should not happen
-            (format!("unknown scope: {}.  Please report a bug.", scope), None)
+            (format!("unknown scope: {:?}.  Please report a bug.", scope), None)
           }
         }
       }
@@ -140,7 +140,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
           }
           Some(_) | None => {
               // this really should not happen
-              (format!("{} unknown free region bounded by scope {}", prefix, fr.scope), None)
+              (format!("{} unknown free region bounded by scope {:?}", prefix, fr.scope), None)
           }
         }
       }
@@ -156,7 +156,7 @@ pub fn explain_region_and_span(cx: &ctxt, region: ty::Region)
       // I believe these cases should not occur (except when debugging,
       // perhaps)
       ty::ReInfer(_) | ty::ReLateBound(..) => {
-        (format!("lifetime {}", region), None)
+        (format!("lifetime {:?}", region), None)
       }
     };
 
@@ -271,7 +271,7 @@ fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>,
         };
 
         if abi != abi::Rust {
-            s.push_str(format!("extern {} ", abi.to_string())[]);
+            s.push_str(format!("extern {} ", abi.to_string()).index(&FullRange));
         };
 
         s.push_str("fn");
@@ -290,7 +290,7 @@ fn bare_fn_to_string<'tcx>(cx: &ctxt<'tcx>,
             Some(def_id) => {
                 s.push_str(" {");
                 let path_str = ty::item_path_str(cx, def_id);
-                s.push_str(path_str[]);
+                s.push_str(path_str.index(&FullRange));
                 s.push_str("}");
             }
             None => { }
@@ -305,7 +305,7 @@ fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, cty: &ty::ClosureTy<'tcx>) -> String
         match cty.store {
             ty::UniqTraitStore => {}
             ty::RegionTraitStore(region, _) => {
-                s.push_str(region_to_string(cx, "", true, region)[]);
+                s.push_str(region_to_string(cx, "", true, region).index(&FullRange));
             }
         }
 
@@ -324,7 +324,7 @@ fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, cty: &ty::ClosureTy<'tcx>) -> String
                 assert_eq!(cty.onceness, ast::Once);
                 s.push_str("proc");
                 push_sig_to_string(cx, &mut s, '(', ')', &cty.sig,
-                                   bounds_str[]);
+                                   bounds_str.index(&FullRange));
             }
             ty::RegionTraitStore(..) => {
                 match cty.onceness {
@@ -332,7 +332,7 @@ fn closure_to_string<'tcx>(cx: &ctxt<'tcx>, cty: &ty::ClosureTy<'tcx>) -> String
                     ast::Once => s.push_str("once ")
                 }
                 push_sig_to_string(cx, &mut s, '|', '|', &cty.sig,
-                                   bounds_str[]);
+                                   bounds_str.index(&FullRange));
             }
         }
 
@@ -365,7 +365,7 @@ fn push_sig_to_string<'tcx>(cx: &ctxt<'tcx>,
             ty::FnConverging(t) => {
                 if !ty::type_is_nil(t) {
                    s.push_str(" -> ");
-                   s.push_str(ty_to_string(cx, t)[]);
+                   s.push_str(ty_to_string(cx, t).index(&FullRange));
                 }
             }
             ty::FnDiverging => {
@@ -402,7 +402,7 @@ fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
         }
         ty_rptr(r, ref tm) => {
             let mut buf = region_ptr_to_string(cx, *r);
-            buf.push_str(mt_to_string(cx, tm)[]);
+            buf.push_str(mt_to_string(cx, tm).index(&FullRange));
             buf
         }
         ty_open(typ) =>
@@ -412,7 +412,7 @@ fn infer_ty_to_string(cx: &ctxt, ty: ty::InferTy) -> String {
                 .iter()
                 .map(|elem| ty_to_string(cx, *elem))
                 .collect::<Vec<_>>();
-            match strs[] {
+            match strs.index(&FullRange) {
                 [ref string] => format!("({},)", string),
                 strs => format!("({})", strs.connect(", "))
             }
@@ -541,7 +541,7 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
         0
     };
 
-    for t in tps[..tps.len() - num_defaults].iter() {
+    for t in tps.index(&(0..(tps.len() - num_defaults))).iter() {
         strs.push(ty_to_string(cx, *t))
     }
 
@@ -549,11 +549,11 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
         format!("{}({}){}",
                 base,
                 if strs[0].starts_with("(") && strs[0].ends_with(",)") {
-                    strs[0][1 .. strs[0].len() - 2] // Remove '(' and ',)'
+                    strs[0].index(&(1 .. (strs[0].len() - 2))) // Remove '(' and ',)'
                 } else if strs[0].starts_with("(") && strs[0].ends_with(")") {
-                    strs[0][1 .. strs[0].len() - 1] // Remove '(' and ')'
+                    strs[0].index(&(1 .. (strs[0].len() - 1))) // Remove '(' and ')'
                 } else {
-                    strs[0][]
+                    strs[0].index(&FullRange)
                 },
                 if &*strs[1] == "()" { String::new() } else { format!(" -> {}", strs[1]) })
     } else if strs.len() > 0 {
@@ -566,7 +566,7 @@ pub fn parameterized<'tcx>(cx: &ctxt<'tcx>,
 pub fn ty_to_short_str<'tcx>(cx: &ctxt<'tcx>, typ: Ty<'tcx>) -> String {
     let mut s = typ.repr(cx).to_string();
     if s.len() >= 32u {
-        s = s[0u..32u].to_string();
+        s = s.index(&(0u..32u)).to_string();
     }
     return s;
 }
@@ -631,7 +631,7 @@ fn repr(&self, tcx: &ctxt<'tcx>) -> String {
 
 impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for OwnedSlice<T> {
     fn repr(&self, tcx: &ctxt<'tcx>) -> String {
-        repr_vec(tcx, self[])
+        repr_vec(tcx, self.index(&FullRange))
     }
 }
 
@@ -639,7 +639,7 @@ fn repr(&self, tcx: &ctxt<'tcx>) -> String {
 // autoderef cannot convert the &[T] handler
 impl<'tcx, T:Repr<'tcx>> Repr<'tcx> for Vec<T> {
     fn repr(&self, tcx: &ctxt<'tcx>) -> String {
-        repr_vec(tcx, self[])
+        repr_vec(tcx, self.index(&FullRange))
     }
 }
 
@@ -653,13 +653,13 @@ fn user_string(&self, tcx: &ctxt<'tcx>) -> String {
 
 impl<'tcx> Repr<'tcx> for def::Def {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ty::TypeParameterDef<'tcx> {
     fn repr(&self, tcx: &ctxt<'tcx>) -> String {
-        format!("TypeParameterDef({}, {}, {}/{})",
+        format!("TypeParameterDef({:?}, {}, {:?}/{})",
                 self.def_id,
                 self.bounds.repr(tcx),
                 self.space,
@@ -854,7 +854,7 @@ impl<'tcx> Repr<'tcx> for ty::Region {
     fn repr(&self, tcx: &ctxt) -> String {
         match *self {
             ty::ReEarlyBound(id, space, index, name) => {
-                format!("ReEarlyBound({}, {}, {}, {})",
+                format!("ReEarlyBound({}, {:?}, {}, {})",
                                id,
                                space,
                                index,
@@ -862,7 +862,7 @@ fn repr(&self, tcx: &ctxt) -> String {
             }
 
             ty::ReLateBound(binder_id, ref bound_region) => {
-                format!("ReLateBound({}, {})",
+                format!("ReLateBound({:?}, {})",
                         binder_id,
                         bound_region.repr(tcx))
             }
@@ -870,7 +870,7 @@ fn repr(&self, tcx: &ctxt) -> String {
             ty::ReFree(ref fr) => fr.repr(tcx),
 
             ty::ReScope(id) => {
-                format!("ReScope({})", id)
+                format!("ReScope({:?})", id)
             }
 
             ty::ReStatic => {
@@ -878,7 +878,7 @@ fn repr(&self, tcx: &ctxt) -> String {
             }
 
             ty::ReInfer(ReVar(ref vid)) => {
-                format!("{}", vid)
+                format!("{:?}", vid)
             }
 
             ty::ReInfer(ReSkolemized(id, ref bound_region)) => {
@@ -920,14 +920,14 @@ fn repr(&self, tcx: &ctxt) -> String {
                 Some(ast_map::NodeVariant(..)) |
                 Some(ast_map::NodeStructCtor(..)) => {
                     return format!(
-                                "{}:{}",
+                                "{:?}:{}",
                                 *self,
                                 ty::item_path_str(tcx, *self))
                 }
                 _ => {}
             }
         }
-        return format!("{}", *self)
+        return format!("{:?}", *self)
     }
 }
 
@@ -1007,13 +1007,13 @@ fn repr(&self, _tcx: &ctxt) -> String {
 
 impl<'tcx> Repr<'tcx> for ast::ExplicitSelf_ {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ast::Visibility {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
@@ -1026,6 +1026,7 @@ fn repr(&self, tcx: &ctxt<'tcx>) -> String {
     }
 }
 
+
 impl<'tcx> Repr<'tcx> for ty::FnSig<'tcx> {
     fn repr(&self, tcx: &ctxt<'tcx>) -> String {
         format!("fn{} -> {}", self.inputs.repr(tcx), self.output.repr(tcx))
@@ -1096,7 +1097,7 @@ fn repr(&self, tcx: &ctxt) -> String {
 
 impl<'tcx> Repr<'tcx> for ty::BuiltinBound {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
@@ -1251,13 +1252,13 @@ fn repr(&self, tcx: &ctxt) -> String {
 
 impl<'tcx> Repr<'tcx> for ast::Mutability {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ty::BorrowKind {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
@@ -1271,49 +1272,49 @@ fn repr(&self, tcx: &ctxt) -> String {
 
 impl<'tcx> Repr<'tcx> for ty::IntVid {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", self)
+        format!("{:?}", self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ty::FloatVid {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", self)
+        format!("{:?}", self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ty::RegionVid {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", self)
+        format!("{:?}", self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ty::TyVid {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", self)
+        format!("{:?}", self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ty::IntVarValue {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ast::IntTy {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ast::UintTy {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for ast::FloatTy {
     fn repr(&self, _tcx: &ctxt) -> String {
-        format!("{}", *self)
+        format!("{:?}", *self)
     }
 }
 
@@ -1332,7 +1333,7 @@ fn user_string(&self, _tcx: &ctxt) -> String {
 impl<'tcx> Repr<'tcx> for ParamTy {
     fn repr(&self, tcx: &ctxt) -> String {
         let ident = self.user_string(tcx);
-        format!("{}/{}.{}", ident, self.space, self.idx)
+        format!("{}/{:?}.{}", ident, self.space, self.idx)
     }
 }
 
@@ -1349,6 +1350,7 @@ fn repr(&self, tcx: &ctxt<'tcx>) -> String {
     }
 }
 
+#[old_impl_check]
 impl<'tcx, S, H, K, V> Repr<'tcx> for HashMap<K,V,H>
     where K : Hash<S> + Eq + Repr<'tcx>,
           V : Repr<'tcx>,
index d5d40a980dc779495bab89503e4a8e4eeb85211a..d68b13aa2ff58587bb28311519a06d5d1a6c644c 100644 (file)
@@ -116,7 +116,7 @@ pub fn start_snapshot(&mut self) -> Snapshot {
     pub fn actions_since_snapshot(&self,
                                   snapshot: &Snapshot)
                                   -> &[UndoLog<T,U>] {
-        self.undo_log[snapshot.length..]
+        self.undo_log.index(&(snapshot.length..))
     }
 
     fn assert_open_snapshot(&self, snapshot: &Snapshot) {
index 0bd4265e487a64f25fa19a7d2f022879e7481fae..48004acaac0878825b6ec0e05ba2d1ad8ee01c1d 100644 (file)
@@ -53,7 +53,7 @@ fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
           args: &str, cwd: Option<&Path>,
           paths: &[&Path]) -> ProcessOutput {
     let ar = match *maybe_ar_prog {
-        Some(ref ar) => ar[],
+        Some(ref ar) => ar.index(&FullRange),
         None => "ar"
     };
     let mut cmd = Command::new(ar);
@@ -64,7 +64,7 @@ fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
     match cwd {
         Some(p) => {
             cmd.cwd(p);
-            debug!("inside {}", p.display());
+            debug!("inside {:?}", p.display());
         }
         None => {}
     }
@@ -75,22 +75,22 @@ fn run_ar(handler: &ErrorHandler, maybe_ar_prog: &Option<String>,
             if !o.status.success() {
                 handler.err(format!("{} failed with: {}",
                                  cmd,
-                                 o.status)[]);
+                                 o.status).index(&FullRange));
                 handler.note(format!("stdout ---\n{}",
                                   str::from_utf8(o.output
-                                                  []).unwrap())
-                          []);
+                                                  .index(&FullRange)).unwrap())
+                          .index(&FullRange));
                 handler.note(format!("stderr ---\n{}",
                                   str::from_utf8(o.error
-                                                  []).unwrap())
-                          []);
+                                                  .index(&FullRange)).unwrap())
+                          .index(&FullRange));
                 handler.abort_if_errors();
             }
             o
         },
         Err(e) => {
-            handler.err(format!("could not exec `{}`: {}", ar[],
-                             e)[]);
+            handler.err(format!("could not exec `{}`: {}", ar.index(&FullRange),
+                             e).index(&FullRange));
             handler.abort_if_errors();
             panic!("rustc::back::archive::run_ar() should not reach this point");
         }
@@ -105,17 +105,17 @@ pub fn find_library(name: &str, osprefix: &str, ossuffix: &str,
     let unixlibname = format!("lib{}.a", name);
 
     for path in search_paths.iter() {
-        debug!("looking for {} inside {}", name, path.display());
-        let test = path.join(oslibname[]);
+        debug!("looking for {} inside {:?}", name, path.display());
+        let test = path.join(oslibname.index(&FullRange));
         if test.exists() { return test }
         if oslibname != unixlibname {
-            let test = path.join(unixlibname[]);
+            let test = path.join(unixlibname.index(&FullRange));
             if test.exists() { return test }
         }
     }
     handler.fatal(format!("could not find native static library `{}`, \
                            perhaps an -L flag is missing?",
-                          name)[]);
+                          name).index(&FullRange));
 }
 
 impl<'a> Archive<'a> {
@@ -147,7 +147,7 @@ pub fn remove_file(&mut self, file: &str) {
     /// Lists all files in an archive
     pub fn files(&self) -> Vec<String> {
         let output = run_ar(self.handler, &self.maybe_ar_prog, "t", None, &[&self.dst]);
-        let output = str::from_utf8(output.output[]).unwrap();
+        let output = str::from_utf8(output.output.index(&FullRange)).unwrap();
         // use lines_any because windows delimits output with `\r\n` instead of
         // just `\n`
         output.lines_any().map(|s| s.to_string()).collect()
@@ -179,9 +179,9 @@ pub fn create(config: ArchiveConfig<'a>) -> ArchiveBuilder<'a> {
     /// search in the relevant locations for a library named `name`.
     pub fn add_native_library(&mut self, name: &str) -> io::IoResult<()> {
         let location = find_library(name,
-                                    self.archive.slib_prefix[],
-                                    self.archive.slib_suffix[],
-                                    self.archive.lib_search_paths[],
+                                    self.archive.slib_prefix.index(&FullRange),
+                                    self.archive.slib_suffix.index(&FullRange),
+                                    self.archive.lib_search_paths.index(&FullRange),
                                     self.archive.handler);
         self.add_archive(&location, name, |_| false)
     }
@@ -197,12 +197,12 @@ pub fn add_rlib(&mut self, rlib: &Path, name: &str,
         // as simple comparison is not enough - there
         // might be also an extra name suffix
         let obj_start = format!("{}", name);
-        let obj_start = obj_start[];
+        let obj_start = obj_start.index(&FullRange);
         // Ignoring all bytecode files, no matter of
         // name
         let bc_ext = ".bytecode.deflate";
 
-        self.add_archive(rlib, name[], |fname: &str| {
+        self.add_archive(rlib, name.index(&FullRange), |fname: &str| {
             let skip_obj = lto && fname.starts_with(obj_start)
                 && fname.ends_with(".o");
             skip_obj || fname.ends_with(bc_ext) || fname == METADATA_FILENAME
@@ -239,7 +239,7 @@ pub fn build(self) -> Archive<'a> {
             // allow running `ar s file.a` to update symbols only.
             if self.should_update_symbols {
                 run_ar(self.archive.handler, &self.archive.maybe_ar_prog,
-                       "s", Some(self.work_dir.path()), args[]);
+                       "s", Some(self.work_dir.path()), args.index(&FullRange));
             }
             return self.archive;
         }
@@ -259,7 +259,7 @@ pub fn build(self) -> Archive<'a> {
                 // Add the archive members seen so far, without updating the
                 // symbol table (`S`).
                 run_ar(self.archive.handler, &self.archive.maybe_ar_prog,
-                       "cruS", Some(self.work_dir.path()), args[]);
+                       "cruS", Some(self.work_dir.path()), args.index(&FullRange));
 
                 args.clear();
                 args.push(&abs_dst);
@@ -274,7 +274,7 @@ pub fn build(self) -> Archive<'a> {
         // necessary.
         let flags = if self.should_update_symbols { "crus" } else { "cruS" };
         run_ar(self.archive.handler, &self.archive.maybe_ar_prog,
-               flags, Some(self.work_dir.path()), args[]);
+               flags, Some(self.work_dir.path()), args.index(&FullRange));
 
         self.archive
     }
@@ -316,7 +316,7 @@ fn add_archive<F>(&mut self, archive: &Path, name: &str, mut skip: F) -> io::IoR
             } else {
                 filename
             };
-            let new_filename = self.work_dir.path().join(filename[]);
+            let new_filename = self.work_dir.path().join(filename.index(&FullRange));
             try!(fs::rename(file, &new_filename));
             self.members.push(Path::new(filename));
         }
index 238c84e88a9e0178fb37d9e17ffca8fd71535ee5..ca39477fbdcb2e9d700d5602f491d7a253108c13 100644 (file)
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/nightly/")]
-
-#![allow(unknown_features)]
-#![feature(globs, phase, macro_rules, slicing_syntax)]
-#![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
+#![feature(slicing_syntax)]
 
 extern crate syntax;
 extern crate serialize;
+#[macro_use] extern crate log;
 
 pub mod abi;
 pub mod archive;
index 955081a3af64c62b1fbd244d03612051754fe0ac..db1dfa6b6eed88fc689bacfac752eab6cebea636 100644 (file)
@@ -44,15 +44,15 @@ pub fn get_rpath_flags<F, G>(config: RPathConfig<F, G>) -> Vec<String> where
         l.map(|p| p.clone())
     }).collect::<Vec<_>>();
 
-    let rpaths = get_rpaths(config, libs[]);
-    flags.push_all(rpaths_to_flags(rpaths[])[]);
+    let rpaths = get_rpaths(config, libs.index(&FullRange));
+    flags.push_all(rpaths_to_flags(rpaths.index(&FullRange)).index(&FullRange));
     flags
 }
 
 fn rpaths_to_flags(rpaths: &[String]) -> Vec<String> {
     let mut ret = Vec::new();
     for rpath in rpaths.iter() {
-        ret.push(format!("-Wl,-rpath,{}", (*rpath)[]));
+        ret.push(format!("-Wl,-rpath,{}", (*rpath).index(&FullRange)));
     }
     return ret;
 }
@@ -61,10 +61,10 @@ fn get_rpaths<F, G>(mut config: RPathConfig<F, G>, libs: &[Path]) -> Vec<String>
     F: FnOnce() -> Path,
     G: FnMut(&Path) -> Result<Path, IoError>,
 {
-    debug!("output: {}", config.out_filename.display());
+    debug!("output: {:?}", config.out_filename.display());
     debug!("libs:");
     for libpath in libs.iter() {
-        debug!("    {}", libpath.display());
+        debug!("    {:?}", libpath.display());
     }
 
     // Use relative paths to the libraries. Binaries can be moved
@@ -82,14 +82,14 @@ fn log_rpaths(desc: &str, rpaths: &[String]) {
         }
     }
 
-    log_rpaths("relative", rel_rpaths[]);
-    log_rpaths("fallback", fallback_rpaths[]);
+    log_rpaths("relative", rel_rpaths.index(&FullRange));
+    log_rpaths("fallback", fallback_rpaths.index(&FullRange));
 
     let mut rpaths = rel_rpaths;
-    rpaths.push_all(fallback_rpaths[]);
+    rpaths.push_all(fallback_rpaths.index(&FullRange));
 
     // Remove duplicates
-    let rpaths = minimize_rpaths(rpaths[]);
+    let rpaths = minimize_rpaths(rpaths.index(&FullRange));
     return rpaths;
 }
 
@@ -140,7 +140,7 @@ fn minimize_rpaths(rpaths: &[String]) -> Vec<String> {
     let mut set = HashSet::new();
     let mut minimized = Vec::new();
     for rpath in rpaths.iter() {
-        if set.insert(rpath[]) {
+        if set.insert(rpath.index(&FullRange)) {
             minimized.push(rpath.clone());
         }
     }
index d606c5158d0f7d930ae003664e2ac4cee9f47f59..f33971a6ac0c2f2e4ad6f0e310bf22eed39a186d 100644 (file)
@@ -140,7 +140,7 @@ fn input<F>(&mut self, input: &[u8], mut func: F) where
             if input.len() >= buffer_remaining {
                     copy_memory(
                         self.buffer.slice_mut(self.buffer_idx, size),
-                        input[..buffer_remaining]);
+                        input.index(&(0..buffer_remaining)));
                 self.buffer_idx = 0;
                 func(&self.buffer);
                 i += buffer_remaining;
@@ -156,7 +156,7 @@ fn input<F>(&mut self, input: &[u8], mut func: F) where
         // While we have at least a full buffer size chunk's worth of data, process that data
         // without copying it into the buffer
         while input.len() - i >= size {
-            func(input[i..i + size]);
+            func(input.index(&(i..(i + size))));
             i += size;
         }
 
@@ -166,7 +166,7 @@ fn input<F>(&mut self, input: &[u8], mut func: F) where
         let input_remaining = input.len() - i;
         copy_memory(
             self.buffer.slice_to_mut(input_remaining),
-            input[i..]);
+            input.index(&(i..)));
         self.buffer_idx += input_remaining;
     }
 
@@ -188,7 +188,7 @@ fn next<'s>(&'s mut self, len: uint) -> &'s mut [u8] {
     fn full_buffer<'s>(&'s mut self) -> &'s [u8] {
         assert!(self.buffer_idx == 64);
         self.buffer_idx = 0;
-        return self.buffer[..64];
+        return self.buffer.index(&(0..64));
     }
 
     fn position(&self) -> uint { self.buffer_idx }
index 86bd74d3f85e5b2ca97769ca579130767638a09a..863c1a7c865f3b5fbcac9f6b8f45a8b1e8a5b5e9 100644 (file)
@@ -65,7 +65,7 @@ pub fn new(hash: &str) -> Svh {
     }
 
     pub fn as_str<'a>(&'a self) -> &'a str {
-        self.hash[]
+        self.hash.index(&FullRange)
     }
 
     pub fn calculate(metadata: &Vec<String>, krate: &ast::Crate) -> Svh {
@@ -119,6 +119,14 @@ fn hex(b: u64) -> char {
 }
 
 impl fmt::Show for Svh {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        //NOTE(stage0): uncomment after snapshot
+        //write!(f, "Svh {{ {} }}", self.as_str())
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for Svh {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.pad(self.as_str())
     }
@@ -358,7 +366,7 @@ fn visit_mac(&mut self, mac: &Mac) {
             fn macro_name(mac: &Mac) -> token::InternedString {
                 match &mac.node {
                     &MacInvocTT(ref path, ref _tts, ref _stx_ctxt) => {
-                        let s = path.segments[];
+                        let s = path.segments.index(&FullRange);
                         assert_eq!(s.len(), 1);
                         content(s[0].identifier)
                     }
index f14583bb9aa81b23282861f47019b9786790d6ce..23c8fc7de51b550391bbc7621c5c127c6ad40acd 100644 (file)
@@ -225,7 +225,7 @@ pub fn from_json(obj: Json) -> Target {
                 Some(val) => val,
                 None =>
                     handler.fatal((format!("Field {} in target specification is required", name))
-                                  [])
+                                  .index(&FullRange))
             }
         };
 
@@ -242,16 +242,18 @@ pub fn from_json(obj: Json) -> Target {
         macro_rules! key {
             ($key_name:ident) => ( {
                 let name = (stringify!($key_name)).replace("_", "-");
-                obj.find(name[]).map(|o| o.as_string()
+                obj.find(name.index(&FullRange)).map(|o| o.as_string()
                                     .map(|s| base.options.$key_name = s.to_string()));
             } );
             ($key_name:ident, bool) => ( {
                 let name = (stringify!($key_name)).replace("_", "-");
-                obj.find(name[]).map(|o| o.as_boolean().map(|s| base.options.$key_name = s));
+                obj.find(name.index(&FullRange))
+                    .map(|o| o.as_boolean()
+                         .map(|s| base.options.$key_name = s));
             } );
             ($key_name:ident, list) => ( {
                 let name = (stringify!($key_name)).replace("_", "-");
-                obj.find(name[]).map(|o| o.as_array()
+                obj.find(name.index(&FullRange)).map(|o| o.as_array()
                     .map(|v| base.options.$key_name = v.iter()
                         .map(|a| a.as_string().unwrap().to_string()).collect()
                         )
@@ -299,8 +301,8 @@ pub fn search(target: &str) -> Result<Target, String> {
         use serialize::json;
 
         fn load_file(path: &Path) -> Result<Target, String> {
-            let mut f = try!(File::open(path).map_err(|e| e.to_string()));
-            let obj = try!(json::from_reader(&mut f).map_err(|e| e.to_string()));
+            let mut f = try!(File::open(path).map_err(|e| format!("{:?}", e)));
+            let obj = try!(json::from_reader(&mut f).map_err(|e| format!("{:?}", e)));
             Ok(Target::from_json(obj))
         }
 
@@ -313,7 +315,7 @@ macro_rules! load_specific {
                     $(
                         else if target == stringify!($name) {
                             let t = $name::target();
-                            debug!("Got builtin target: {}", t);
+                            debug!("Got builtin target: {:?}", t);
                             return Ok(t);
                         }
                     )*
@@ -367,7 +369,7 @@ macro_rules! load_specific {
 
         let target_path = os::getenv("RUST_TARGET_PATH").unwrap_or(String::new());
 
-        let paths = os::split_paths(target_path[]);
+        let paths = os::split_paths(target_path.index(&FullRange));
         // FIXME 16351: add a sane default search path?
 
         for dir in paths.iter() {
@@ -377,6 +379,6 @@ macro_rules! load_specific {
             }
         }
 
-        Err(format!("Could not find specification for target {}", target))
+        Err(format!("Could not find specification for target {:?}", target))
     }
 }
index cb77519671cf57fd315243a576777e5e47da752f..d942581ca62f22b71a1ff72d4b1267b0a6eb10cb 100644 (file)
@@ -96,7 +96,7 @@ fn consume(&mut self,
                consume_span: Span,
                cmt: mc::cmt<'tcx>,
                mode: euv::ConsumeMode) {
-        debug!("consume(consume_id={}, cmt={}, mode={})",
+        debug!("consume(consume_id={}, cmt={}, mode={:?})",
                consume_id, cmt.repr(self.tcx()), mode);
 
         self.consume_common(consume_id, consume_span, cmt, mode);
@@ -111,7 +111,7 @@ fn consume_pat(&mut self,
                    consume_pat: &ast::Pat,
                    cmt: mc::cmt<'tcx>,
                    mode: euv::ConsumeMode) {
-        debug!("consume_pat(consume_pat={}, cmt={}, mode={})",
+        debug!("consume_pat(consume_pat={}, cmt={}, mode={:?})",
                consume_pat.repr(self.tcx()),
                cmt.repr(self.tcx()),
                mode);
@@ -127,8 +127,8 @@ fn borrow(&mut self,
               bk: ty::BorrowKind,
               loan_cause: euv::LoanCause)
     {
-        debug!("borrow(borrow_id={}, cmt={}, loan_region={}, \
-               bk={}, loan_cause={})",
+        debug!("borrow(borrow_id={}, cmt={}, loan_region={:?}, \
+               bk={:?}, loan_cause={:?})",
                borrow_id, cmt.repr(self.tcx()), loan_region,
                bk, loan_cause);
 
@@ -355,10 +355,10 @@ pub fn check_for_conflicting_loans(&self, scope: region::CodeExtent) {
         //! (Note that some loans can be *issued* without necessarily
         //! taking effect yet.)
 
-        debug!("check_for_conflicting_loans(scope={})", scope);
+        debug!("check_for_conflicting_loans(scope={:?})", scope);
 
         let new_loan_indices = self.loans_generated_by(scope);
-        debug!("new_loan_indices = {}", new_loan_indices);
+        debug!("new_loan_indices = {:?}", new_loan_indices);
 
         self.each_issued_loan(scope, |issued_loan| {
             for &new_loan_index in new_loan_indices.iter() {
@@ -465,7 +465,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                         new_loan.span,
                         format!("cannot borrow `{}`{} as mutable \
                                 more than once at a time",
-                                nl, new_loan_msg)[])
+                                nl, new_loan_msg).index(&FullRange))
                 }
 
                 (ty::UniqueImmBorrow, _) => {
@@ -473,7 +473,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                         new_loan.span,
                         format!("closure requires unique access to `{}` \
                                 but {} is already borrowed{}",
-                                nl, ol_pronoun, old_loan_msg)[]);
+                                nl, ol_pronoun, old_loan_msg).index(&FullRange));
                 }
 
                 (_, ty::UniqueImmBorrow) => {
@@ -481,7 +481,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                         new_loan.span,
                         format!("cannot borrow `{}`{} as {} because \
                                 previous closure requires unique access",
-                                nl, new_loan_msg, new_loan.kind.to_user_str())[]);
+                                nl, new_loan_msg, new_loan.kind.to_user_str()).index(&FullRange));
                 }
 
                 (_, _) => {
@@ -494,7 +494,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                                 new_loan.kind.to_user_str(),
                                 ol_pronoun,
                                 old_loan.kind.to_user_str(),
-                                old_loan_msg)[]);
+                                old_loan_msg).index(&FullRange));
                 }
             }
 
@@ -503,7 +503,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
                     self.bccx.span_note(
                         span,
                         format!("borrow occurs due to use of `{}` in closure",
-                                nl)[]);
+                                nl).index(&FullRange));
                 }
                 _ => { }
             }
@@ -552,7 +552,7 @@ pub fn report_error_if_loan_conflicts_with_restriction(&self,
 
             self.bccx.span_note(
                 old_loan.span,
-                format!("{}; {}", borrow_summary, rule_summary)[]);
+                format!("{}; {}", borrow_summary, rule_summary).index(&FullRange));
 
             let old_loan_span = self.tcx().map.span(old_loan.kill_scope.node_id());
             self.bccx.span_end_note(old_loan_span,
@@ -622,13 +622,13 @@ fn check_for_copy_of_frozen_path(&self,
                 self.bccx.span_err(
                     span,
                     format!("cannot use `{}` because it was mutably borrowed",
-                            self.bccx.loan_path_to_string(copy_path)[])
-                    []);
+                            self.bccx.loan_path_to_string(copy_path).index(&FullRange))
+                    .index(&FullRange));
                 self.bccx.span_note(
                     loan_span,
                     format!("borrow of `{}` occurs here",
-                            self.bccx.loan_path_to_string(&*loan_path)[])
-                    []);
+                            self.bccx.loan_path_to_string(&*loan_path).index(&FullRange))
+                    .index(&FullRange));
             }
         }
     }
@@ -647,20 +647,20 @@ fn check_for_move_of_borrowed_path(&self,
                 let err_message = match move_kind {
                     move_data::Captured =>
                         format!("cannot move `{}` into closure because it is borrowed",
-                                self.bccx.loan_path_to_string(move_path)[]),
+                                self.bccx.loan_path_to_string(move_path).index(&FullRange)),
                     move_data::Declared |
                     move_data::MoveExpr |
                     move_data::MovePat =>
                         format!("cannot move out of `{}` because it is borrowed",
-                                self.bccx.loan_path_to_string(move_path)[])
+                                self.bccx.loan_path_to_string(move_path).index(&FullRange))
                 };
 
-                self.bccx.span_err(span, err_message[]);
+                self.bccx.span_err(span, err_message.index(&FullRange));
                 self.bccx.span_note(
                     loan_span,
                     format!("borrow of `{}` occurs here",
-                            self.bccx.loan_path_to_string(&*loan_path)[])
-                    []);
+                            self.bccx.loan_path_to_string(&*loan_path).index(&FullRange))
+                    .index(&FullRange));
             }
         }
     }
@@ -696,7 +696,7 @@ fn check_if_path_is_moved(&self,
                               span: Span,
                               use_kind: MovedValueUseKind,
                               lp: &Rc<LoanPath<'tcx>>) {
-        debug!("check_if_path_is_moved(id={}, use_kind={}, lp={})",
+        debug!("check_if_path_is_moved(id={}, use_kind={:?}, lp={})",
                id, use_kind, lp.repr(self.bccx.tcx));
         let base_lp = owned_ptr_base_path_rc(lp);
         self.move_data.each_move_of(id, &base_lp, |the_move, moved_lp| {
@@ -810,7 +810,7 @@ fn check_assignment(&self,
                     self.bccx.span_err(
                         assignment_span,
                         format!("cannot assign to {}",
-                                self.bccx.cmt_to_string(&*assignee_cmt))[]);
+                                self.bccx.cmt_to_string(&*assignee_cmt)).index(&FullRange));
                     self.bccx.span_help(
                         self.tcx().map.span(upvar_id.closure_expr_id),
                         "consider changing this closure to take self by mutable reference");
@@ -819,7 +819,7 @@ fn check_assignment(&self,
                         assignment_span,
                         format!("cannot assign to {} {}",
                                 assignee_cmt.mutbl.to_user_str(),
-                                self.bccx.cmt_to_string(&*assignee_cmt))[]);
+                                self.bccx.cmt_to_string(&*assignee_cmt)).index(&FullRange));
                 }
             }
             _ => match opt_loan_path(&assignee_cmt) {
@@ -829,14 +829,14 @@ fn check_assignment(&self,
                         format!("cannot assign to {} {} `{}`",
                                 assignee_cmt.mutbl.to_user_str(),
                                 self.bccx.cmt_to_string(&*assignee_cmt),
-                                self.bccx.loan_path_to_string(&*lp))[]);
+                                self.bccx.loan_path_to_string(&*lp)).index(&FullRange));
                 }
                 None => {
                     self.bccx.span_err(
                         assignment_span,
                         format!("cannot assign to {} {}",
                                 assignee_cmt.mutbl.to_user_str(),
-                                self.bccx.cmt_to_string(&*assignee_cmt))[]);
+                                self.bccx.cmt_to_string(&*assignee_cmt)).index(&FullRange));
                 }
             }
         }
@@ -956,10 +956,10 @@ pub fn report_illegal_mutation(&self,
         self.bccx.span_err(
             span,
             format!("cannot assign to `{}` because it is borrowed",
-                    self.bccx.loan_path_to_string(loan_path))[]);
+                    self.bccx.loan_path_to_string(loan_path)).index(&FullRange));
         self.bccx.span_note(
             loan.span,
             format!("borrow of `{}` occurs here",
-                    self.bccx.loan_path_to_string(loan_path))[]);
+                    self.bccx.loan_path_to_string(loan_path)).index(&FullRange));
     }
 }
index ac2ab56b2c5f8edbb492b5d27787b8eb821bd84a..2100d5a9bc307cec26d3283c165b59b68b626291 100644 (file)
 //! necessary to add any restrictions at all to the final result.
 //!
 //! ```text
-//!     RESTRICTIONS(*LV, LT, []) = []                         // R-Deref-Freeze-Borrowed
+//!     RESTRICTIONS(*LV, LT, []) = []                // R-Deref-Freeze-Borrowed
 //!       TYPE(LV) = &const Ty
 //! ```
 //!
index 0d86811af9f49cfc6e471b694dd766c005adbd1c..d7527487465895db0aea649a865ba5f807cea5f4 100644 (file)
@@ -38,7 +38,7 @@ enum Fragment {
     // This represents the collection of all but one of the elements
     // from an array at the path described by the move path index.
     // Note that attached MovePathIndex should have mem_categorization
-    // of InteriorElement (i.e. array dereference `[]`).
+    // of InteriorElement (i.e. array dereference `.index(&FullRange)`).
     AllButOneFrom(MovePathIndex),
 }
 
@@ -123,12 +123,12 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
         let attrs : &[ast::Attribute];
         attrs = match tcx.map.find(id) {
             Some(ast_map::NodeItem(ref item)) =>
-                item.attrs[],
+                item.attrs.index(&FullRange),
             Some(ast_map::NodeImplItem(&ast::MethodImplItem(ref m))) =>
-                m.attrs[],
+                m.attrs.index(&FullRange),
             Some(ast_map::NodeTraitItem(&ast::ProvidedMethod(ref m))) =>
-                m.attrs[],
-            _ => [][],
+                m.attrs.index(&FullRange),
+            _ => [].index(&FullRange),
         };
 
         let span_err =
@@ -144,7 +144,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
         for (i, mpi) in vec_rc.iter().enumerate() {
             let render = |&:| this.path_loan_path(*mpi).user_string(tcx);
             if span_err {
-                tcx.sess.span_err(sp, format!("{}: `{}`", kind, render())[]);
+                tcx.sess.span_err(sp, format!("{}: `{}`", kind, render()).index(&FullRange));
             }
             if print {
                 println!("id:{} {}[{}] `{}`", id, kind, i, render());
@@ -156,7 +156,7 @@ pub fn instrument_move_fragments<'tcx>(this: &MoveData<'tcx>,
         for (i, f) in vec_rc.iter().enumerate() {
             let render = |&:| f.loan_path_user_string(this, tcx);
             if span_err {
-                tcx.sess.span_err(sp, format!("{}: `{}`", kind, render())[]);
+                tcx.sess.span_err(sp, format!("{}: `{}`", kind, render()).index(&FullRange));
             }
             if print {
                 println!("id:{} {}[{}] `{}`", id, kind, i, render());
@@ -198,11 +198,11 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
     // First, filter out duplicates
     moved.sort();
     moved.dedup();
-    debug!("fragments 1 moved: {}", path_lps(moved[]));
+    debug!("fragments 1 moved: {:?}", path_lps(moved.index(&FullRange)));
 
     assigned.sort();
     assigned.dedup();
-    debug!("fragments 1 assigned: {}", path_lps(assigned[]));
+    debug!("fragments 1 assigned: {:?}", path_lps(assigned.index(&FullRange)));
 
     // Second, build parents from the moved and assigned.
     for m in moved.iter() {
@@ -222,14 +222,14 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
 
     parents.sort();
     parents.dedup();
-    debug!("fragments 2 parents: {}", path_lps(parents[]));
+    debug!("fragments 2 parents: {:?}", path_lps(parents.index(&FullRange)));
 
     // Third, filter the moved and assigned fragments down to just the non-parents
-    moved.retain(|f| non_member(*f, parents[]));
-    debug!("fragments 3 moved: {}", path_lps(moved[]));
+    moved.retain(|f| non_member(*f, parents.index(&FullRange)));
+    debug!("fragments 3 moved: {:?}", path_lps(moved.index(&FullRange)));
 
-    assigned.retain(|f| non_member(*f, parents[]));
-    debug!("fragments 3 assigned: {}", path_lps(assigned[]));
+    assigned.retain(|f| non_member(*f, parents.index(&FullRange)));
+    debug!("fragments 3 assigned: {:?}", path_lps(assigned.index(&FullRange)));
 
     // Fourth, build the leftover from the moved, assigned, and parents.
     for m in moved.iter() {
@@ -247,16 +247,16 @@ pub fn fixup_fragment_sets<'tcx>(this: &MoveData<'tcx>, tcx: &ty::ctxt<'tcx>) {
 
     unmoved.sort();
     unmoved.dedup();
-    debug!("fragments 4 unmoved: {}", frag_lps(unmoved[]));
+    debug!("fragments 4 unmoved: {:?}", frag_lps(unmoved.index(&FullRange)));
 
     // Fifth, filter the leftover fragments down to its core.
     unmoved.retain(|f| match *f {
         AllButOneFrom(_) => true,
-        Just(mpi) => non_member(mpi, parents[]) &&
-            non_member(mpi, moved[]) &&
-            non_member(mpi, assigned[])
+        Just(mpi) => non_member(mpi, parents.index(&FullRange)) &&
+            non_member(mpi, moved.index(&FullRange)) &&
+            non_member(mpi, assigned.index(&FullRange))
     });
-    debug!("fragments 5 unmoved: {}", frag_lps(unmoved[]));
+    debug!("fragments 5 unmoved: {:?}", frag_lps(unmoved.index(&FullRange)));
 
     // Swap contents back in.
     fragments.unmoved_fragments = unmoved;
@@ -430,10 +430,10 @@ fn add_fragment_siblings_for_extension<'tcx>(this: &MoveData<'tcx>,
         }
 
         ref sty_and_variant_info => {
-            let msg = format!("type {} ({}) is not fragmentable",
+            let msg = format!("type {} ({:?}) is not fragmentable",
                               parent_ty.repr(tcx), sty_and_variant_info);
             let opt_span = origin_id.and_then(|id|tcx.map.opt_span(id));
-            tcx.sess.opt_span_bug(opt_span, msg[])
+            tcx.sess.opt_span_bug(opt_span, msg.index(&FullRange))
         }
     }
 }
index 6f02f447a158d7be441513c69ba4cf017dae96fe..ca1fba53de42aa11f6fa1c39929017abaa371e91 100644 (file)
@@ -65,7 +65,7 @@ pub fn gather_match_variant<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
                                       cmt: mc::cmt<'tcx>,
                                       mode: euv::MatchMode) {
     let tcx = bccx.tcx;
-    debug!("gather_match_variant(move_pat={}, cmt={}, mode={})",
+    debug!("gather_match_variant(move_pat={}, cmt={}, mode={:?})",
            move_pat.id, cmt.repr(tcx), mode);
 
     let opt_lp = opt_loan_path(&cmt);
index 1e9e5b22aa0ed85ac85865537b16111e6c49946a..2c48e0da01d77e48f7e51213e564acdd25f264eb 100644 (file)
@@ -76,7 +76,7 @@ fn consume(&mut self,
                _consume_span: Span,
                cmt: mc::cmt<'tcx>,
                mode: euv::ConsumeMode) {
-        debug!("consume(consume_id={}, cmt={}, mode={})",
+        debug!("consume(consume_id={}, cmt={}, mode={:?})",
                consume_id, cmt.repr(self.tcx()), mode);
 
         match mode {
@@ -93,7 +93,7 @@ fn matched_pat(&mut self,
                    matched_pat: &ast::Pat,
                    cmt: mc::cmt<'tcx>,
                    mode: euv::MatchMode) {
-        debug!("matched_pat(matched_pat={}, cmt={}, mode={})",
+        debug!("matched_pat(matched_pat={}, cmt={}, mode={:?})",
                matched_pat.repr(self.tcx()),
                cmt.repr(self.tcx()),
                mode);
@@ -109,7 +109,7 @@ fn consume_pat(&mut self,
                    consume_pat: &ast::Pat,
                    cmt: mc::cmt<'tcx>,
                    mode: euv::ConsumeMode) {
-        debug!("consume_pat(consume_pat={}, cmt={}, mode={})",
+        debug!("consume_pat(consume_pat={}, cmt={}, mode={:?})",
                consume_pat.repr(self.tcx()),
                cmt.repr(self.tcx()),
                mode);
@@ -132,8 +132,8 @@ fn borrow(&mut self,
               bk: ty::BorrowKind,
               loan_cause: euv::LoanCause)
     {
-        debug!("borrow(borrow_id={}, cmt={}, loan_region={}, \
-               bk={}, loan_cause={})",
+        debug!("borrow(borrow_id={}, cmt={}, loan_region={:?}, \
+               bk={:?}, loan_cause={:?})",
                borrow_id, cmt.repr(self.tcx()), loan_region,
                bk, loan_cause);
 
@@ -235,7 +235,7 @@ fn guarantee_valid(&mut self,
                        loan_region: ty::Region,
                        cause: euv::LoanCause) {
         debug!("guarantee_valid(borrow_id={}, cmt={}, \
-                req_mutbl={}, loan_region={})",
+                req_mutbl={:?}, loan_region={:?})",
                borrow_id,
                cmt.repr(self.tcx()),
                req_kind,
@@ -273,7 +273,7 @@ fn guarantee_valid(&mut self,
             self.bccx, borrow_span, cause,
             cmt.clone(), loan_region);
 
-        debug!("guarantee_valid(): restrictions={}", restr);
+        debug!("guarantee_valid(): restrictions={:?}", restr);
 
         // Create the loan record (if needed).
         let loan = match restr {
@@ -306,18 +306,18 @@ fn guarantee_valid(&mut self,
                     ty::ReInfer(..) => {
                         self.tcx().sess.span_bug(
                             cmt.span,
-                            format!("invalid borrow lifetime: {}",
-                                    loan_region)[]);
+                            format!("invalid borrow lifetime: {:?}",
+                                    loan_region).index(&FullRange));
                     }
                 };
-                debug!("loan_scope = {}", loan_scope);
+                debug!("loan_scope = {:?}", loan_scope);
 
                 let borrow_scope = region::CodeExtent::from_node_id(borrow_id);
                 let gen_scope = self.compute_gen_scope(borrow_scope, loan_scope);
-                debug!("gen_scope = {}", gen_scope);
+                debug!("gen_scope = {:?}", gen_scope);
 
                 let kill_scope = self.compute_kill_scope(loan_scope, &*loan_path);
-                debug!("kill_scope = {}", kill_scope);
+                debug!("kill_scope = {:?}", kill_scope);
 
                 if req_kind == ty::MutBorrow {
                     self.mark_loan_path_as_mutated(&*loan_path);
index 95c5d9415a1250f8a194ade562d0ac85e9928109..1bb143e1dc8d3c87d66a7534bf0cc2e3090070d9 100644 (file)
@@ -120,7 +120,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
             bccx.span_err(
                 move_from.span,
                 format!("cannot move out of {}",
-                        bccx.cmt_to_string(&*move_from))[]);
+                        bccx.cmt_to_string(&*move_from)).index(&FullRange));
         }
 
         mc::cat_downcast(ref b, _) |
@@ -132,7 +132,7 @@ fn report_cannot_move_out_of<'a, 'tcx>(bccx: &BorrowckCtxt<'a, 'tcx>,
                         move_from.span,
                         format!("cannot move out of type `{}`, \
                                  which defines the `Drop` trait",
-                                b.ty.user_string(bccx.tcx))[]);
+                                b.ty.user_string(bccx.tcx)).index(&FullRange));
                 },
                 _ => panic!("this path should not cause illegal move")
             }
@@ -155,10 +155,10 @@ fn note_move_destination(bccx: &BorrowckCtxt,
             format!("to prevent the move, \
                      use `ref {0}` or `ref mut {0}` to capture value by \
                      reference",
-                    pat_name)[]);
+                    pat_name).index(&FullRange));
     } else {
         bccx.span_note(move_to_span,
                        format!("and here (use `ref {0}` or `ref mut {0}`)",
-                               pat_name)[]);
+                               pat_name).index(&FullRange));
     }
 }
index 20949151557cbeec572e1cd76102e75ec5d2c399..88f56f6862218b276c227945c733e9d897e047f1 100644 (file)
@@ -137,7 +137,7 @@ fn borrowck_fn(this: &mut BorrowckCtxt,
     check_loans::check_loans(this,
                              &loan_dfcx,
                              flowed_moves,
-                             all_loans[],
+                             all_loans.index(&FullRange),
                              id,
                              decl,
                              body);
@@ -505,7 +505,7 @@ pub fn is_subregion_of(&self, r_sub: ty::Region, r_sup: ty::Region)
     pub fn report(&self, err: BckError<'tcx>) {
         self.span_err(
             err.span,
-            self.bckerr_to_string(&err)[]);
+            self.bckerr_to_string(&err).index(&FullRange));
         self.note_and_explain_bckerr(err);
     }
 
@@ -527,7 +527,7 @@ pub fn report_use_of_moved_value<'b>(&self,
                     use_span,
                     format!("{} of possibly uninitialized variable: `{}`",
                             verb,
-                            self.loan_path_to_string(lp))[]);
+                            self.loan_path_to_string(lp)).index(&FullRange));
                 (self.loan_path_to_string(moved_lp),
                  String::new())
             }
@@ -569,7 +569,7 @@ pub fn report_use_of_moved_value<'b>(&self,
                     format!("{} of {}moved value: `{}`",
                             verb,
                             msg,
-                            nl)[]);
+                            nl).index(&FullRange));
                 (ol, moved_lp_msg)
             }
         };
@@ -586,9 +586,9 @@ pub fn report_use_of_moved_value<'b>(&self,
                     }
                     r => {
                         self.tcx.sess.bug(format!("MoveExpr({}) maps to \
-                                                   {}, not Expr",
+                                                   {:?}, not Expr",
                                                   the_move.id,
-                                                  r)[])
+                                                  r).index(&FullRange))
                     }
                 };
                 let (suggestion, _) =
@@ -599,7 +599,7 @@ pub fn report_use_of_moved_value<'b>(&self,
                             ol,
                             moved_lp_msg,
                             expr_ty.user_string(self.tcx),
-                            suggestion)[]);
+                            suggestion).index(&FullRange));
             }
 
             move_data::MovePat => {
@@ -610,7 +610,7 @@ pub fn report_use_of_moved_value<'b>(&self,
                              which is moved by default",
                             ol,
                             moved_lp_msg,
-                            pat_ty.user_string(self.tcx))[]);
+                            pat_ty.user_string(self.tcx)).index(&FullRange));
                 self.tcx.sess.span_help(span,
                     "use `ref` to override");
             }
@@ -624,9 +624,9 @@ pub fn report_use_of_moved_value<'b>(&self,
                     }
                     r => {
                         self.tcx.sess.bug(format!("Captured({}) maps to \
-                                                   {}, not Expr",
+                                                   {:?}, not Expr",
                                                   the_move.id,
-                                                  r)[])
+                                                  r).index(&FullRange))
                     }
                 };
                 let (suggestion, help) =
@@ -642,7 +642,7 @@ pub fn report_use_of_moved_value<'b>(&self,
                             ol,
                             moved_lp_msg,
                             expr_ty.user_string(self.tcx),
-                            suggestion)[]);
+                            suggestion).index(&FullRange));
                 self.tcx.sess.span_help(expr_span, help);
             }
         }
@@ -673,7 +673,7 @@ pub fn report_reassigned_immutable_variable(&self,
         self.tcx.sess.span_err(
             span,
             format!("re-assignment of immutable variable `{}`",
-                    self.loan_path_to_string(lp))[]);
+                    self.loan_path_to_string(lp)).index(&FullRange));
         self.tcx.sess.span_note(assign.span, "prior assignment occurs here");
     }
 
@@ -799,12 +799,12 @@ pub fn report_aliasability_violation(&self,
                 self.tcx.sess.span_err(
                     span,
                     format!("{} in an aliasable location",
-                             prefix)[]);
+                             prefix).index(&FullRange));
             }
             mc::AliasableClosure(id) => {
                 self.tcx.sess.span_err(span,
                                        format!("{} in a captured outer \
-                                               variable in an `Fn` closure", prefix)[]);
+                                               variable in an `Fn` closure", prefix).as_slice());
                 span_help!(self.tcx.sess, self.tcx.map.span(id),
                            "consider changing this closure to take self by mutable reference");
             }
@@ -812,12 +812,12 @@ pub fn report_aliasability_violation(&self,
             mc::AliasableStaticMut(..) => {
                 self.tcx.sess.span_err(
                     span,
-                    format!("{} in a static location", prefix)[]);
+                    format!("{} in a static location", prefix).index(&FullRange));
             }
             mc::AliasableBorrowed => {
                 self.tcx.sess.span_err(
                     span,
-                    format!("{} in a `&` reference", prefix)[]);
+                    format!("{} in a `&` reference", prefix).index(&FullRange));
             }
         }
 
@@ -885,12 +885,12 @@ pub fn note_and_explain_bckerr(&self, err: BckError<'tcx>) {
                 note_and_explain_region(
                     self.tcx,
                     format!("{} would have to be valid for ",
-                            descr)[],
+                            descr).index(&FullRange),
                     loan_scope,
                     "...");
                 note_and_explain_region(
                     self.tcx,
-                    format!("...but {} is only valid for ", descr)[],
+                    format!("...but {} is only valid for ", descr).index(&FullRange),
                     ptr_scope,
                     "");
             }
@@ -910,7 +910,7 @@ pub fn append_loan_path_to_string(&self,
                 out.push('(');
                 self.append_loan_path_to_string(&**lp_base, out);
                 out.push_str(DOWNCAST_PRINTED_OPERATOR);
-                out.push_str(ty::item_path_str(self.tcx, variant_def_id)[]);
+                out.push_str(ty::item_path_str(self.tcx, variant_def_id).index(&FullRange));
                 out.push(')');
             }
 
@@ -924,7 +924,7 @@ pub fn append_loan_path_to_string(&self,
                     }
                     mc::PositionalField(idx) => {
                         out.push('.');
-                        out.push_str(idx.to_string()[]);
+                        out.push_str(idx.to_string().index(&FullRange));
                     }
                 }
             }
@@ -956,7 +956,7 @@ pub fn append_autoderefd_loan_path_to_string(&self,
                 out.push('(');
                 self.append_autoderefd_loan_path_to_string(&**lp_base, out);
                 out.push(':');
-                out.push_str(ty::item_path_str(self.tcx, variant_def_id)[]);
+                out.push_str(ty::item_path_str(self.tcx, variant_def_id).index(&FullRange));
                 out.push(')');
             }
 
@@ -1005,7 +1005,7 @@ fn initial_value(&self) -> bool {
 
 impl<'tcx> Repr<'tcx> for Loan<'tcx> {
     fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
-        format!("Loan_{}({}, {}, {}-{}, {})",
+        format!("Loan_{}({}, {:?}, {:?}-{:?}, {})",
                  self.index,
                  self.loan_path.repr(tcx),
                  self.kind,
index b49164f0c25476aa46c9333841e775ff2117a059..21b3c910d328a72ec814ec97dd18969308bf9421 100644 (file)
@@ -311,7 +311,7 @@ pub fn move_path(&self,
             }
         };
 
-        debug!("move_path(lp={}, index={})",
+        debug!("move_path(lp={}, index={:?})",
                lp.repr(tcx),
                index);
 
@@ -362,7 +362,7 @@ pub fn add_move(&self,
                     lp: Rc<LoanPath<'tcx>>,
                     id: ast::NodeId,
                     kind: MoveKind) {
-        debug!("add_move(lp={}, id={}, kind={})",
+        debug!("add_move(lp={}, id={}, kind={:?})",
                lp.repr(tcx),
                id,
                kind);
@@ -413,12 +413,12 @@ pub fn add_assignment(&self,
         };
 
         if self.is_var_path(path_index) {
-            debug!("add_assignment[var](lp={}, assignment={}, path_index={})",
+            debug!("add_assignment[var](lp={}, assignment={}, path_index={:?})",
                    lp.repr(tcx), self.var_assignments.borrow().len(), path_index);
 
             self.var_assignments.borrow_mut().push(assignment);
         } else {
-            debug!("add_assignment[path](lp={}, path_index={})",
+            debug!("add_assignment[path](lp={}, path_index={:?})",
                    lp.repr(tcx), path_index);
 
             self.path_assignments.borrow_mut().push(assignment);
index f2c35851d0d7c6484429951d9b799a0a78fff425..647a5dd559c1dcd60c65357eac00976439824d72 100644 (file)
@@ -53,14 +53,14 @@ pub struct DataflowLabeller<'a, 'tcx: 'a> {
 impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> {
     fn dataflow_for(&self, e: EntryOrExit, n: &Node<'a>) -> String {
         let id = n.1.data.id;
-        debug!("dataflow_for({}, id={}) {}", e, id, self.variants);
+        debug!("dataflow_for({:?}, id={}) {:?}", e, id, self.variants);
         let mut sets = "".to_string();
         let mut seen_one = false;
         for &variant in self.variants.iter() {
             if seen_one { sets.push_str(" "); } else { seen_one = true; }
             sets.push_str(variant.short_name());
             sets.push_str(": ");
-            sets.push_str(self.dataflow_for_variant(e, n, variant)[]);
+            sets.push_str(self.dataflow_for_variant(e, n, variant).index(&FullRange));
         }
         sets
     }
@@ -89,7 +89,7 @@ fn build_set<O:DataFlowOperator, F>(&self,
                 set.push_str(", ");
             }
             let loan_str = self.borrowck_ctxt.loan_path_to_string(&*lp);
-            set.push_str(loan_str[]);
+            set.push_str(loan_str.index(&FullRange));
             saw_some = true;
             true
         });
@@ -101,7 +101,8 @@ 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 all_loans = &self.analysis_data.all_loans;
-            all_loans[loan_index].loan_path()
+            let l: &borrowck::Loan = &all_loans[loan_index];
+            l.loan_path()
         };
         self.build_set(e, cfgidx, dfcx, loan_index_to_path)
     }
@@ -111,7 +112,7 @@ fn dataflow_moves_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
         let move_index_to_path = |&mut: move_index| {
             let move_data = &self.analysis_data.move_data.move_data;
             let moves = move_data.moves.borrow();
-            let the_move = &(*moves)[move_index];
+            let the_move: &borrowck::move_data::Move = &(*moves)[move_index];
             move_data.path_loan_path(the_move.path)
         };
         self.build_set(e, cfgidx, dfcx, move_index_to_path)
@@ -122,7 +123,7 @@ fn dataflow_assigns_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String {
         let assign_index_to_path = |&mut: assign_index| {
             let move_data = &self.analysis_data.move_data.move_data;
             let assignments = move_data.var_assignments.borrow();
-            let assignment = &(*assignments)[assign_index];
+            let assignment: &borrowck::move_data::Assignment = &(*assignments)[assign_index];
             move_data.path_loan_path(assignment.path)
         };
         self.build_set(e, cfgidx, dfcx, assign_index_to_path)
index 0600ddba01897e1e257848c6533ca51b90c9c67a..26bcd5f4c10cd3b82c702dd34fb13e7cb09a2f89 100644 (file)
       html_root_url = "http://doc.rust-lang.org/nightly/")]
 
 #![allow(unknown_features)]
-#![feature(default_type_params, globs, macro_rules, phase, quote)]
+#![feature(quote)]
 #![feature(slicing_syntax, unsafe_destructor)]
 #![feature(rustc_diagnostic_macros)]
-#![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
 #![allow(non_camel_case_types)]
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate syntax;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate syntax;
+#[macro_use] extern crate log;
+#[macro_use] extern crate syntax;
 
 // for "clarity", rename the graphviz crate to dot; graphviz within `borrowck`
 // refers to the borrowck-specific graphviz adapter traits.
index 74f81ae9d6d1eeb7f256f4cc940e847caa7a574d..52d49924d05d51fe43421d5f524d156ae0daf792 100644 (file)
@@ -58,12 +58,12 @@ pub fn compile_input(sess: Session,
             let outputs = build_output_filenames(input,
                                                  outdir,
                                                  output,
-                                                 krate.attrs[],
+                                                 krate.attrs.index(&FullRange),
                                                  &sess);
-            let id = link::find_crate_name(Some(&sess), krate.attrs[],
+            let id = link::find_crate_name(Some(&sess), krate.attrs.index(&FullRange),
                                            input);
             let expanded_crate
-                = match phase_2_configure_and_expand(&sess, krate, id[],
+                = match phase_2_configure_and_expand(&sess, krate, id.index(&FullRange),
                                                      addl_plugins) {
                     None => return,
                     Some(k) => k
@@ -75,7 +75,7 @@ pub fn compile_input(sess: Session,
         let mut forest = ast_map::Forest::new(expanded_crate);
         let ast_map = assign_node_ids_and_map(&sess, &mut forest);
 
-        write_out_deps(&sess, input, &outputs, id[]);
+        write_out_deps(&sess, input, &outputs, id.index(&FullRange));
 
         if stop_after_phase_2(&sess) { return; }
 
@@ -171,9 +171,9 @@ pub fn phase_2_configure_and_expand(sess: &Session,
     let time_passes = sess.time_passes();
 
     *sess.crate_types.borrow_mut() =
-        collect_crate_types(sess, krate.attrs[]);
+        collect_crate_types(sess, krate.attrs.index(&FullRange));
     *sess.crate_metadata.borrow_mut() =
-        collect_crate_metadata(sess, krate.attrs[]);
+        collect_crate_metadata(sess, krate.attrs.index(&FullRange));
 
     time(time_passes, "recursion limit", (), |_| {
         middle::recursion_limit::update_recursion_limit(sess, &krate);
@@ -268,8 +268,8 @@ pub fn phase_2_configure_and_expand(sess: &Session,
             if cfg!(windows) {
                 _old_path = os::getenv("PATH").unwrap_or(_old_path);
                 let mut new_path = sess.host_filesearch(PathKind::All).get_dylib_search_paths();
-                new_path.extend(os::split_paths(_old_path[]).into_iter());
-                os::setenv("PATH", os::join_paths(new_path[]).unwrap());
+                new_path.extend(os::split_paths(_old_path.index(&FullRange)).into_iter());
+                os::setenv("PATH", os::join_paths(new_path.index(&FullRange)).unwrap());
             }
             let cfg = syntax::ext::expand::ExpansionConfig {
                 crate_name: crate_name.to_string(),
@@ -533,7 +533,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
         time(sess.time_passes(), "LLVM passes", (), |_|
             write::run_passes(sess,
                               trans,
-                              sess.opts.output_types[],
+                              sess.opts.output_types.index(&FullRange),
                               outputs));
     }
 
@@ -547,14 +547,14 @@ pub fn phase_6_link_output(sess: &Session,
                            outputs: &OutputFilenames) {
     let old_path = os::getenv("PATH").unwrap_or_else(||String::new());
     let mut new_path = sess.host_filesearch(PathKind::All).get_tools_search_paths();
-    new_path.extend(os::split_paths(old_path[]).into_iter());
-    os::setenv("PATH", os::join_paths(new_path[]).unwrap());
+    new_path.extend(os::split_paths(old_path.index(&FullRange)).into_iter());
+    os::setenv("PATH", os::join_paths(new_path.index(&FullRange)).unwrap());
 
     time(sess.time_passes(), "linking", (), |_|
          link::link_binary(sess,
                            trans,
                            outputs,
-                           trans.link.crate_name[]));
+                           trans.link.crate_name.index(&FullRange)));
 
     os::setenv("PATH", old_path);
 }
@@ -643,7 +643,7 @@ fn write_out_deps(sess: &Session,
         // write Makefile-compatible dependency rules
         let files: Vec<String> = sess.codemap().files.borrow()
                                    .iter().filter(|fmap| fmap.is_real_file())
-                                   .map(|fmap| escape_dep_filename(fmap.name[]))
+                                   .map(|fmap| escape_dep_filename(fmap.name.index(&FullRange)))
                                    .collect();
         let mut file = try!(io::File::create(&deps_filename));
         for path in out_filenames.iter() {
@@ -657,7 +657,7 @@ fn write_out_deps(sess: &Session,
         Ok(()) => {}
         Err(e) => {
             sess.fatal(format!("error writing dependencies to `{}`: {}",
-                               deps_filename.display(), e)[]);
+                               deps_filename.display(), e).index(&FullRange));
         }
     }
 }
@@ -726,9 +726,9 @@ pub fn collect_crate_types(session: &Session,
         let res = !link::invalid_output_for_target(session, *crate_type);
 
         if !res {
-            session.warn(format!("dropping unsupported crate type `{}` \
+            session.warn(format!("dropping unsupported crate type `{:?}` \
                                    for target `{}`",
-                                 *crate_type, session.opts.target_triple)[]);
+                                 *crate_type, session.opts.target_triple).index(&FullRange));
         }
 
         res
index 89b2e0f257acd97b5ca75a1b0c2b393e0f7e84dc..5af114abeea77ca85c7cdb7f6c7b79298d27a3d7 100644 (file)
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![feature(default_type_params, globs, macro_rules, phase, quote)]
+#![feature(quote)]
 #![feature(slicing_syntax, unsafe_destructor)]
 #![feature(rustc_diagnostic_macros)]
-#![feature(unboxed_closures)]
-#![feature(associated_types)]
 
 extern crate arena;
 extern crate flate;
 extern crate rustc_typeck;
 extern crate serialize;
 extern crate "rustc_llvm" as llvm;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate syntax;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate syntax;
+#[macro_use] extern crate log;
+#[macro_use] extern crate syntax;
 
 pub use syntax::diagnostic;
 
@@ -105,12 +89,12 @@ fn run_compiler(args: &[String]) {
     let descriptions = diagnostics::registry::Registry::new(&DIAGNOSTICS);
     match matches.opt_str("explain") {
         Some(ref code) => {
-            match descriptions.find_description(code[]) {
+            match descriptions.find_description(code.index(&FullRange)) {
                 Some(ref description) => {
                     println!("{}", description);
                 }
                 None => {
-                    early_error(format!("no extended information for {}", code)[]);
+                    early_error(format!("no extended information for {}", code).index(&FullRange));
                 }
             }
             return;
@@ -136,7 +120,7 @@ fn run_compiler(args: &[String]) {
             early_error("no input filename given");
         }
         1u => {
-            let ifile = matches.free[0][];
+            let ifile = matches.free[0].index(&FullRange);
             if ifile == "-" {
                 let contents = io::stdin().read_to_end().unwrap();
                 let src = String::from_utf8(contents).unwrap();
@@ -313,7 +297,7 @@ fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
         for lint in lints.into_iter() {
             let name = lint.name_lower().replace("_", "-");
             println!("    {}  {:7.7}  {}",
-                     padded(name[]), lint.default_level.as_str(), lint.desc);
+                     padded(name.index(&FullRange)), lint.default_level.as_str(), lint.desc);
         }
         println!("\n");
     };
@@ -343,7 +327,7 @@ fn sort_lint_groups(lints: Vec<(&'static str, Vec<lint::LintId>, bool)>)
             let desc = to.into_iter().map(|x| x.as_str().replace("_", "-"))
                          .collect::<Vec<String>>().connect(", ");
             println!("    {}  {}",
-                     padded(name[]), desc);
+                     padded(name.index(&FullRange)), desc);
         }
         println!("\n");
     };
@@ -409,7 +393,7 @@ pub fn handle_options(mut args: Vec<String>) -> Option<getopts::Matches> {
     }
 
     let matches =
-        match getopts::getopts(args[], config::optgroups()[]) {
+        match getopts::getopts(args.index(&FullRange), config::optgroups().index(&FullRange)) {
             Ok(m) => m,
             Err(f_stable_attempt) => {
                 // redo option parsing, including unstable options this time,
@@ -559,7 +543,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
         cfg = cfg.stack_size(STACK_SIZE);
     }
 
-    match cfg.spawn(move || { std::io::stdio::set_stderr(box w); f() }).join() {
+    match cfg.scoped(move || { std::io::stdio::set_stderr(box w); f() }).join() {
         Ok(()) => { /* fallthrough */ }
         Err(value) => {
             // Thread panicked without emitting a fatal diagnostic
@@ -583,7 +567,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
                     "run with `RUST_BACKTRACE=1` for a backtrace".to_string(),
                 ];
                 for note in xs.iter() {
-                    emitter.emit(None, note[], None, diagnostic::Note)
+                    emitter.emit(None, note.index(&FullRange), None, diagnostic::Note)
                 }
 
                 match r.read_to_string() {
@@ -591,7 +575,7 @@ pub fn monitor<F:FnOnce()+Send>(f: F) {
                     Err(e) => {
                         emitter.emit(None,
                                      format!("failed to read internal \
-                                              stderr: {}", e)[],
+                                              stderr: {}", e).index(&FullRange),
                                      None,
                                      diagnostic::Error)
                     }
index 61fd7d16ab7ddea401a618297fa3dc6e7cafc56d..44a35ef6be70be5178bd20d83cb3257c6c36f763 100644 (file)
@@ -296,7 +296,7 @@ fn post(&self,
                 try!(pp::word(&mut s.s,
                               ppaux::ty_to_string(
                                   tcx,
-                                  ty::expr_ty(tcx, expr))[]));
+                                  ty::expr_ty(tcx, expr)).index(&FullRange)));
                 s.pclose()
             }
             _ => Ok(())
@@ -370,7 +370,7 @@ fn all_matching_node_ids<'a, 'ast>(&'a self, map: &'a ast_map::Map<'ast>)
             ItemViaNode(node_id) =>
                 NodesMatchingDirect(Some(node_id).into_iter()),
             ItemViaPath(ref parts) =>
-                NodesMatchingSuffix(map.nodes_matching_suffix(parts[])),
+                NodesMatchingSuffix(map.nodes_matching_suffix(parts.index(&FullRange))),
         }
     }
 
@@ -382,7 +382,7 @@ fn to_one_node_id(self, user_option: &str, sess: &Session, map: &ast_map::Map) -
                         user_option,
                         self.reconstructed_input(),
                         is_wrong_because);
-            sess.fatal(message[])
+            sess.fatal(message.index(&FullRange))
         };
 
         let mut saw_node = ast::DUMMY_NODE_ID;
@@ -509,7 +509,7 @@ pub fn pretty_print_input(sess: Session,
     let is_expanded = needs_expansion(&ppm);
     let compute_ast_map = needs_ast_map(&ppm, &opt_uii);
     let krate = if compute_ast_map {
-        match driver::phase_2_configure_and_expand(&sess, krate, id[], None) {
+        match driver::phase_2_configure_and_expand(&sess, krate, id.index(&FullRange), None) {
             None => return,
             Some(k) => k
         }
@@ -528,7 +528,7 @@ pub fn pretty_print_input(sess: Session,
     };
 
     let src_name = driver::source_name(input);
-    let src = sess.codemap().get_filemap(src_name[])
+    let src = sess.codemap().get_filemap(src_name.index(&FullRange))
                             .src.as_bytes().to_vec();
     let mut rdr = MemReader::new(src);
 
@@ -548,7 +548,7 @@ pub fn pretty_print_input(sess: Session,
         (PpmSource(s), None) =>
             s.call_with_pp_support(
                 sess, ast_map, &arenas, id, out, |annotation, out| {
-                    debug!("pretty printing source code {}", s);
+                    debug!("pretty printing source code {:?}", s);
                     let sess = annotation.sess();
                     pprust::print_crate(sess.codemap(),
                                         sess.diagnostic(),
@@ -563,7 +563,7 @@ pub fn pretty_print_input(sess: Session,
         (PpmSource(s), Some(uii)) =>
             s.call_with_pp_support(
                 sess, ast_map, &arenas, id, (out,uii), |annotation, (out,uii)| {
-                    debug!("pretty printing source code {}", s);
+                    debug!("pretty printing source code {:?}", s);
                     let sess = annotation.sess();
                     let ast_map = annotation.ast_map()
                         .expect("--pretty missing ast_map");
@@ -586,10 +586,10 @@ pub fn pretty_print_input(sess: Session,
                 }),
 
         (PpmFlowGraph, opt_uii) => {
-            debug!("pretty printing flow graph for {}", opt_uii);
+            debug!("pretty printing flow graph for {:?}", opt_uii);
             let uii = opt_uii.unwrap_or_else(|| {
                 sess.fatal(format!("`pretty flowgraph=..` needs NodeId (int) or
-                                     unique path suffix (b::c::d)")[])
+                                     unique path suffix (b::c::d)").index(&FullRange))
 
             });
             let ast_map = ast_map.expect("--pretty flowgraph missing ast_map");
@@ -597,7 +597,7 @@ pub fn pretty_print_input(sess: Session,
 
             let node = ast_map.find(nodeid).unwrap_or_else(|| {
                 sess.fatal(format!("--pretty flowgraph couldn't find id: {}",
-                                   nodeid)[])
+                                   nodeid).index(&FullRange))
             });
 
             let code = blocks::Code::from_node(node);
@@ -609,14 +609,14 @@ pub fn pretty_print_input(sess: Session,
                 }
                 None => {
                     let message = format!("--pretty=flowgraph needs \
-                                           block, fn, or method; got {}",
+                                           block, fn, or method; got {:?}",
                                           node);
 
                     // point to what was found, if there's an
                     // accessible span.
                     match ast_map.opt_span(nodeid) {
-                        Some(sp) => sess.span_fatal(sp, message[]),
-                        None => sess.fatal(message[])
+                        Some(sp) => sess.span_fatal(sp, message.index(&FullRange)),
+                        None => sess.fatal(message.index(&FullRange))
                     }
                 }
             }
index b1e65dce6045a592200f44e9d29cd5f760e09447..d301e9c7b5c279b8e850a4fa1e2de9d2805fcb3f 100644 (file)
@@ -279,7 +279,7 @@ pub fn t_pair(&self, ty1: Ty<'tcx>, ty2: Ty<'tcx>) -> Ty<'tcx> {
 
     pub fn t_param(&self, space: subst::ParamSpace, index: u32) -> Ty<'tcx> {
         let name = format!("T{}", index);
-        ty::mk_param(self.infcx.tcx, space, index, token::intern(name[]))
+        ty::mk_param(self.infcx.tcx, space, index, token::intern(name.index(&FullRange)))
     }
 
     pub fn re_early_bound(&self,
@@ -418,7 +418,7 @@ pub fn check_glb(&self, t1: Ty<'tcx>, t2: Ty<'tcx>, t_glb: Ty<'tcx>) {
                self.ty_to_string(t_glb));
         match self.glb().tys(t1, t2) {
             Err(e) => {
-                panic!("unexpected error computing LUB: {}", e)
+                panic!("unexpected error computing LUB: {:?}", e)
             }
             Ok(t) => {
                 self.assert_eq(t, t_glb);
@@ -841,7 +841,7 @@ fn walk_ty_skip_subtree() {
 
         let mut walker = uniq_ty.walk();
         while let Some(t) = walker.next() {
-            debug!("walked to {}", t);
+            debug!("walked to {:?}", t);
             let (expected_ty, skip) = expected.pop().unwrap();
             assert_eq!(t, expected_ty);
             if skip { walker.skip_current_subtree(); }
index 8a9334be985f70b04d177ec6402b734bd4b066e3..0bed754aa3c1bf8cb351377baab05543ae2cb067 100644 (file)
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![feature(globs)]
 #![feature(link_args)]
-#![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
 
 extern crate libc;
 
index 10788f9f7cb83e67c296651d0273dc7c22af7161..ca6b1469f856934a55b78568a915e7a7cb04f859 100644 (file)
@@ -221,14 +221,14 @@ fn add_child(&self,
                     self.resolve_error(sp,
                         format!("duplicate definition of {} `{}`",
                              namespace_error_to_string(duplicate_type),
-                             token::get_name(name))[]);
+                             token::get_name(name)).index(&FullRange));
                     {
                         let r = child.span_for_namespace(ns);
                         for sp in r.iter() {
                             self.session.span_note(*sp,
                                  format!("first definition of {} `{}` here",
                                       namespace_error_to_string(duplicate_type),
-                                      token::get_name(name))[]);
+                                      token::get_name(name)).index(&FullRange));
                         }
                     }
                 }
@@ -845,7 +845,7 @@ fn handle_external_def(&mut self,
                            name: Name,
                            new_parent: &Rc<Module>) {
         debug!("(building reduced graph for \
-                external crate) building external def, priv {}",
+                external crate) building external def, priv {:?}",
                vis);
         let is_public = vis == ast::Public;
         let modifiers = if is_public { PUBLIC } else { DefModifiers::empty() } | IMPORTABLE;
@@ -989,7 +989,7 @@ fn handle_external_def(&mut self,
           DefLocal(..) | DefPrimTy(..) | DefTyParam(..) |
           DefUse(..) | DefUpvar(..) | DefRegion(..) |
           DefTyParamBinder(..) | DefLabel(..) | DefSelfTy(..) => {
-            panic!("didn't expect `{}`", def);
+            panic!("didn't expect `{:?}`", def);
           }
         }
     }
@@ -1201,7 +1201,7 @@ fn build_import_directive(&mut self,
                 debug!("(building import directive) building import \
                         directive: {}::{}",
                        self.names_to_string(module_.imports.borrow().last().unwrap()
-                                                 .module_path[]),
+                                                 .module_path.index(&FullRange)),
                        token::get_name(target));
 
                 let mut import_resolutions = module_.import_resolutions
index 26b1058d18341781742acd22b0f7f12934e1391c..18066a7b94bd82fff2ab5bc6c03b8fa3062b0689 100644 (file)
@@ -58,7 +58,7 @@ impl<'a, 'b, 'tcx> UnusedImportCheckVisitor<'a, 'b, 'tcx> {
     // public or private item, we will check the correct thing, dependent on how the import
     // is used.
     fn finalize_import(&mut self, id: ast::NodeId, span: Span) {
-        debug!("finalizing import uses for {}",
+        debug!("finalizing import uses for {:?}",
                 self.session.codemap().span_to_snippet(span));
 
         if !self.used_imports.contains(&(id, TypeNS)) &&
index 58102fe5629d9f43bc2656d609830f2451a0f68e..93ad69e03b17f1af3eb84dd1850b74a14e52a266 100644 (file)
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![feature(globs, phase, slicing_syntax)]
+#![feature(slicing_syntax)]
 #![feature(rustc_diagnostic_macros)]
-#![feature(associated_types)]
-#![feature(old_orphan_check)]
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate syntax;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate syntax;
+#[macro_use] extern crate log;
+#[macro_use] extern crate syntax;
 
 extern crate rustc;
 
@@ -86,9 +71,9 @@
 use syntax::ast::{RegionTyParamBound, StructField};
 use syntax::ast::{TraitRef, TraitTyParamBound};
 use syntax::ast::{Ty, TyBool, TyChar, TyF32};
-use syntax::ast::{TyF64, TyFloat, TyI, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
+use syntax::ast::{TyF64, TyFloat, TyIs, TyI8, TyI16, TyI32, TyI64, TyInt, TyObjectSum};
 use syntax::ast::{TyParam, TyParamBound, TyPath, TyPtr, TyPolyTraitRef, TyQPath};
-use syntax::ast::{TyRptr, TyStr, TyU, TyU8, TyU16, TyU32, TyU64, TyUint};
+use syntax::ast::{TyRptr, TyStr, TyUs, TyU8, TyU16, TyU32, TyU64, TyUint};
 use syntax::ast::{TypeImplItem};
 use syntax::ast;
 use syntax::ast_map;
@@ -548,7 +533,7 @@ fn all_imports_resolved(&self) -> bool {
 
 impl fmt::Show for Module {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}, kind: {}, {}",
+        write!(f, "{:?}, kind: {:?}, {}",
                self.def_id,
                self.kind,
                if self.is_public { "public" } else { "private" } )
@@ -689,7 +674,7 @@ fn set_module_kind(&self,
 
     /// Records a type definition.
     fn define_type(&self, def: Def, sp: Span, modifiers: DefModifiers) {
-        debug!("defining type for def {} with modifiers {}", def, modifiers);
+        debug!("defining type for def {:?} with modifiers {:?}", def, modifiers);
         // Merges the type with the existing type def or creates a new one.
         let type_def = self.type_def.borrow().clone();
         match type_def {
@@ -714,7 +699,7 @@ fn define_type(&self, def: Def, sp: Span, modifiers: DefModifiers) {
 
     /// Records a value definition.
     fn define_value(&self, def: Def, sp: Span, modifiers: DefModifiers) {
-        debug!("defining value for def {} with modifiers {}", def, modifiers);
+        debug!("defining value for def {:?} with modifiers {:?}", def, modifiers);
         *self.value_def.borrow_mut() = Some(ValueNsDef {
             def: def,
             value_span: Some(sp),
@@ -833,13 +818,15 @@ fn new() -> PrimitiveTypeTable {
         table.intern("char",    TyChar);
         table.intern("f32",     TyFloat(TyF32));
         table.intern("f64",     TyFloat(TyF64));
-        table.intern("int",     TyInt(TyI));
+        table.intern("int",     TyInt(TyIs));
+        table.intern("isize",   TyInt(TyIs));
         table.intern("i8",      TyInt(TyI8));
         table.intern("i16",     TyInt(TyI16));
         table.intern("i32",     TyInt(TyI32));
         table.intern("i64",     TyInt(TyI64));
         table.intern("str",     TyStr);
-        table.intern("uint",    TyUint(TyU));
+        table.intern("uint",    TyUint(TyUs));
+        table.intern("usize",   TyUint(TyUs));
         table.intern("u8",      TyUint(TyU8));
         table.intern("u16",     TyUint(TyU16));
         table.intern("u32",     TyUint(TyU32));
@@ -1071,10 +1058,10 @@ fn resolve_imports_for_module(&mut self, module: Rc<Module>) {
                     let msg = format!("unresolved import `{}`{}",
                                       self.import_path_to_string(
                                           import_directive.module_path
-                                                          [],
+                                                          .index(&FullRange),
                                           import_directive.subclass),
                                       help);
-                    self.resolve_error(span, msg[]);
+                    self.resolve_error(span, msg.index(&FullRange));
                 }
                 Indeterminate => break, // Bail out. We'll come around next time.
                 Success(()) => () // Good. Continue.
@@ -1104,7 +1091,7 @@ fn path_names_to_string(&self, path: &Path) -> String {
                                         .iter()
                                         .map(|seg| seg.identifier.name)
                                         .collect();
-        self.names_to_string(names[])
+        self.names_to_string(names.index(&FullRange))
     }
 
     fn import_directive_subclass_to_string(&mut self,
@@ -1168,7 +1155,7 @@ fn resolve_import_for_module(&mut self,
         let module_path = &import_directive.module_path;
 
         debug!("(resolving import for module) resolving import `{}::...` in `{}`",
-               self.names_to_string(module_path[]),
+               self.names_to_string(module_path.index(&FullRange)),
                self.module_to_string(&*module_));
 
         // First, resolve the module path for the directive, if necessary.
@@ -1177,7 +1164,7 @@ fn resolve_import_for_module(&mut self,
             Some((self.graph_root.get_module(), LastMod(AllPublic)))
         } else {
             match self.resolve_module_path(module_.clone(),
-                                           module_path[],
+                                           module_path.index(&FullRange),
                                            DontUseLexicalScope,
                                            import_directive.span,
                                            ImportSearch) {
@@ -1272,7 +1259,7 @@ fn resolve_single_import(&mut self,
                              lp: LastPrivate)
                                  -> ResolveResult<()> {
         debug!("(resolving single import) resolving `{}` = `{}::{}` from \
-                `{}` id {}, last private {}",
+                `{}` id {}, last private {:?}",
                token::get_name(target),
                self.module_to_string(&*containing_module),
                token::get_name(source),
@@ -1375,7 +1362,7 @@ fn get_binding(this: &mut Resolver,
                                     shadowable: _
                                 }) => {
                                     debug!("(resolving single import) found \
-                                            import in ns {}", namespace);
+                                            import in ns {:?}", namespace);
                                     let id = import_resolution.id(namespace);
                                     // track used imports and extern crates as well
                                     this.used_imports.insert((id, namespace));
@@ -1484,7 +1471,7 @@ fn get_binding(this: &mut Resolver,
 
                 match *result {
                     BoundResult(ref target_module, ref name_bindings) => {
-                        debug!("(resolving single import) found {} target: {}",
+                        debug!("(resolving single import) found {:?} target: {:?}",
                                namespace_name,
                                name_bindings.def_for_namespace(namespace));
                         self.check_for_conflicting_import(
@@ -1508,7 +1495,7 @@ fn get_binding(this: &mut Resolver,
                     }
                     UnboundResult => { /* Continue. */ }
                     UnknownResult => {
-                        panic!("{} result should be known at this point", namespace_name);
+                        panic!("{:?} result should be known at this point", namespace_name);
                     }
                 }
             };
@@ -1701,7 +1688,7 @@ fn merge_import_resolution(&mut self,
         let is_public = import_directive.is_public;
 
         let mut import_resolutions = module_.import_resolutions.borrow_mut();
-        let dest_import_resolution = import_resolutions.entry(&name).get().unwrap_or_else(
+        let dest_import_resolution = import_resolutions.entry(name).get().unwrap_or_else(
             |vacant_entry| {
                 // Create a new import resolution from this child.
                 vacant_entry.insert(ImportResolution::new(id, is_public))
@@ -1774,7 +1761,7 @@ fn check_for_conflicting_import(&mut self,
                                     ValueNS => "value",
                                   },
                                   token::get_name(name).get());
-                self.session.span_err(import_span, msg[]);
+                self.session.span_err(import_span, msg.index(&FullRange));
             }
             Some(_) | None => {}
         }
@@ -1789,7 +1776,7 @@ fn check_that_import_is_importable(&mut self,
         if !name_bindings.defined_in_namespace_with(namespace, IMPORTABLE) {
             let msg = format!("`{}` is not directly importable",
                               token::get_name(name));
-            self.session.span_err(import_span, msg[]);
+            self.session.span_err(import_span, msg.index(&FullRange));
         }
     }
 
@@ -1814,7 +1801,7 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                                        crate in this module \
                                        (maybe you meant `use {0}::*`?)",
                                       token::get_name(name).get());
-                    self.session.span_err(import_span, msg[]);
+                    self.session.span_err(import_span, msg.index(&FullRange));
                 }
                 Some(_) | None => {}
             }
@@ -1836,7 +1823,7 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                     let msg = format!("import `{}` conflicts with value \
                                        in this module",
                                       token::get_name(name).get());
-                    self.session.span_err(import_span, msg[]);
+                    self.session.span_err(import_span, msg.index(&FullRange));
                     if let Some(span) = value.value_span {
                         self.session.span_note(span,
                                                "conflicting value here");
@@ -1854,7 +1841,7 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                             let msg = format!("import `{}` conflicts with type in \
                                                this module",
                                               token::get_name(name).get());
-                            self.session.span_err(import_span, msg[]);
+                            self.session.span_err(import_span, msg.index(&FullRange));
                             if let Some(span) = ty.type_span {
                                 self.session.span_note(span,
                                                        "note conflicting type here")
@@ -1867,7 +1854,7 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                                         let msg = format!("inherent implementations \
                                                            are only allowed on types \
                                                            defined in the current module");
-                                        self.session.span_err(span, msg[]);
+                                        self.session.span_err(span, msg.index(&FullRange));
                                         self.session.span_note(import_span,
                                                                "import from other module here")
                                     }
@@ -1876,7 +1863,7 @@ fn check_for_conflicts_between_imports_and_items(&mut self,
                                     let msg = format!("import `{}` conflicts with existing \
                                                        submodule",
                                                       token::get_name(name).get());
-                                    self.session.span_err(import_span, msg[]);
+                                    self.session.span_err(import_span, msg.index(&FullRange));
                                     if let Some(span) = ty.type_span {
                                         self.session.span_note(span,
                                                                "note conflicting module here")
@@ -1906,7 +1893,7 @@ fn check_for_conflicts_between_external_crates(&self,
                 .span_err(span,
                           format!("an external crate named `{}` has already \
                                    been imported into this module",
-                                  token::get_name(name).get())[]);
+                                  token::get_name(name).get()).index(&FullRange));
         }
     }
 
@@ -1925,7 +1912,7 @@ fn check_for_conflicts_between_external_crates_and_items(&self,
                           format!("the name `{}` conflicts with an external \
                                    crate that has been imported into this \
                                    module",
-                                  token::get_name(name).get())[]);
+                                  token::get_name(name).get()).index(&FullRange));
         }
     }
 
@@ -1973,7 +1960,7 @@ fn search_parent_externals(needle: Name, module: &Rc<Module>)
                     let segment_name = token::get_name(name);
                     let module_name = self.module_to_string(&*search_module);
                     let mut span = span;
-                    let msg = if "???" == module_name[] {
+                    let msg = if "???" == module_name.index(&FullRange) {
                         span.hi = span.lo + Pos::from_uint(segment_name.get().len());
 
                         match search_parent_externals(name,
@@ -2086,14 +2073,14 @@ fn resolve_module_path(&mut self,
         match module_prefix_result {
             Failed(None) => {
                 let mpath = self.names_to_string(module_path);
-                let mpath = mpath[];
+                let mpath = mpath.index(&FullRange);
                 match mpath.rfind(':') {
                     Some(idx) => {
                         let msg = format!("Could not find `{}` in `{}`",
                                             // idx +- 1 to account for the
                                             // colons on either side
-                                            mpath[idx + 1..],
-                                            mpath[0..idx - 1]);
+                                            mpath.index(&((idx + 1)..)),
+                                            mpath.index(&(0..(idx - 1))));
                         return Failed(Some((span, msg)));
                     },
                     None => {
@@ -2165,7 +2152,7 @@ fn resolve_item_in_lexical_scope(&mut self,
                                      namespace: Namespace)
                                     -> ResolveResult<(Target, bool)> {
         debug!("(resolving item in lexical scope) resolving `{}` in \
-                namespace {} in `{}`",
+                namespace {:?} in `{}`",
                token::get_name(name),
                namespace,
                self.module_to_string(&*module_));
@@ -2195,7 +2182,7 @@ fn resolve_item_in_lexical_scope(&mut self,
                 None => {
                     // Not found; continue.
                     debug!("(resolving item in lexical scope) found \
-                            import resolution, but not in namespace {}",
+                            import resolution, but not in namespace {:?}",
                            namespace);
                 }
                 Some(target) => {
@@ -2268,7 +2255,7 @@ fn resolve_item_in_lexical_scope(&mut self,
                                               true) {
                 Failed(Some((span, msg))) =>
                     self.resolve_error(span, format!("failed to resolve. {}",
-                                                     msg)[]),
+                                                     msg).index(&FullRange)),
                 Failed(None) => (), // Continue up the search chain.
                 Indeterminate => {
                     // We couldn't see through the higher scope because of an
@@ -2475,7 +2462,7 @@ fn resolve_name_in_module(&mut self,
                 match import_resolution.target_for_namespace(namespace) {
                     None => {
                         debug!("(resolving name in module) name found, \
-                                but not in namespace {}",
+                                but not in namespace {:?}",
                                namespace);
                     }
                     Some(target) => {
@@ -2528,7 +2515,7 @@ fn report_unresolved_imports(&mut self, module_: Rc<Module>) {
             } else {
                 let err = format!("unresolved import (maybe you meant `{}::*`?)",
                                   sn);
-                self.resolve_error((*imports)[index].span, err[]);
+                self.resolve_error((*imports)[index].span, err.index(&FullRange));
             }
         }
 
@@ -2620,7 +2607,7 @@ fn upvarify(&self,
         match def_like {
             DlDef(d @ DefUpvar(..)) => {
                 self.session.span_bug(span,
-                    format!("unexpected {} in bindings", d)[])
+                    format!("unexpected {:?} in bindings", d).index(&FullRange))
             }
             DlDef(d @ DefLocal(_)) => {
                 let node_id = d.def_id().node;
@@ -2639,14 +2626,14 @@ fn upvarify(&self,
                             def = DefUpvar(node_id, function_id, last_proc_body_id);
 
                             let mut seen = self.freevars_seen.borrow_mut();
-                            let seen = match seen.entry(&function_id) {
+                            let seen = match seen.entry(function_id) {
                                 Occupied(v) => v.into_mut(),
                                 Vacant(v) => v.insert(NodeSet::new()),
                             };
                             if seen.contains(&node_id) {
                                 continue;
                             }
-                            match self.freevars.borrow_mut().entry(&function_id) {
+                            match self.freevars.borrow_mut().entry(function_id) {
                                 Occupied(v) => v.into_mut(),
                                 Vacant(v) => v.insert(vec![]),
                             }.push(Freevar { def: prev_def, span: span });
@@ -2766,7 +2753,7 @@ fn search_ribs(&self,
         for (i, rib) in ribs.iter().enumerate().rev() {
             match rib.bindings.get(&name).cloned() {
                 Some(def_like) => {
-                    return self.upvarify(ribs[i + 1..], def_like, span);
+                    return self.upvarify(ribs.index(&((i + 1)..)), def_like, span);
                 }
                 None => {
                     // Continue.
@@ -2859,7 +2846,7 @@ fn resolve_item(&mut self, item: &Item) {
                                             generics,
                                             implemented_traits,
                                             &**self_type,
-                                            impl_items[]);
+                                            impl_items.index(&FullRange));
             }
 
             ItemTrait(_, ref generics, ref bounds, ref trait_items) => {
@@ -2937,7 +2924,7 @@ fn resolve_item(&mut self, item: &Item) {
             ItemStruct(ref struct_def, ref generics) => {
                 self.resolve_struct(item.id,
                                     generics,
-                                    struct_def.fields[]);
+                                    struct_def.fields.index(&FullRange));
             }
 
             ItemMod(ref module_) => {
@@ -3010,7 +2997,7 @@ fn with_type_parameter_rib<F>(&mut self, type_parameters: TypeParameters, f: F)
                                                     parameter in this type \
                                                     parameter list",
                                                    token::get_name(
-                                                       name))[])
+                                                       name)).index(&FullRange))
                     }
                     seen_bindings.insert(name);
 
@@ -3182,26 +3169,26 @@ fn resolve_trait_reference(&mut self,
                 };
 
                 let msg = format!("attempt to {} a nonexistent trait `{}`", usage_str, path_str);
-                self.resolve_error(trait_reference.path.span, msg[]);
+                self.resolve_error(trait_reference.path.span, msg.index(&FullRange));
             }
             Some(def) => {
                 match def {
                     (DefTrait(_), _) => {
-                        debug!("(resolving trait) found trait def: {}", def);
+                        debug!("(resolving trait) found trait def: {:?}", def);
                         self.record_def(trait_reference.ref_id, def);
                     }
                     (def, _) => {
                         self.resolve_error(trait_reference.path.span,
                                            format!("`{}` is not a trait",
                                                    self.path_names_to_string(
-                                                       &trait_reference.path))[]);
+                                                       &trait_reference.path)).index(&FullRange));
 
                         // If it's a typedef, give a note
                         if let DefTy(..) = def {
                             self.session.span_note(
                                 trait_reference.path.span,
                                 format!("`type` aliases cannot be used for traits")
-                                    []);
+                                    .index(&FullRange));
                         }
                     }
                 }
@@ -3398,7 +3385,7 @@ fn check_trait_item(&self, name: Name, span: Span) {
                 self.resolve_error(span,
                                     format!("method `{}` is not a member of trait `{}`",
                                             token::get_name(name),
-                                            path_str)[]);
+                                            path_str).index(&FullRange));
             }
         }
     }
@@ -3467,7 +3454,7 @@ fn check_consistent_bindings(&mut self, arm: &Arm) {
                         format!("variable `{}` from pattern #1 is \
                                   not bound in pattern #{}",
                                 token::get_name(key),
-                                i + 1)[]);
+                                i + 1).index(&FullRange));
                   }
                   Some(binding_i) => {
                     if binding_0.binding_mode != binding_i.binding_mode {
@@ -3476,7 +3463,7 @@ fn check_consistent_bindings(&mut self, arm: &Arm) {
                             format!("variable `{}` is bound with different \
                                       mode in pattern #{} than in pattern #1",
                                     token::get_name(key),
-                                    i + 1)[]);
+                                    i + 1).index(&FullRange));
                     }
                   }
                 }
@@ -3489,7 +3476,7 @@ fn check_consistent_bindings(&mut self, arm: &Arm) {
                         format!("variable `{}` from pattern {}{} is \
                                   not bound in pattern {}1",
                                 token::get_name(key),
-                                "#", i + 1, "#")[]);
+                                "#", i + 1, "#").index(&FullRange));
                 }
             }
         }
@@ -3578,8 +3565,8 @@ fn resolve_type(&mut self, ty: &Ty) {
                     None => {
                         match self.resolve_path(ty.id, path, TypeNS, true) {
                             Some(def) => {
-                                debug!("(resolving type) resolved `{}` to \
-                                        type {}",
+                                debug!("(resolving type) resolved `{:?}` to \
+                                        type {:?}",
                                        token::get_ident(path.segments.last().unwrap() .identifier),
                                        def);
                                 result_def = Some(def);
@@ -3604,7 +3591,7 @@ fn resolve_type(&mut self, ty: &Ty) {
                     None => {
                         let msg = format!("use of undeclared type name `{}`",
                                           self.path_names_to_string(path));
-                        self.resolve_error(ty.span, msg[]);
+                        self.resolve_error(ty.span, msg.index(&FullRange));
                     }
                 }
             }
@@ -3676,7 +3663,7 @@ struct or enum variant",
                                 format!("declaration of `{}` shadows an enum \
                                          variant or unit-like struct in \
                                          scope",
-                                        token::get_name(renamed))[]);
+                                        token::get_name(renamed)).index(&FullRange));
                         }
                         FoundConst(ref def, lp) if mode == RefutableMode => {
                             debug!("(resolving pattern) resolving `{}` to \
@@ -3728,7 +3715,7 @@ struct or enum variant",
                                                             list",
                                                            token::get_ident(
                                                                ident))
-                                                   [])
+                                                   .index(&FullRange))
                             } else if bindings_list.get(&renamed) ==
                                     Some(&pat_id) {
                                 // Then this is a duplicate variable in the
@@ -3737,7 +3724,7 @@ struct or enum variant",
                                     format!("identifier `{}` is bound \
                                              more than once in the same \
                                              pattern",
-                                            token::get_ident(ident))[]);
+                                            token::get_ident(ident)).index(&FullRange));
                             }
                             // Else, not bound in the same pattern: do
                             // nothing.
@@ -3763,13 +3750,13 @@ struct or enum variant",
                             self.resolve_error(path.span,
                                 format!("`{}` is not an enum variant, struct or const",
                                     token::get_ident(
-                                        path.segments.last().unwrap().identifier))[]);
+                                        path.segments.last().unwrap().identifier)).as_slice());
                         }
                         None => {
                             self.resolve_error(path.span,
                                 format!("unresolved enum variant, struct or const `{}`",
                                     token::get_ident(
-                                        path.segments.last().unwrap().identifier))[]);
+                                        path.segments.last().unwrap().identifier)).as_slice());
                         }
                     }
 
@@ -3797,10 +3784,10 @@ struct or enum variant",
                         }
                         result => {
                             debug!("(resolving pattern) didn't find struct \
-                                    def: {}", result);
+                                    def: {:?}", result);
                             let msg = format!("`{}` does not name a structure",
                                               self.path_names_to_string(path));
-                            self.resolve_error(path.span, msg[]);
+                            self.resolve_error(path.span, msg.index(&FullRange));
                         }
                     }
                 }
@@ -3821,7 +3808,7 @@ fn resolve_bare_identifier_pattern(&mut self, name: Name, span: Span)
                                                  ValueNS) {
             Success((target, _)) => {
                 debug!("(resolve bare identifier pattern) succeeded in \
-                         finding {} at {}",
+                         finding {} at {:?}",
                         token::get_name(name),
                         target.bindings.value_def.borrow());
                 match *target.bindings.value_def.borrow() {
@@ -3862,7 +3849,7 @@ fn resolve_bare_identifier_pattern(&mut self, name: Name, span: Span)
                 match err {
                     Some((span, msg)) => {
                         self.resolve_error(span, format!("failed to resolve: {}",
-                                                         msg)[]);
+                                                         msg).index(&FullRange));
                     }
                     None => ()
                 }
@@ -4057,7 +4044,7 @@ fn resolve_module_relative_path(&mut self,
         let last_private;
         let module = self.current_module.clone();
         match self.resolve_module_path(module,
-                                       module_path[],
+                                       module_path.index(&FullRange),
                                        UseLexicalScope,
                                        path.span,
                                        PathSearch) {
@@ -4072,7 +4059,7 @@ fn resolve_module_relative_path(&mut self,
                 };
 
                 self.resolve_error(span, format!("failed to resolve. {}",
-                                                 msg)[]);
+                                                 msg).index(&FullRange));
                 return None;
             }
             Indeterminate => panic!("indeterminate unexpected"),
@@ -4115,7 +4102,7 @@ fn resolve_crate_relative_path(&mut self,
         let containing_module;
         let last_private;
         match self.resolve_module_path_from_root(root_module,
-                                                 module_path[],
+                                                 module_path.index(&FullRange),
                                                  0,
                                                  path.span,
                                                  PathSearch,
@@ -4125,13 +4112,13 @@ fn resolve_crate_relative_path(&mut self,
                     Some((span, msg)) => (span, msg),
                     None => {
                         let msg = format!("Use of undeclared module `::{}`",
-                                          self.names_to_string(module_path[]));
+                                          self.names_to_string(module_path.index(&FullRange)));
                         (path.span, msg)
                     }
                 };
 
                 self.resolve_error(span, format!("failed to resolve. {}",
-                                                 msg)[]);
+                                                 msg).index(&FullRange));
                 return None;
             }
 
@@ -4172,14 +4159,14 @@ fn resolve_identifier_in_local_ribs(&mut self,
             }
             TypeNS => {
                 let name = ident.name;
-                self.search_ribs(self.type_ribs[], name, span)
+                self.search_ribs(self.type_ribs.index(&FullRange), name, span)
             }
         };
 
         match search_result {
             Some(DlDef(def)) => {
                 debug!("(resolving path in local ribs) resolved `{}` to \
-                        local: {}",
+                        local: {:?}",
                        token::get_ident(ident),
                        def);
                 return Some(def);
@@ -4227,7 +4214,7 @@ fn resolve_item_by_name_in_lexical_scope(&mut self,
                 match err {
                     Some((span, msg)) =>
                         self.resolve_error(span, format!("failed to resolve. {}",
-                                                         msg)[]),
+                                                         msg).index(&FullRange)),
                     None => ()
                 }
 
@@ -4284,7 +4271,7 @@ fn get_module(this: &mut Resolver, span: Span, name_path: &[ast::Name])
                 }
             } else {
                 match this.resolve_module_path(root,
-                                                name_path[],
+                                                name_path.index(&FullRange),
                                                 UseLexicalScope,
                                                 span,
                                                 PathSearch) {
@@ -4322,7 +4309,7 @@ fn get_module(this: &mut Resolver, span: Span, name_path: &[ast::Name])
         let name_path = path.segments.iter().map(|seg| seg.identifier.name).collect::<Vec<_>>();
 
         // Look for a method in the current self type's impl module.
-        match get_module(self, path.span, name_path[]) {
+        match get_module(self, path.span, name_path.index(&FullRange)) {
             Some(module) => match module.children.borrow().get(&name) {
                 Some(binding) => {
                     let p_str = self.path_names_to_string(&path);
@@ -4530,10 +4517,10 @@ fn resolve_expr(&mut self, expr: &Expr) {
                     Some(definition) => self.record_def(expr.id, definition),
                     result => {
                         debug!("(resolving expression) didn't find struct \
-                                def: {}", result);
+                                def: {:?}", result);
                         let msg = format!("`{}` does not name a structure",
                                           self.path_names_to_string(path));
-                        self.resolve_error(path.span, msg[]);
+                        self.resolve_error(path.span, msg.index(&FullRange));
                     }
                 }
 
@@ -4594,7 +4581,7 @@ fn resolve_expr(&mut self, expr: &Expr) {
                         self.resolve_error(
                             expr.span,
                             format!("use of undeclared label `{}`",
-                                    token::get_ident(label))[])
+                                    token::get_ident(label)).index(&FullRange))
                     }
                     Some(DlDef(def @ DefLabel(_))) => {
                         // Since this def is a label, it is never read.
@@ -4717,23 +4704,23 @@ fn add_trait_info(found_traits: &mut Vec<DefId>,
     }
 
     fn record_def(&mut self, node_id: NodeId, (def, lp): (Def, LastPrivate)) {
-        debug!("(recording def) recording {} for {}, last private {}",
+        debug!("(recording def) recording {:?} for {}, last private {:?}",
                 def, node_id, lp);
         assert!(match lp {LastImport{..} => false, _ => true},
                 "Import should only be used for `use` directives");
         self.last_private.insert(node_id, lp);
 
-        match self.def_map.borrow_mut().entry(&node_id) {
+        match self.def_map.borrow_mut().entry(node_id) {
             // Resolve appears to "resolve" the same ID multiple
             // times, so here is a sanity check it at least comes to
             // the same conclusion! - nmatsakis
             Occupied(entry) => if def != *entry.get() {
                 self.session
-                    .bug(format!("node_id {} resolved first to {} and \
-                                  then {}",
+                    .bug(format!("node_id {} resolved first to {:?} and \
+                                  then {:?}",
                                  node_id,
                                  *entry.get(),
-                                 def)[]);
+                                 def).index(&FullRange));
             },
             Vacant(entry) => { entry.insert(def); },
         }
@@ -4749,7 +4736,7 @@ fn enforce_default_binding_mode(&mut self,
                 self.resolve_error(pat.span,
                                    format!("cannot use `ref` binding mode \
                                             with {}",
-                                           descr)[]);
+                                           descr).index(&FullRange));
             }
         }
     }
@@ -4785,7 +4772,7 @@ fn collect_mod(names: &mut Vec<ast::Name>, module: &Module) {
             return "???".to_string();
         }
         self.names_to_string(names.into_iter().rev()
-                                  .collect::<Vec<ast::Name>>()[])
+                                  .collect::<Vec<ast::Name>>().index(&FullRange))
     }
 
     #[allow(dead_code)]   // useful for debugging
index 84fd3c936719b7a94eeddd572d54a19516981631..67bcf152eb78cfa5d20d71d413f79dabfad1d766 100644 (file)
@@ -117,7 +117,7 @@ fn add_exports_of_namebindings(&mut self,
                                    ns: Namespace) {
         match namebindings.def_for_namespace(ns) {
             Some(d) => {
-                debug!("(computing exports) YES: export '{}' => {}",
+                debug!("(computing exports) YES: export '{}' => {:?}",
                        name, d.def_id());
                 exports.push(Export {
                     name: name,
@@ -125,7 +125,7 @@ fn add_exports_of_namebindings(&mut self,
                 });
             }
             d_opt => {
-                debug!("(computing exports) NO: {}", d_opt);
+                debug!("(computing exports) NO: {:?}", d_opt);
             }
         }
     }
index 8fbeadc55b38751cb58cf4de42319cf466de8c1b..26241ace76f4889e28b18338465e94034eef80a3 100644 (file)
@@ -128,7 +128,7 @@ pub fn find_crate_name(sess: Option<&Session>,
                        attrs: &[ast::Attribute],
                        input: &Input) -> String {
     let validate = |&: s: String, span: Option<Span>| {
-        creader::validate_crate_name(sess, s[], span);
+        creader::validate_crate_name(sess, s.index(&FullRange), span);
         s
     };
 
@@ -146,7 +146,7 @@ pub fn find_crate_name(sess: Option<&Session>,
                     let msg = format!("--crate-name and #[crate_name] are \
                                        required to match, but `{}` != `{}`",
                                       s, name);
-                    sess.span_err(attr.span, msg[]);
+                    sess.span_err(attr.span, msg.index(&FullRange));
                 }
             }
             return validate(s.clone(), None);
@@ -171,7 +171,7 @@ pub fn build_link_meta(sess: &Session, krate: &ast::Crate,
         crate_name: name,
         crate_hash: Svh::calculate(&sess.opts.cg.metadata, krate),
     };
-    info!("{}", r);
+    info!("{:?}", r);
     return r;
 }
 
@@ -192,17 +192,17 @@ fn symbol_hash<'tcx>(tcx: &ty::ctxt<'tcx>,
     // to be independent of one another in the crate.
 
     symbol_hasher.reset();
-    symbol_hasher.input_str(link_meta.crate_name[]);
+    symbol_hasher.input_str(link_meta.crate_name.index(&FullRange));
     symbol_hasher.input_str("-");
     symbol_hasher.input_str(link_meta.crate_hash.as_str());
     for meta in tcx.sess.crate_metadata.borrow().iter() {
-        symbol_hasher.input_str(meta[]);
+        symbol_hasher.input_str(meta.index(&FullRange));
     }
     symbol_hasher.input_str("-");
-    symbol_hasher.input_str(encoder::encoded_ty(tcx, t)[]);
+    symbol_hasher.input_str(encoder::encoded_ty(tcx, t).index(&FullRange));
     // Prefix with 'h' so that it never blends into adjacent digits
     let mut hash = String::from_str("h");
-    hash.push_str(truncated_hash_result(symbol_hasher)[]);
+    hash.push_str(truncated_hash_result(symbol_hasher).index(&FullRange));
     hash
 }
 
@@ -251,7 +251,7 @@ pub fn sanitize(s: &str) -> String {
                 let mut tstr = String::new();
                 for c in c.escape_unicode() { tstr.push(c) }
                 result.push('$');
-                result.push_str(tstr[1..]);
+                result.push_str(tstr.index(&(1..)));
             }
         }
     }
@@ -260,7 +260,7 @@ pub fn sanitize(s: &str) -> String {
     if result.len() > 0u &&
         result.as_bytes()[0] != '_' as u8 &&
         ! (result.as_bytes()[0] as char).is_xid_start() {
-        return format!("_{}", result[]);
+        return format!("_{}", result.index(&FullRange));
     }
 
     return result;
@@ -286,12 +286,12 @@ pub fn mangle<PI: Iterator<Item=PathElem>>(mut path: PI,
 
     fn push(n: &mut String, s: &str) {
         let sani = sanitize(s);
-        n.push_str(format!("{}{}", sani.len(), sani)[]);
+        n.push_str(format!("{}{}", sani.len(), sani).index(&FullRange));
     }
 
     // First, connect each component with <len, name> pairs.
     for e in path {
-        push(&mut n, token::get_name(e.name()).get()[])
+        push(&mut n, token::get_name(e.name()).get().index(&FullRange))
     }
 
     match hash {
@@ -329,17 +329,17 @@ pub fn mangle_exported_name<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, path: PathEl
     hash.push(EXTRA_CHARS.as_bytes()[extra2] as char);
     hash.push(EXTRA_CHARS.as_bytes()[extra3] as char);
 
-    exported_name(path, hash[])
+    exported_name(path, hash.index(&FullRange))
 }
 
 pub fn mangle_internal_name_by_type_and_seq<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                                       t: Ty<'tcx>,
                                                       name: &str) -> String {
     let s = ppaux::ty_to_string(ccx.tcx(), t);
-    let path = [PathName(token::intern(s[])),
+    let path = [PathName(token::intern(s.index(&FullRange))),
                 gensym_name(name)];
     let hash = get_symbol_hash(ccx, t);
-    mangle(ast_map::Values(path.iter()), Some(hash[]))
+    mangle(ast_map::Values(path.iter()), Some(hash.index(&FullRange)))
 }
 
 pub fn mangle_internal_name_by_path_and_seq(path: PathElems, flav: &str) -> String {
@@ -359,7 +359,7 @@ pub fn remove(sess: &Session, path: &Path) {
         Err(e) => {
             sess.err(format!("failed to remove {}: {}",
                              path.display(),
-                             e)[]);
+                             e).index(&FullRange));
         }
     }
 }
@@ -373,8 +373,8 @@ pub fn link_binary(sess: &Session,
     let mut out_filenames = Vec::new();
     for &crate_type in sess.crate_types.borrow().iter() {
         if invalid_output_for_target(sess, crate_type) {
-            sess.bug(format!("invalid output type `{}` for target os `{}`",
-                             crate_type, sess.opts.target_triple)[]);
+            sess.bug(format!("invalid output type `{:?}` for target os `{}`",
+                             crate_type, sess.opts.target_triple).index(&FullRange));
         }
         let out_file = link_binary_output(sess, trans, crate_type, outputs,
                                           crate_name);
@@ -439,8 +439,8 @@ pub fn filename_for_input(sess: &Session,
             out_filename.with_filename(format!("lib{}.rlib", libname))
         }
         config::CrateTypeDylib => {
-            let (prefix, suffix) = (sess.target.target.options.dll_prefix[],
-                                    sess.target.target.options.dll_suffix[]);
+            let (prefix, suffix) = (sess.target.target.options.dll_prefix.index(&FullRange),
+                                    sess.target.target.options.dll_suffix.index(&FullRange));
             out_filename.with_filename(format!("{}{}{}",
                                                prefix,
                                                libname,
@@ -450,7 +450,7 @@ pub fn filename_for_input(sess: &Session,
             out_filename.with_filename(format!("lib{}.a", libname))
         }
         config::CrateTypeExecutable => {
-            let suffix = sess.target.target.options.exe_suffix[];
+            let suffix = sess.target.target.options.exe_suffix.index(&FullRange);
             out_filename.with_filename(format!("{}{}", libname, suffix))
         }
     }
@@ -479,12 +479,12 @@ fn link_binary_output(sess: &Session,
     if !out_is_writeable {
         sess.fatal(format!("output file {} is not writeable -- check its \
                             permissions.",
-                           out_filename.display())[]);
+                           out_filename.display()).index(&FullRange));
     }
     else if !obj_is_writeable {
         sess.fatal(format!("object file {} is not writeable -- check its \
                             permissions.",
-                           obj_filename.display())[]);
+                           obj_filename.display()).index(&FullRange));
     }
 
     match crate_type {
@@ -539,7 +539,7 @@ fn link_rlib<'a>(sess: &'a Session,
     for &(ref l, kind) in sess.cstore.get_used_libraries().borrow().iter() {
         match kind {
             cstore::NativeStatic => {
-                ab.add_native_library(l[]).unwrap();
+                ab.add_native_library(l.index(&FullRange)).unwrap();
             }
             cstore::NativeFramework | cstore::NativeUnknown => {}
         }
@@ -587,12 +587,12 @@ fn link_rlib<'a>(sess: &'a Session,
             let tmpdir = TempDir::new("rustc").ok().expect("needs a temp dir");
             let metadata = tmpdir.path().join(METADATA_FILENAME);
             match fs::File::create(&metadata).write(trans.metadata
-                                                         []) {
+                                                         .index(&FullRange)) {
                 Ok(..) => {}
                 Err(e) => {
                     sess.err(format!("failed to write {}: {}",
                                      metadata.display(),
-                                     e)[]);
+                                     e).index(&FullRange));
                     sess.abort_if_errors();
                 }
             }
@@ -608,27 +608,27 @@ 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)[]);
+                let bc_filename = obj_filename.with_extension(format!("{}.bc", i).as_slice());
                 let bc_deflated_filename = obj_filename.with_extension(
-                    format!("{}.bytecode.deflate", i)[]);
+                    format!("{}.bytecode.deflate", i).index(&FullRange));
 
                 let bc_data = match fs::File::open(&bc_filename).read_to_end() {
                     Ok(buffer) => buffer,
                     Err(e) => sess.fatal(format!("failed to read bytecode: {}",
-                                                 e)[])
+                                                 e).index(&FullRange))
                 };
 
-                let bc_data_deflated = match flate::deflate_bytes(bc_data[]) {
+                let bc_data_deflated = match flate::deflate_bytes(bc_data.index(&FullRange)) {
                     Some(compressed) => compressed,
                     None => sess.fatal(format!("failed to compress bytecode from {}",
-                                               bc_filename.display())[])
+                                               bc_filename.display()).index(&FullRange))
                 };
 
                 let mut bc_file_deflated = match fs::File::create(&bc_deflated_filename) {
                     Ok(file) => file,
                     Err(e) => {
                         sess.fatal(format!("failed to create compressed bytecode \
-                                            file: {}", e)[])
+                                            file: {}", e).index(&FullRange))
                     }
                 };
 
@@ -637,7 +637,7 @@ fn link_rlib<'a>(sess: &'a Session,
                     Ok(()) => {}
                     Err(e) => {
                         sess.err(format!("failed to write compressed bytecode: \
-                                          {}", e)[]);
+                                          {}", e).index(&FullRange));
                         sess.abort_if_errors()
                     }
                 };
@@ -677,7 +677,7 @@ fn write_rlib_bytecode_object_v1<T: Writer>(writer: &mut T,
     try! { writer.write(RLIB_BYTECODE_OBJECT_MAGIC) };
     try! { writer.write_le_u32(1) };
     try! { writer.write_le_u64(bc_data_deflated_size) };
-    try! { writer.write(bc_data_deflated[]) };
+    try! { writer.write(bc_data_deflated.index(&FullRange)) };
 
     let number_of_bytes_written_so_far =
         RLIB_BYTECODE_OBJECT_MAGIC.len() +                // magic id
@@ -728,11 +728,11 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
         let p = match *path {
             Some(ref p) => p.clone(), None => {
                 sess.err(format!("could not find rlib for: `{}`",
-                                 name)[]);
+                                 name).index(&FullRange));
                 continue
             }
         };
-        ab.add_rlib(&p, name[], sess.lto()).unwrap();
+        ab.add_rlib(&p, name.index(&FullRange), sess.lto()).unwrap();
 
         let native_libs = csearch::get_native_libraries(&sess.cstore, cnum);
         all_native_libs.extend(native_libs.into_iter());
@@ -754,7 +754,7 @@ fn link_staticlib(sess: &Session, obj_filename: &Path, out_filename: &Path) {
             cstore::NativeUnknown => "library",
             cstore::NativeFramework => "framework",
         };
-        sess.note(format!("{}: {}", name, *lib)[]);
+        sess.note(format!("{}: {}", name, *lib).index(&FullRange));
     }
 }
 
@@ -768,12 +768,12 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
 
     // The invocations of cc share some flags across platforms
     let pname = get_cc_prog(sess);
-    let mut cmd = Command::new(pname[]);
+    let mut cmd = Command::new(pname.index(&FullRange));
 
-    cmd.args(sess.target.target.options.pre_link_args[]);
+    cmd.args(sess.target.target.options.pre_link_args.index(&FullRange));
     link_args(&mut cmd, sess, dylib, tmpdir.path(),
               trans, obj_filename, out_filename);
-    cmd.args(sess.target.target.options.post_link_args[]);
+    cmd.args(sess.target.target.options.post_link_args.index(&FullRange));
     if !sess.target.target.options.no_compiler_rt {
         cmd.arg("-lcompiler-rt");
     }
@@ -793,11 +793,11 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
             if !prog.status.success() {
                 sess.err(format!("linking with `{}` failed: {}",
                                  pname,
-                                 prog.status)[]);
-                sess.note(format!("{}", &cmd)[]);
+                                 prog.status).index(&FullRange));
+                sess.note(format!("{}", &cmd).index(&FullRange));
                 let mut output = prog.error.clone();
-                output.push_all(prog.output[]);
-                sess.note(str::from_utf8(output[]).unwrap());
+                output.push_all(prog.output.index(&FullRange));
+                sess.note(str::from_utf8(output.index(&FullRange)).unwrap());
                 sess.abort_if_errors();
             }
             debug!("linker stderr:\n{}", String::from_utf8(prog.error).unwrap());
@@ -806,7 +806,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
         Err(e) => {
             sess.err(format!("could not exec the linker `{}`: {}",
                              pname,
-                             e)[]);
+                             e).index(&FullRange));
             sess.abort_if_errors();
         }
     }
@@ -818,7 +818,7 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool,
         match Command::new("dsymutil").arg(out_filename).output() {
             Ok(..) => {}
             Err(e) => {
-                sess.err(format!("failed to run dsymutil: {}", e)[]);
+                sess.err(format!("failed to run dsymutil: {}", e).index(&FullRange));
                 sess.abort_if_errors();
             }
         }
@@ -867,7 +867,7 @@ fn link_args(cmd: &mut Command,
 
             let mut v = b"-Wl,-force_load,".to_vec();
             v.push_all(morestack.as_vec());
-            cmd.arg(v[]);
+            cmd.arg(v.index(&FullRange));
         } else {
             cmd.args(&["-Wl,--whole-archive", "-lmorestack", "-Wl,--no-whole-archive"]);
         }
@@ -992,7 +992,7 @@ fn link_args(cmd: &mut Command,
             if sess.opts.cg.rpath {
                 let mut v = "-Wl,-install_name,@rpath/".as_bytes().to_vec();
                 v.push_all(out_filename.filename().unwrap());
-                cmd.arg(v[]);
+                cmd.arg(v.index(&FullRange));
             }
         } else {
             cmd.arg("-shared");
@@ -1004,7 +1004,7 @@ fn link_args(cmd: &mut Command,
     // addl_lib_search_paths
     if sess.opts.cg.rpath {
         let sysroot = sess.sysroot();
-        let target_triple = sess.opts.target_triple[];
+        let target_triple = sess.opts.target_triple.index(&FullRange);
         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);
@@ -1021,14 +1021,14 @@ fn link_args(cmd: &mut Command,
             get_install_prefix_lib_path: get_install_prefix_lib_path,
             realpath: ::util::fs::realpath
         };
-        cmd.args(rpath::get_rpath_flags(rpath_config)[]);
+        cmd.args(rpath::get_rpath_flags(rpath_config).index(&FullRange));
     }
 
     // Finally add all the linker arguments provided on the command line along
     // with any #[link_args] attributes found inside the crate
     let empty = Vec::new();
-    cmd.args(sess.opts.cg.link_args.as_ref().unwrap_or(&empty)[]);
-    cmd.args(used_link_args[]);
+    cmd.args(sess.opts.cg.link_args.as_ref().unwrap_or(&empty).index(&FullRange));
+    cmd.args(used_link_args.index(&FullRange));
 }
 
 // # Native library linking
@@ -1082,14 +1082,14 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
         } else {
             // -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[],
-                                            sess.target.target.options.staticlib_suffix[],
-                                            search_path[],
+            let lib = archive::find_library(l.index(&FullRange),
+                                            sess.target.target.options.staticlib_prefix.as_slice(),
+                                            sess.target.target.options.staticlib_suffix.as_slice(),
+                                            search_path.index(&FullRange),
                                             &sess.diagnostic().handler);
             let mut v = b"-Wl,-force_load,".to_vec();
             v.push_all(lib.as_vec());
-            cmd.arg(v[]);
+            cmd.arg(v.index(&FullRange));
         }
     }
     if takes_hints {
@@ -1102,7 +1102,7 @@ fn add_local_native_libraries(cmd: &mut Command, sess: &Session) {
                 cmd.arg(format!("-l{}", l));
             }
             cstore::NativeFramework => {
-                cmd.arg("-framework").arg(l[]);
+                cmd.arg("-framework").arg(l.index(&FullRange));
             }
             cstore::NativeStatic => unreachable!(),
         }
@@ -1158,7 +1158,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session,
     // Converts a library file-stem into a cc -l argument
     fn unlib<'a>(config: &config::Config, stem: &'a [u8]) -> &'a [u8] {
         if stem.starts_with("lib".as_bytes()) && !config.target.options.is_like_windows {
-            stem[3..]
+            stem.index(&(3..))
         } else {
             stem
         }
@@ -1183,9 +1183,9 @@ fn add_static_crate(cmd: &mut Command, sess: &Session, tmpdir: &Path,
         // against the archive.
         if sess.lto() {
             let name = cratepath.filename_str().unwrap();
-            let name = name[3..name.len() - 5]; // chop off lib/.rlib
+            let name = name.index(&(3..(name.len() - 5))); // chop off lib/.rlib
             time(sess.time_passes(),
-                 format!("altering {}.rlib", name)[],
+                 format!("altering {}.rlib", name).index(&FullRange),
                  (), |()| {
                 let dst = tmpdir.join(cratepath.filename().unwrap());
                 match fs::copy(&cratepath, &dst) {
@@ -1194,7 +1194,7 @@ fn add_static_crate(cmd: &mut Command, sess: &Session, tmpdir: &Path,
                         sess.err(format!("failed to copy {} to {}: {}",
                                          cratepath.display(),
                                          dst.display(),
-                                         e)[]);
+                                         e).index(&FullRange));
                         sess.abort_if_errors();
                     }
                 }
@@ -1206,7 +1206,7 @@ fn add_static_crate(cmd: &mut Command, sess: &Session, tmpdir: &Path,
                     Err(e) => {
                         sess.err(format!("failed to chmod {} when preparing \
                                           for LTO: {}", dst.display(),
-                                         e)[]);
+                                         e).index(&FullRange));
                         sess.abort_if_errors();
                     }
                 }
@@ -1220,9 +1220,9 @@ fn add_static_crate(cmd: &mut Command, sess: &Session, tmpdir: &Path,
                     maybe_ar_prog: sess.opts.cg.ar.clone()
                 };
                 let mut archive = Archive::open(config);
-                archive.remove_file(format!("{}.o", name)[]);
+                archive.remove_file(format!("{}.o", name).index(&FullRange));
                 let files = archive.files();
-                if files.iter().any(|s| s[].ends_with(".o")) {
+                if files.iter().any(|s| s.index(&FullRange).ends_with(".o")) {
                     cmd.arg(dst);
                 }
             });
@@ -1244,7 +1244,7 @@ fn add_dynamic_crate(cmd: &mut Command, sess: &Session, cratepath: Path) {
 
         let mut v = "-l".as_bytes().to_vec();
         v.push_all(unlib(&sess.target, cratepath.filestem().unwrap()));
-        cmd.arg(v[]);
+        cmd.arg(v.index(&FullRange));
     }
 }
 
@@ -1286,7 +1286,7 @@ fn add_upstream_native_libraries(cmd: &mut Command, sess: &Session) {
                 }
                 cstore::NativeFramework => {
                     cmd.arg("-framework");
-                    cmd.arg(lib[]);
+                    cmd.arg(lib.index(&FullRange));
                 }
                 cstore::NativeStatic => {
                     sess.bug("statics shouldn't be propagated");
index f3e90c43a8414961bcdb979fb15f9dbada402d85..ecf2e9ed7242557360ad7b3d6c8c465b28e90dc5 100644 (file)
@@ -54,21 +54,21 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
             Some(p) => p,
             None => {
                 sess.fatal(format!("could not find rlib for: `{}`",
-                                   name)[]);
+                                   name).index(&FullRange));
             }
         };
 
         let archive = ArchiveRO::open(&path).expect("wanted an rlib");
         let file = path.filename_str().unwrap();
-        let file = file[3..file.len() - 5]; // chop off lib/.rlib
+        let file = file.index(&(3..(file.len() - 5))); // chop off lib/.rlib
         debug!("reading {}", file);
         for i in iter::count(0u, 1) {
             let bc_encoded = time(sess.time_passes(),
-                                  format!("check for {}.{}.bytecode.deflate", name, i)[],
+                                  format!("check for {}.{}.bytecode.deflate", name, i).as_slice(),
                                   (),
                                   |_| {
                                       archive.read(format!("{}.{}.bytecode.deflate",
-                                                           file, i)[])
+                                                           file, i).index(&FullRange))
                                   });
             let bc_encoded = match bc_encoded {
                 Some(data) => data,
@@ -76,7 +76,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
                     if i == 0 {
                         // No bitcode was found at all.
                         sess.fatal(format!("missing compressed bytecode in {}",
-                                           path.display())[]);
+                                           path.display()).index(&FullRange));
                     }
                     // No more bitcode files to read.
                     break;
@@ -91,20 +91,20 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
                     if version == 1 {
                         // The only version existing so far
                         let data_size = extract_compressed_bytecode_size_v1(bc_encoded);
-                        let compressed_data = bc_encoded[
+                        let compressed_data = bc_encoded.index(&(
                             link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET..
-                            link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as uint];
+                            (link::RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET + data_size as uint)));
 
                         match flate::inflate_bytes(compressed_data) {
                             Some(inflated) => inflated,
                             None => {
                                 sess.fatal(format!("failed to decompress bc of `{}`",
-                                                   name)[])
+                                                   name).index(&FullRange))
                             }
                         }
                     } else {
                         sess.fatal(format!("Unsupported bytecode format version {}",
-                                           version)[])
+                                           version).index(&FullRange))
                     }
                 })
             } else {
@@ -115,7 +115,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
                         Some(bc) => bc,
                         None => {
                             sess.fatal(format!("failed to decompress bc of `{}`",
-                                               name)[])
+                                               name).index(&FullRange))
                         }
                     }
                 })
@@ -124,7 +124,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
             let ptr = bc_decoded.as_slice().as_ptr();
             debug!("linking {}, part {}", name, i);
             time(sess.time_passes(),
-                 format!("ll link {}.{}", name, i)[],
+                 format!("ll link {}.{}", name, i).index(&FullRange),
                  (),
                  |()| unsafe {
                 if !llvm::LLVMRustLinkInExternalBitcode(llmod,
@@ -132,7 +132,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
                                                         bc_decoded.len() as libc::size_t) {
                     write::llvm_err(sess.diagnostic().handler(),
                                     format!("failed to load bc of `{}`",
-                                            name[]));
+                                            name.index(&FullRange)));
                 }
             });
         }
@@ -186,7 +186,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
 fn is_versioned_bytecode_format(bc: &[u8]) -> bool {
     let magic_id_byte_count = link::RLIB_BYTECODE_OBJECT_MAGIC.len();
     return bc.len() > magic_id_byte_count &&
-           bc[..magic_id_byte_count] == link::RLIB_BYTECODE_OBJECT_MAGIC;
+           bc.index(&(0..magic_id_byte_count)) == link::RLIB_BYTECODE_OBJECT_MAGIC;
 }
 
 fn extract_bytecode_format_version(bc: &[u8]) -> u32 {
@@ -198,8 +198,8 @@ fn extract_compressed_bytecode_size_v1(bc: &[u8]) -> u64 {
 }
 
 fn read_from_le_bytes<T: Int>(bytes: &[u8], position_in_bytes: uint) -> T {
-    let byte_data = bytes[position_in_bytes..
-                          position_in_bytes + mem::size_of::<T>()];
+    let byte_data = bytes.index(&(position_in_bytes..
+                                  (position_in_bytes + mem::size_of::<T>())));
     let data = unsafe {
         *(byte_data.as_ptr() as *const T)
     };
index 98e2b4b9dddb575bbba99fe53160840f43c7d138..8a80019143ea316b0865705dc487a488be19108a 100644 (file)
@@ -47,14 +47,14 @@ pub fn llvm_err(handler: &diagnostic::Handler, msg: String) -> ! {
     unsafe {
         let cstr = llvm::LLVMRustGetLastError();
         if cstr == ptr::null() {
-            handler.fatal(msg[]);
+            handler.fatal(msg.index(&FullRange));
         } else {
             let err = ffi::c_str_to_bytes(&cstr);
             let err = String::from_utf8_lossy(err.as_slice()).to_string();
             libc::free(cstr as *mut _);
             handler.fatal(format!("{}: {}",
-                                  msg[],
-                                  err[])[]);
+                                  msg.index(&FullRange),
+                                  err.index(&FullRange)).index(&FullRange));
         }
     }
 }
@@ -104,13 +104,13 @@ fn dump(&mut self, handler: &Handler) {
             match diag.code {
                 Some(ref code) => {
                     handler.emit_with_code(None,
-                                           diag.msg[],
-                                           code[],
+                                           diag.msg.index(&FullRange),
+                                           code.index(&FullRange),
                                            diag.lvl);
                 },
                 None => {
                     handler.emit(None,
-                                 diag.msg[],
+                                 diag.msg.index(&FullRange),
                                  diag.lvl);
                 },
             }
@@ -165,8 +165,8 @@ fn get_llvm_opt_level(optimize: config::OptLevel) -> llvm::CodeGenOptLevel {
 
 fn create_target_machine(sess: &Session) -> TargetMachineRef {
     let reloc_model_arg = match sess.opts.cg.relocation_model {
-        Some(ref s) => s[],
-        None => sess.target.target.options.relocation_model[]
+        Some(ref s) => s.index(&FullRange),
+        None => sess.target.target.options.relocation_model.index(&FullRange)
     };
     let reloc_model = match reloc_model_arg {
         "pic" => llvm::RelocPIC,
@@ -174,10 +174,10 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
         "default" => llvm::RelocDefault,
         "dynamic-no-pic" => llvm::RelocDynamicNoPic,
         _ => {
-            sess.err(format!("{} is not a valid relocation mode",
+            sess.err(format!("{:?} is not a valid relocation mode",
                              sess.opts
                                  .cg
-                                 .relocation_model)[]);
+                                 .relocation_model).index(&FullRange));
             sess.abort_if_errors();
             unreachable!();
         }
@@ -198,8 +198,8 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
     let fdata_sections = ffunction_sections;
 
     let code_model_arg = match sess.opts.cg.code_model {
-        Some(ref s) => s[],
-        None => sess.target.target.options.code_model[]
+        Some(ref s) => s.index(&FullRange),
+        None => sess.target.target.options.code_model.index(&FullRange)
     };
 
     let code_model = match code_model_arg {
@@ -209,16 +209,16 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
         "medium" => llvm::CodeModelMedium,
         "large" => llvm::CodeModelLarge,
         _ => {
-            sess.err(format!("{} is not a valid code model",
+            sess.err(format!("{:?} is not a valid code model",
                              sess.opts
                                  .cg
-                                 .code_model)[]);
+                                 .code_model).index(&FullRange));
             sess.abort_if_errors();
             unreachable!();
         }
     };
 
-    let triple = sess.target.target.llvm_target[];
+    let triple = sess.target.target.llvm_target.index(&FullRange);
 
     let tm = unsafe {
         let triple = CString::from_slice(triple.as_bytes());
@@ -350,13 +350,13 @@ struct HandlerFreeVars<'a> {
     match cgcx.lto_ctxt {
         Some((sess, _)) => {
             sess.codemap().with_expn_info(ExpnId::from_llvm_cookie(cookie), |info| match info {
-                Some(ei) => sess.span_err(ei.call_site, msg[]),
-                None     => sess.err(msg[]),
+                Some(ei) => sess.span_err(ei.call_site, msg.index(&FullRange)),
+                None     => sess.err(msg.index(&FullRange)),
             });
         }
 
         None => {
-            cgcx.handler.err(msg[]);
+            cgcx.handler.err(msg.index(&FullRange));
             cgcx.handler.note("build without -C codegen-units for more exact errors");
         }
     }
@@ -381,8 +381,8 @@ struct HandlerFreeVars<'a> {
                 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))[]);
+                                          if loc.is_empty() { "[unknown]" } else { loc.as_slice() },
+                                          llvm::twine_to_string(opt.message)).as_slice());
             }
         }
 
@@ -446,7 +446,7 @@ unsafe fn optimize_and_codegen(cgcx: &CodegenContext,
             for pass in config.passes.iter() {
                 let pass = CString::from_slice(pass.as_bytes());
                 if !llvm::LLVMRustAddPass(mpm, pass.as_ptr()) {
-                    cgcx.handler.warn(format!("unknown pass {}, ignoring",
+                    cgcx.handler.warn(format!("unknown pass {:?}, ignoring",
                                               pass).as_slice());
                 }
             }
@@ -518,14 +518,14 @@ unsafe fn with_codegen<F>(tm: TargetMachineRef,
         }
 
         if config.emit_asm {
-            let path = output_names.with_extension(format!("{}.s", name_extra)[]);
+            let path = output_names.with_extension(format!("{}.s", name_extra).index(&FullRange));
             with_codegen(tm, llmod, config.no_builtins, |cpm| {
                 write_output_file(cgcx.handler, tm, cpm, llmod, &path, llvm::AssemblyFileType);
             });
         }
 
         if config.emit_obj {
-            let path = output_names.with_extension(format!("{}.o", name_extra)[]);
+            let path = output_names.with_extension(format!("{}.o", name_extra).index(&FullRange));
             with_codegen(tm, llmod, config.no_builtins, |cpm| {
                 write_output_file(cgcx.handler, tm, cpm, llmod, &path, llvm::ObjectFileType);
             });
@@ -639,7 +639,7 @@ pub fn run_passes(sess: &Session,
 
     // Process the work items, optionally using worker threads.
     if sess.opts.cg.codegen_units == 1 {
-        run_work_singlethreaded(sess, trans.reachable[], work_items);
+        run_work_singlethreaded(sess, trans.reachable.index(&FullRange), work_items);
     } else {
         run_work_multithreaded(sess, work_items, sess.opts.cg.codegen_units);
     }
@@ -667,7 +667,7 @@ pub fn run_passes(sess: &Session,
                 // 2) Multiple codegen units, with `-o some_name`.  We have
                 //    no good solution for this case, so warn the user.
                 sess.warn(format!("ignoring -o because multiple .{} files were produced",
-                                  ext)[]);
+                                  ext).index(&FullRange));
             } else {
                 // 3) Multiple codegen units, but no `-o some_name`.  We
                 //    just leave the `foo.0.x` files in place.
@@ -700,20 +700,20 @@ pub fn run_passes(sess: &Session,
             };
 
         let pname = get_cc_prog(sess);
-        let mut cmd = Command::new(pname[]);
+        let mut cmd = Command::new(pname.index(&FullRange));
 
-        cmd.args(sess.target.target.options.pre_link_args[]);
+        cmd.args(sess.target.target.options.pre_link_args.index(&FullRange));
         cmd.arg("-nostdlib");
 
         for index in range(0, trans.modules.len()) {
-            cmd.arg(crate_output.with_extension(format!("{}.o", index)[]));
+            cmd.arg(crate_output.with_extension(format!("{}.o", index).index(&FullRange)));
         }
 
         cmd.arg("-r")
            .arg("-o")
            .arg(windows_output_path.as_ref().unwrap_or(output_path));
 
-        cmd.args(sess.target.target.options.post_link_args[]);
+        cmd.args(sess.target.target.options.post_link_args.index(&FullRange));
 
         if (sess.opts.debugging_opts & config::PRINT_LINK_ARGS) != 0 {
             println!("{}", &cmd);
@@ -726,14 +726,14 @@ pub fn run_passes(sess: &Session,
             Ok(status) => {
                 if !status.success() {
                     sess.err(format!("linking of {} with `{}` failed",
-                                     output_path.display(), cmd)[]);
+                                     output_path.display(), cmd).index(&FullRange));
                     sess.abort_if_errors();
                 }
             },
             Err(e) => {
                 sess.err(format!("could not exec the linker `{}`: {}",
                                  pname,
-                                 e)[]);
+                                 e).index(&FullRange));
                 sess.abort_if_errors();
             },
         }
@@ -818,12 +818,12 @@ pub fn run_passes(sess: &Session,
         for i in range(0, trans.modules.len()) {
             if modules_config.emit_obj {
                 let ext = format!("{}.o", i);
-                remove(sess, &crate_output.with_extension(ext[]));
+                remove(sess, &crate_output.with_extension(ext.index(&FullRange)));
             }
 
             if modules_config.emit_bc && !keep_numbered_bitcode {
                 let ext = format!("{}.bc", i);
-                remove(sess, &crate_output.with_extension(ext[]));
+                remove(sess, &crate_output.with_extension(ext.index(&FullRange)));
             }
         }
 
@@ -928,7 +928,7 @@ fn run_work_multithreaded(sess: &Session,
             }
 
             tx.take().unwrap().send(()).unwrap();
-        }).detach();
+        });
     }
 
     let mut panicked = false;
@@ -949,7 +949,7 @@ fn run_work_multithreaded(sess: &Session,
 
 pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
     let pname = get_cc_prog(sess);
-    let mut cmd = Command::new(pname[]);
+    let mut cmd = Command::new(pname.index(&FullRange));
 
     cmd.arg("-c").arg("-o").arg(outputs.path(config::OutputTypeObject))
                            .arg(outputs.temp_path(config::OutputTypeAssembly));
@@ -960,18 +960,18 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
             if !prog.status.success() {
                 sess.err(format!("linking with `{}` failed: {}",
                                  pname,
-                                 prog.status)[]);
-                sess.note(format!("{}", &cmd)[]);
+                                 prog.status).index(&FullRange));
+                sess.note(format!("{}", &cmd).index(&FullRange));
                 let mut note = prog.error.clone();
-                note.push_all(prog.output[]);
-                sess.note(str::from_utf8(note[]).unwrap());
+                note.push_all(prog.output.index(&FullRange));
+                sess.note(str::from_utf8(note.index(&FullRange)).unwrap());
                 sess.abort_if_errors();
             }
         },
         Err(e) => {
             sess.err(format!("could not exec the linker `{}`: {}",
                              pname,
-                             e)[]);
+                             e).index(&FullRange));
             sess.abort_if_errors();
         }
     }
@@ -1004,7 +1004,7 @@ unsafe fn configure_llvm(sess: &Session) {
         if sess.print_llvm_passes() { add("-debug-pass=Structure"); }
 
         for arg in sess.opts.cg.llvm_args.iter() {
-            add((*arg)[]);
+            add((*arg).index(&FullRange));
         }
     }
 
index 705fecf4d198eec8b7590c53b659c719dbf93fdf..b6f90a4c2f52a9ac7420b588f9f3727051fb87eb 100644 (file)
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![allow(unknown_features)]
-#![feature(default_type_params, globs, macro_rules, phase, quote)]
+#![feature(quote)]
 #![feature(slicing_syntax, unsafe_destructor)]
 #![feature(rustc_diagnostic_macros)]
-#![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
-#![feature(associated_types)]
 
 extern crate arena;
 extern crate flate;
 extern crate serialize;
 extern crate "rustc_llvm" as llvm;
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate syntax;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate syntax;
+#[macro_use] extern crate log;
+#[macro_use] extern crate syntax;
 
 pub use rustc::session;
 pub use rustc::metadata;
index 8e6276b61f949eecfe4afdae958965bcfc5d63e7..35f168f092a700d5d57dda2dc011504defa3fd1a 100644 (file)
@@ -94,7 +94,7 @@ fn dump_crate_info(&mut self, name: &str, krate: &ast::Crate) {
 
         // dump info about all the external crates referenced from this crate
         self.sess.cstore.iter_crate_data(|n, cmd| {
-            self.fmt.external_crate_str(krate.span, cmd.name[], n);
+            self.fmt.external_crate_str(krate.span, cmd.name.index(&FullRange), n);
         });
         self.fmt.recorder.record("end_external_crates\n");
     }
@@ -143,7 +143,7 @@ fn write_sub_paths(&mut self, path: &ast::Path) {
         for &(ref span, ref qualname) in sub_paths.iter() {
             self.fmt.sub_mod_ref_str(path.span,
                                      *span,
-                                     qualname[],
+                                     qualname.index(&FullRange),
                                      self.cur_scope);
         }
     }
@@ -161,7 +161,7 @@ fn write_sub_paths_truncated(&mut self, path: &ast::Path) {
         for &(ref span, ref qualname) in sub_paths.iter() {
             self.fmt.sub_mod_ref_str(path.span,
                                      *span,
-                                     qualname[],
+                                     qualname.index(&FullRange),
                                      self.cur_scope);
         }
     }
@@ -180,17 +180,17 @@ fn write_sub_path_trait_truncated(&mut self, path: &ast::Path) {
         let (ref span, ref qualname) = sub_paths[len-2];
         self.fmt.sub_type_ref_str(path.span,
                                   *span,
-                                  qualname[]);
+                                  qualname.index(&FullRange));
 
         // write the other sub-paths
         if len <= 2 {
             return;
         }
-        let sub_paths = sub_paths[..len-2];
+        let sub_paths = sub_paths.index(&(0..(len-2)));
         for &(ref span, ref qualname) in sub_paths.iter() {
             self.fmt.sub_mod_ref_str(path.span,
                                      *span,
-                                     qualname[],
+                                     qualname.index(&FullRange),
                                      self.cur_scope);
         }
     }
@@ -199,7 +199,7 @@ fn write_sub_path_trait_truncated(&mut self, path: &ast::Path) {
     fn lookup_type_ref(&self, ref_id: NodeId) -> Option<DefId> {
         if !self.analysis.ty_cx.def_map.borrow().contains_key(&ref_id) {
             self.sess.bug(format!("def_map has no key for {} in lookup_type_ref",
-                                  ref_id)[]);
+                                  ref_id).index(&FullRange));
         }
         let def = (*self.analysis.ty_cx.def_map.borrow())[ref_id];
         match def {
@@ -212,7 +212,7 @@ fn lookup_def_kind(&self, ref_id: NodeId, span: Span) -> Option<recorder::Row> {
         let def_map = self.analysis.ty_cx.def_map.borrow();
         if !def_map.contains_key(&ref_id) {
             self.sess.span_bug(span, format!("def_map has no key for {} in lookup_def_kind",
-                                             ref_id)[]);
+                                             ref_id).index(&FullRange));
         }
         let def = (*def_map)[ref_id];
         match def {
@@ -240,8 +240,8 @@ fn lookup_def_kind(&self, ref_id: NodeId, span: Span) -> Option<recorder::Row> {
             def::DefUse(_) |
             def::DefMethod(..) |
             def::DefPrimTy(_) => {
-                self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {}",
-                                                 def)[]);
+                self.sess.span_bug(span, format!("lookup_def_kind for unexpected item: {:?}",
+                                                 def).index(&FullRange));
             },
         }
     }
@@ -262,8 +262,8 @@ fn process_formals(&mut self, formals: &Vec<ast::Arg>, qualname: &str) {
                                     span_utils.span_for_last_ident(p.span),
                                     id,
                                     qualname,
-                                    path_to_string(p)[],
-                                    typ[]);
+                                    path_to_string(p).index(&FullRange),
+                                    typ.index(&FullRange));
             }
             self.collected_paths.clear();
         }
@@ -285,14 +285,14 @@ fn process_method(&mut self, method: &ast::Method) {
                     match item.node {
                         ast::ItemImpl(_, _, _, _, ref ty, _) => {
                             let mut result = String::from_str("<");
-                            result.push_str(ty_to_string(&**ty)[]);
+                            result.push_str(ty_to_string(&**ty).index(&FullRange));
 
                             match ty::trait_of_item(&self.analysis.ty_cx,
                                                     ast_util::local_def(method.id)) {
                                 Some(def_id) => {
                                     result.push_str(" as ");
                                     result.push_str(
-                                        ty::item_path_str(&self.analysis.ty_cx, def_id)[]);
+                                        ty::item_path_str(&self.analysis.ty_cx, def_id).as_slice());
                                 },
                                 None => {}
                             }
@@ -302,17 +302,17 @@ fn process_method(&mut self, method: &ast::Method) {
                         _ => {
                             self.sess.span_bug(method.span,
                                                format!("Container {} for method {} not an impl?",
-                                                       impl_id.node, method.id)[]);
+                                                       impl_id.node, method.id).index(&FullRange));
                         },
                     }
                 },
                 _ => {
                     self.sess.span_bug(method.span,
-                                       format!("Container {} for method {} is not a node item {}",
+                                       format!("Container {} for method {} is not a node item {:?}",
                                                impl_id.node,
                                                method.id,
                                                self.analysis.ty_cx.map.get(impl_id.node)
-                                              )[]);
+                                              ).index(&FullRange));
                 },
             },
             None => match ty::trait_of_item(&self.analysis.ty_cx,
@@ -328,20 +328,20 @@ fn process_method(&mut self, method: &ast::Method) {
                         _ => {
                             self.sess.span_bug(method.span,
                                                format!("Could not find container {} for method {}",
-                                                       def_id.node, method.id)[]);
+                                                       def_id.node, method.id).index(&FullRange));
                         }
                     }
                 },
                 None => {
                     self.sess.span_bug(method.span,
                                        format!("Could not find container for method {}",
-                                               method.id)[]);
+                                               method.id).index(&FullRange));
                 },
             },
         };
 
         qualname.push_str(get_ident(method.pe_ident()).get());
-        let qualname = qualname[];
+        let qualname = qualname.index(&FullRange);
 
         // record the decl for this def (if it has one)
         let decl_id = ty::trait_item_of_item(&self.analysis.ty_cx,
@@ -430,13 +430,13 @@ fn process_struct_field_def(&mut self,
                     Some(sub_span) => self.fmt.field_str(field.span,
                                                          Some(sub_span),
                                                          field.node.id,
-                                                         name.get()[],
-                                                         qualname[],
-                                                         typ[],
+                                                         name.get().index(&FullRange),
+                                                         qualname.index(&FullRange),
+                                                         typ.index(&FullRange),
                                                          scope_id),
                     None => self.sess.span_bug(field.span,
                                                format!("Could not find sub-span for field {}",
-                                                       qualname)[]),
+                                                       qualname).index(&FullRange)),
                 }
             },
             _ => (),
@@ -463,7 +463,7 @@ fn process_generic_params(&mut self, generics:&ast::Generics,
             self.fmt.typedef_str(full_span,
                                  Some(*param_ss),
                                  param.id,
-                                 name[],
+                                 name.index(&FullRange),
                                  "");
         }
         self.visit_generics(generics);
@@ -480,10 +480,10 @@ fn process_fn(&mut self,
         self.fmt.fn_str(item.span,
                         sub_span,
                         item.id,
-                        qualname[],
+                        qualname.index(&FullRange),
                         self.cur_scope);
 
-        self.process_formals(&decl.inputs, qualname[]);
+        self.process_formals(&decl.inputs, qualname.index(&FullRange));
 
         // walk arg and return types
         for arg in decl.inputs.iter() {
@@ -497,7 +497,7 @@ fn process_fn(&mut self,
         // walk the body
         self.nest(item.id, |v| v.visit_block(&*body));
 
-        self.process_generic_params(ty_params, item.span, qualname[], item.id);
+        self.process_generic_params(ty_params, item.span, qualname.index(&FullRange), item.id);
     }
 
     fn process_static(&mut self,
@@ -519,9 +519,9 @@ fn process_static(&mut self,
                             sub_span,
                             item.id,
                             get_ident(item.ident).get(),
-                            qualname[],
-                            value[],
-                            ty_to_string(&*typ)[],
+                            qualname.index(&FullRange),
+                            value.index(&FullRange),
+                            ty_to_string(&*typ).index(&FullRange),
                             self.cur_scope);
 
         // walk type and init value
@@ -542,9 +542,9 @@ fn process_const(&mut self,
                             sub_span,
                             item.id,
                             get_ident(item.ident).get(),
-                            qualname[],
+                            qualname.index(&FullRange),
                             "",
-                            ty_to_string(&*typ)[],
+                            ty_to_string(&*typ).index(&FullRange),
                             self.cur_scope);
 
         // walk type and init value
@@ -568,17 +568,17 @@ fn process_struct(&mut self,
                             sub_span,
                             item.id,
                             ctor_id,
-                            qualname[],
+                            qualname.index(&FullRange),
                             self.cur_scope,
-                            val[]);
+                            val.index(&FullRange));
 
         // fields
         for field in def.fields.iter() {
-            self.process_struct_field_def(field, qualname[], item.id);
+            self.process_struct_field_def(field, qualname.index(&FullRange), item.id);
             self.visit_ty(&*field.node.ty);
         }
 
-        self.process_generic_params(ty_params, item.span, qualname[], item.id);
+        self.process_generic_params(ty_params, item.span, qualname.index(&FullRange), item.id);
     }
 
     fn process_enum(&mut self,
@@ -591,12 +591,12 @@ fn process_enum(&mut self,
             Some(sub_span) => self.fmt.enum_str(item.span,
                                                 Some(sub_span),
                                                 item.id,
-                                                enum_name[],
+                                                enum_name.index(&FullRange),
                                                 self.cur_scope,
-                                                val[]),
+                                                val.index(&FullRange)),
             None => self.sess.span_bug(item.span,
                                        format!("Could not find subspan for enum {}",
-                                               enum_name)[]),
+                                               enum_name).index(&FullRange)),
         }
         for variant in enum_definition.variants.iter() {
             let name = get_ident(variant.node.name);
@@ -612,9 +612,9 @@ fn process_enum(&mut self,
                                                self.span.span_for_first_ident(variant.span),
                                                variant.node.id,
                                                name,
-                                               qualname[],
-                                               enum_name[],
-                                               val[],
+                                               qualname.index(&FullRange),
+                                               enum_name.index(&FullRange),
+                                               val.index(&FullRange),
                                                item.id);
                     for arg in args.iter() {
                         self.visit_ty(&*arg.ty);
@@ -630,20 +630,20 @@ fn process_enum(&mut self,
                         self.span.span_for_first_ident(variant.span),
                         variant.node.id,
                         ctor_id,
-                        qualname[],
-                        enum_name[],
-                        val[],
+                        qualname.index(&FullRange),
+                        enum_name.index(&FullRange),
+                        val.index(&FullRange),
                         item.id);
 
                     for field in struct_def.fields.iter() {
-                        self.process_struct_field_def(field, qualname[], variant.node.id);
+                        self.process_struct_field_def(field, qualname.as_slice(), variant.node.id);
                         self.visit_ty(&*field.node.ty);
                     }
                 }
             }
         }
 
-        self.process_generic_params(ty_params, item.span, enum_name[], item.id);
+        self.process_generic_params(ty_params, item.span, enum_name.index(&FullRange), item.id);
     }
 
     fn process_impl(&mut self,
@@ -703,9 +703,9 @@ fn process_trait(&mut self,
         self.fmt.trait_str(item.span,
                            sub_span,
                            item.id,
-                           qualname[],
+                           qualname.index(&FullRange),
                            self.cur_scope,
-                           val[]);
+                           val.index(&FullRange));
 
         // super-traits
         for super_bound in trait_refs.iter() {
@@ -737,7 +737,7 @@ fn process_trait(&mut self,
         }
 
         // walk generics and methods
-        self.process_generic_params(generics, item.span, qualname[], item.id);
+        self.process_generic_params(generics, item.span, qualname.index(&FullRange), item.id);
         for method in methods.iter() {
             self.visit_trait_item(method)
         }
@@ -755,9 +755,9 @@ fn process_mod(&mut self,
         self.fmt.mod_str(item.span,
                          sub_span,
                          item.id,
-                         qualname[],
+                         qualname.index(&FullRange),
                          self.cur_scope,
-                         filename[]);
+                         filename.index(&FullRange));
 
         self.nest(item.id, |v| visit::walk_mod(v, m));
     }
@@ -774,7 +774,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)[]);
+                               format!("def_map has no key for {} in visit_expr", id).as_slice());
         }
         let def = &(*def_map)[id];
         let sub_span = self.span.span_for_last_ident(span);
@@ -841,7 +841,7 @@ fn process_path(&mut self,
                                                           self.cur_scope),
             _ => self.sess.span_bug(span,
                                     format!("Unexpected def kind while looking up path in '{}'",
-                                            self.span.snippet(span))[]),
+                                            self.span.snippet(span)).index(&FullRange)),
         }
         // modules or types in the path prefix
         match *def {
@@ -959,7 +959,7 @@ fn process_method_call(&mut self,
                                self.cur_scope);
 
         // walk receiver and args
-        visit::walk_exprs(self, args[]);
+        visit::walk_exprs(self, args.index(&FullRange));
     }
 
     fn process_pat(&mut self, p:&ast::Pat) {
@@ -976,7 +976,7 @@ fn process_pat(&mut self, p:&ast::Pat) {
                     None => {
                         self.sess.span_bug(p.span,
                                            format!("Could not find struct_def for `{}`",
-                                                   self.span.snippet(p.span))[]);
+                                                   self.span.snippet(p.span)).index(&FullRange));
                     }
                 };
                 for &Spanned { node: ref field, span } in fields.iter() {
@@ -1061,11 +1061,11 @@ fn visit_item(&mut self, item: &ast::Item) {
                 self.fmt.typedef_str(item.span,
                                      sub_span,
                                      item.id,
-                                     qualname[],
-                                     value[]);
+                                     qualname.index(&FullRange),
+                                     value.index(&FullRange));
 
                 self.visit_ty(&**ty);
-                self.process_generic_params(ty_params, item.span, qualname[], item.id);
+                self.process_generic_params(ty_params, item.span, qualname.as_slice(), item.id);
             },
             ast::ItemMac(_) => (),
             _ => visit::walk_item(self, item),
@@ -1122,12 +1122,12 @@ fn visit_trait_item(&mut self, tm: &ast::TraitItem) {
                     None => {
                         self.sess.span_bug(method_type.span,
                                            format!("Could not find trait for method {}",
-                                                   method_type.id)[]);
+                                                   method_type.id).index(&FullRange));
                     },
                 };
 
                 qualname.push_str(get_ident(method_type.ident).get());
-                let qualname = qualname[];
+                let qualname = qualname.index(&FullRange);
 
                 let sub_span = self.span.sub_span_after_keyword(method_type.span, keywords::Fn);
                 self.fmt.method_decl_str(method_type.span,
@@ -1262,7 +1262,7 @@ fn visit_view_item(&mut self, i: &ast::ViewItem) {
                                           id,
                                           cnum,
                                           name,
-                                          s[],
+                                          s.index(&FullRange),
                                           self.cur_scope);
             },
         }
@@ -1371,8 +1371,8 @@ fn visit_expr(&mut self, ex: &ast::Expr) {
                 }
 
                 let mut id = String::from_str("$");
-                id.push_str(ex.id.to_string()[]);
-                self.process_formals(&decl.inputs, id[]);
+                id.push_str(ex.id.to_string().index(&FullRange));
+                self.process_formals(&decl.inputs, id.index(&FullRange));
 
                 // walk arg and return types
                 for arg in decl.inputs.iter() {
@@ -1418,7 +1418,8 @@ fn visit_arm(&mut self, arm: &ast::Arm) {
             let def_map = self.analysis.ty_cx.def_map.borrow();
             if !def_map.contains_key(&id) {
                 self.sess.span_bug(p.span,
-                                   format!("def_map has no key for {} in visit_arm", id)[]);
+                                   format!("def_map has no key for {} in visit_arm",
+                                           id).index(&FullRange));
             }
             let def = &(*def_map)[id];
             match *def {
@@ -1433,8 +1434,8 @@ fn visit_arm(&mut self, arm: &ast::Arm) {
                     self.fmt.variable_str(p.span,
                                           Some(p.span),
                                           id,
-                                          path_to_string(p)[],
-                                          value[],
+                                          path_to_string(p).index(&FullRange),
+                                          value.index(&FullRange),
                                           "")
                 }
                 def::DefVariant(..) => {
@@ -1443,7 +1444,8 @@ fn visit_arm(&mut self, arm: &ast::Arm) {
                 // FIXME(nrc) what are these doing here?
                 def::DefStatic(_, _) => {}
                 def::DefConst(..) => {}
-                _ => error!("unexpected definition kind when processing collected paths: {}", *def)
+                _ => error!("unexpected definition kind when processing collected paths: {:?}",
+                            *def)
             }
         }
         for &(id, span, ref path, ref_kind) in paths_to_process.iter() {
@@ -1488,9 +1490,9 @@ fn visit_local(&mut self, l: &ast::Local) {
             self.fmt.variable_str(p.span,
                                   sub_span,
                                   id,
-                                  path_to_string(p)[],
-                                  value[],
-                                  typ[]);
+                                  path_to_string(p).index(&FullRange),
+                                  value.index(&FullRange),
+                                  typ.index(&FullRange));
         }
         self.collected_paths.clear();
 
@@ -1509,7 +1511,7 @@ pub fn process_crate(sess: &Session,
     }
 
     assert!(analysis.glob_map.is_some());
-    let cratename = match attr::find_crate_name(krate.attrs[]) {
+    let cratename = match attr::find_crate_name(krate.attrs.index(&FullRange)) {
         Some(name) => name.get().to_string(),
         None => {
             info!("Could not find crate name, using 'unknown_crate'");
@@ -1530,7 +1532,7 @@ pub fn process_crate(sess: &Session,
 
     match fs::mkdir_recursive(&root_path, io::USER_RWX) {
         Err(e) => sess.err(format!("Could not create directory {}: {}",
-                           root_path.display(), e)[]),
+                           root_path.display(), e).index(&FullRange)),
         _ => (),
     }
 
@@ -1547,7 +1549,7 @@ pub fn process_crate(sess: &Session,
         Ok(f) => box f,
         Err(e) => {
             let disp = root_path.display();
-            sess.fatal(format!("Could not open {}: {}", disp, e)[]);
+            sess.fatal(format!("Could not open {}: {}", disp, e).index(&FullRange));
         }
     };
     root_path.pop();
@@ -1573,7 +1575,7 @@ pub fn process_crate(sess: &Session,
         cur_scope: 0
     };
 
-    visitor.dump_crate_info(cratename[], krate);
+    visitor.dump_crate_info(cratename.index(&FullRange), krate);
 
     visit::walk_crate(&mut visitor, krate);
 }
index 679a8d2d07bc88acf3533b5b30cd03646936b9a1..bb0fb387002083ffc19ec1ea511a60f59972bf78 100644 (file)
@@ -41,7 +41,7 @@ pub fn dump_span(&mut self,
         assert!(self.dump_spans);
         let result = format!("span,kind,{},{},text,\"{}\"\n",
                              kind, su.extent_str(span), escape(su.snippet(span)));
-        self.record(result[]);
+        self.record(result.index(&FullRange));
     }
 }
 
@@ -160,15 +160,15 @@ pub fn make_values_str(&self,
         if values.len() != fields.len() {
             self.span.sess.span_bug(span, format!(
                 "Mismatch between length of fields for '{}', expected '{}', found '{}'",
-                kind, fields.len(), values.len())[]);
+                kind, fields.len(), values.len()).index(&FullRange));
         }
 
         let values = values.iter().map(|s| {
             // Never take more than 1020 chars
             if s.len() > 1020 {
-                s[..1020]
+                s.index(&(0..1020))
             } else {
-                s[]
+                s.index(&FullRange)
             }
         });
 
@@ -184,7 +184,7 @@ pub fn make_values_str(&self,
             }
         )));
         Some(strs.fold(String::new(), |mut s, ss| {
-            s.push_str(ss[]);
+            s.push_str(ss.index(&FullRange));
             s
         }))
     }
@@ -198,7 +198,7 @@ pub fn record_without_span(&mut self,
         if needs_span {
             self.span.sess.span_bug(span, format!(
                 "Called record_without_span for '{}' which does requires a span",
-                label)[]);
+                label).index(&FullRange));
         }
         assert!(!dump_spans);
 
@@ -212,9 +212,9 @@ pub fn record_without_span(&mut self,
         };
 
         let mut result = String::from_str(label);
-        result.push_str(values_str[]);
+        result.push_str(values_str.index(&FullRange));
         result.push_str("\n");
-        self.recorder.record(result[]);
+        self.recorder.record(result.index(&FullRange));
     }
 
     pub fn record_with_span(&mut self,
@@ -237,7 +237,7 @@ 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)[]);
+                                             which does not require a span", label).as_slice());
         }
 
         let values_str = match self.make_values_str(label, fields, values, span) {
@@ -245,7 +245,7 @@ pub fn record_with_span(&mut self,
             None => return,
         };
         let result = format!("{},{}{}\n", label, self.span.extent_str(sub_span), values_str);
-        self.recorder.record(result[]);
+        self.recorder.record(result.index(&FullRange));
     }
 
     pub fn check_and_record(&mut self,
@@ -275,7 +275,7 @@ pub fn variable_str(&mut self,
         // variable def's node id
         let mut qualname = String::from_str(name);
         qualname.push_str("$");
-        qualname.push_str(id.to_string()[]);
+        qualname.push_str(id.to_string().index(&FullRange));
         self.check_and_record(Variable,
                               span,
                               sub_span,
index 14c6475c87df9199c9425c1a8a33353da8dcfba5..8d249b8bfe9036c55f21ff0bb5b110e994118eab 100644 (file)
@@ -218,7 +218,7 @@ pub fn sub_span_for_type_name(&self, span: Span) -> Option<Span> {
             let loc = self.sess.codemap().lookup_char_pos(span.lo);
             self.sess.span_bug(span,
                 format!("Mis-counted brackets when breaking path? Parsing '{}' in {}, line {}",
-                        self.snippet(span), loc.file.name, loc.line)[]);
+                        self.snippet(span), loc.file.name, loc.line).index(&FullRange));
         }
         if result.is_none() && prev.tok.is_ident() && bracket_count == 0 {
             return self.make_sub_span(span, Some(prev.sp));
@@ -244,7 +244,7 @@ pub fn spans_with_brackets(&self, span: Span, nesting: int, limit: int) -> Vec<S
                     let loc = self.sess.codemap().lookup_char_pos(span.lo);
                     self.sess.span_bug(span, format!(
                         "Mis-counted brackets when breaking path? Parsing '{}' in {}, line {}",
-                         self.snippet(span), loc.file.name, loc.line)[]);
+                         self.snippet(span), loc.file.name, loc.line).index(&FullRange));
                 }
                 return result
             }
index fed0931cab71d52f071ed5429356ce99ed19fbd9..49b9ef5a40adebf2e6add1ac35d25a37a17c6690 100644 (file)
@@ -427,7 +427,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
     let _indenter = indenter();
 
     m.iter().filter_map(|br| {
-        e(br.pats[]).map(|pats| {
+        e(br.pats.index(&FullRange)).map(|pats| {
             let this = br.pats[col];
             let mut bound_ptrs = br.bound_ptrs.clone();
             match this.node {
@@ -471,8 +471,8 @@ fn enter_default<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     // Collect all of the matches that can match against anything.
     enter_match(bcx, dm, m, col, val, |pats| {
         if pat_is_binding_or_wild(dm, &*pats[col]) {
-            let mut r = pats[..col].to_vec();
-            r.push_all(pats[col + 1..]);
+            let mut r = pats.index(&(0..col)).to_vec();
+            r.push_all(pats.index(&((col + 1)..)));
             Some(r)
         } else {
             None
@@ -518,7 +518,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
              variant_size: uint,
              val: ValueRef)
              -> Vec<Match<'a, 'p, 'blk, 'tcx>> {
-    debug!("enter_opt(bcx={}, m={}, opt={}, col={}, val={})",
+    debug!("enter_opt(bcx={}, m={}, opt={:?}, col={}, val={})",
            bcx.to_str(),
            m.repr(bcx.tcx()),
            *opt,
@@ -548,7 +548,7 @@ fn enter_opt<'a, 'p, 'blk, 'tcx>(
         param_env: param_env,
     };
     enter_match(bcx, dm, m, col, val, |pats|
-        check_match::specialize(&mcx, pats[], &ctor, col, variant_size)
+        check_match::specialize(&mcx, pats.index(&FullRange), &ctor, col, variant_size)
     )
 }
 
@@ -790,7 +790,7 @@ fn compare_str<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
         let did = langcall(cx,
                            None,
                            format!("comparison of `{}`",
-                                   cx.ty_to_string(rhs_t))[],
+                                   cx.ty_to_string(rhs_t)).index(&FullRange),
                            StrEqFnLangItem);
         callee::trans_lang_call(cx, did, &[lhs, rhs], None)
     }
@@ -945,7 +945,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             if has_nested_bindings(m, col) {
                 let expanded = expand_nested_bindings(bcx, m, col, val);
                 compile_submatch_continue(bcx,
-                                          expanded[],
+                                          expanded.index(&FullRange),
                                           vals,
                                           chk,
                                           col,
@@ -967,7 +967,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                     bcx = compile_guard(bcx,
                                         &**guard_expr,
                                         m[0].data,
-                                        m[1..m.len()],
+                                        m.index(&(1..m.len())),
                                         vals,
                                         chk,
                                         has_genuine_default);
@@ -990,8 +990,8 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
     let tcx = bcx.tcx();
     let dm = &tcx.def_map;
 
-    let mut vals_left = vals[0u..col].to_vec();
-    vals_left.push_all(vals[col + 1u..]);
+    let mut vals_left = vals.index(&(0u..col)).to_vec();
+    vals_left.push_all(vals.index(&((col + 1u)..)));
     let ccx = bcx.fcx.ccx;
 
     // Find a real id (we're adding placeholder wildcard patterns, but
@@ -1037,8 +1037,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[]);
-            compile_submatch(bcx, pats[], vals[], chk, has_genuine_default);
+            vals.push_all(vals_left.as_slice());
+            compile_submatch(bcx, pats.as_slice(), vals.as_slice(), chk, has_genuine_default);
             return;
         }
         _ => ()
@@ -1046,7 +1046,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
 
     // Decide what kind of branch we need
     let opts = get_branches(bcx, m, col);
-    debug!("options={}", opts);
+    debug!("options={:?}", opts);
     let mut kind = NoBranch;
     let mut test_val = val;
     debug!("test_val={}", bcx.val_to_string(test_val));
@@ -1191,10 +1191,10 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
         }
         let opt_ms = enter_opt(opt_cx, pat_id, dm, m, opt, col, size, val);
         let mut opt_vals = unpacked;
-        opt_vals.push_all(vals_left[]);
+        opt_vals.push_all(vals_left.index(&FullRange));
         compile_submatch(opt_cx,
-                         opt_ms[],
-                         opt_vals[],
+                         opt_ms.index(&FullRange),
+                         opt_vals.index(&FullRange),
                          branch_chk.as_ref().unwrap_or(chk),
                          has_genuine_default);
     }
@@ -1213,8 +1213,8 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
             }
             _ => {
                 compile_submatch(else_cx,
-                                 defaults[],
-                                 vals_left[],
+                                 defaults.index(&FullRange),
+                                 vals_left.index(&FullRange),
                                  chk,
                                  has_genuine_default);
             }
@@ -1333,7 +1333,7 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
                                  "__llmatch");
                 trmode = TrByCopy(alloca_no_lifetime(bcx,
                                          llvariable_ty,
-                                         bcx.ident(ident)[]));
+                                         bcx.ident(ident).index(&FullRange)));
             }
             ast::BindByValue(_) => {
                 // in this case, the final type of the variable will be T,
@@ -1341,13 +1341,13 @@ fn create_bindings_map<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, pat: &ast::Pat,
                 // above
                 llmatch = alloca_no_lifetime(bcx,
                                  llvariable_ty.ptr_to(),
-                                 bcx.ident(ident)[]);
+                                 bcx.ident(ident).index(&FullRange));
                 trmode = TrByMove;
             }
             ast::BindByRef(_) => {
                 llmatch = alloca_no_lifetime(bcx,
                                  llvariable_ty,
-                                 bcx.ident(ident)[]);
+                                 bcx.ident(ident).index(&FullRange));
                 trmode = TrByRef;
             }
         };
@@ -1415,7 +1415,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
         && arm.pats.last().unwrap().node == ast::PatWild(ast::PatWildSingle)
     });
 
-    compile_submatch(bcx, matches[], &[discr_datum.val], &chk, has_default);
+    compile_submatch(bcx, matches.index(&FullRange), &[discr_datum.val], &chk, has_default);
 
     let mut arm_cxs = Vec::new();
     for arm_data in arm_datas.iter() {
@@ -1429,7 +1429,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>,
         arm_cxs.push(bcx);
     }
 
-    bcx = scope_cx.fcx.join_blocks(match_id, arm_cxs[]);
+    bcx = scope_cx.fcx.join_blocks(match_id, arm_cxs.index(&FullRange));
     return bcx;
 }
 
@@ -1582,7 +1582,7 @@ fn mk_binding_alloca<'blk, 'tcx, A, F>(bcx: Block<'blk, 'tcx>,
     let var_ty = node_id_type(bcx, p_id);
 
     // Allocate memory on stack for the binding.
-    let llval = alloc_ty(bcx, var_ty, bcx.ident(*ident)[]);
+    let llval = alloc_ty(bcx, var_ty, bcx.ident(*ident).index(&FullRange));
 
     // Subtle: be sure that we *populate* the memory *before*
     // we schedule the cleanup.
@@ -1620,7 +1620,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     if bcx.sess().asm_comments() {
         add_comment(bcx, format!("bind_irrefutable_pat(pat={})",
-                                 pat.repr(bcx.tcx()))[]);
+                                 pat.repr(bcx.tcx())).index(&FullRange));
     }
 
     let _indenter = indenter();
index 01b47b728b6ba7410f71e9723ae463c3024579d6..231de71848a1d44e6179b564f08210f809b11ca9 100644 (file)
@@ -145,7 +145,7 @@ pub fn represent_type<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     }
 
     let repr = Rc::new(represent_type_uncached(cx, t));
-    debug!("Represented as: {}", repr);
+    debug!("Represented as: {:?}", repr);
     cx.adt_reprs().borrow_mut().insert(t, repr.clone());
     repr
 }
@@ -154,7 +154,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                      t: Ty<'tcx>) -> Repr<'tcx> {
     match t.sty {
         ty::ty_tup(ref elems) => {
-            Univariant(mk_struct(cx, elems[], false, t), false)
+            Univariant(mk_struct(cx, elems.index(&FullRange), false, t), false)
         }
         ty::ty_struct(def_id, substs) => {
             let fields = ty::lookup_struct_fields(cx.tcx(), def_id);
@@ -165,17 +165,17 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             let dtor = ty::ty_dtor(cx.tcx(), def_id).has_drop_flag();
             if dtor { ftys.push(cx.tcx().types.bool); }
 
-            Univariant(mk_struct(cx, ftys[], packed, t), dtor)
+            Univariant(mk_struct(cx, ftys.index(&FullRange), packed, t), dtor)
         }
         ty::ty_unboxed_closure(def_id, _, substs) => {
             let typer = NormalizingUnboxedClosureTyper::new(cx.tcx());
             let upvars = typer.unboxed_closure_upvars(def_id, substs).unwrap();
             let upvar_types = upvars.iter().map(|u| u.ty).collect::<Vec<_>>();
-            Univariant(mk_struct(cx, upvar_types[], false, t), false)
+            Univariant(mk_struct(cx, upvar_types.index(&FullRange), false, t), false)
         }
         ty::ty_enum(def_id, substs) => {
             let cases = get_cases(cx.tcx(), def_id, substs);
-            let hint = *ty::lookup_repr_hints(cx.tcx(), def_id)[].get(0)
+            let hint = *ty::lookup_repr_hints(cx.tcx(), def_id).index(&FullRange).get(0)
                 .unwrap_or(&attr::ReprAny);
 
             let dtor = ty::ty_dtor(cx.tcx(), def_id).has_drop_flag();
@@ -185,7 +185,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 // (Typechecking will reject discriminant-sizing attrs.)
                 assert_eq!(hint, attr::ReprAny);
                 let ftys = if dtor { vec!(cx.tcx().types.bool) } else { vec!() };
-                return Univariant(mk_struct(cx, ftys[], false, t),
+                return Univariant(mk_struct(cx, ftys.index(&FullRange), false, t),
                                   dtor);
             }
 
@@ -208,7 +208,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 cx.sess().bug(format!("non-C-like enum {} with specified \
                                       discriminants",
                                       ty::item_path_str(cx.tcx(),
-                                                        def_id))[]);
+                                                        def_id)).index(&FullRange));
             }
 
             if cases.len() == 1 {
@@ -217,7 +217,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 assert_eq!(hint, attr::ReprAny);
                 let mut ftys = cases[0].tys.clone();
                 if dtor { ftys.push(cx.tcx().types.bool); }
-                return Univariant(mk_struct(cx, ftys[], false, t),
+                return Univariant(mk_struct(cx, ftys.index(&FullRange), false, t),
                                   dtor);
             }
 
@@ -226,7 +226,7 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 let mut discr = 0;
                 while discr < 2 {
                     if cases[1 - discr].is_zerolen(cx, t) {
-                        let st = mk_struct(cx, cases[discr].tys[],
+                        let st = mk_struct(cx, cases[discr].tys.index(&FullRange),
                                            false, t);
                         match cases[discr].find_ptr(cx) {
                             Some(ref df) if df.len() == 1 && st.fields.len() == 1 => {
@@ -316,17 +316,17 @@ fn represent_type_uncached<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
             let fields : Vec<_> = cases.iter().map(|c| {
                 let mut ftys = vec!(ty_of_inttype(cx.tcx(), ity));
-                ftys.push_all(c.tys[]);
+                ftys.push_all(c.tys.index(&FullRange));
                 if dtor { ftys.push(cx.tcx().types.bool); }
-                mk_struct(cx, ftys[], false, t)
+                mk_struct(cx, ftys.index(&FullRange), false, t)
             }).collect();
 
-            ensure_enum_fits_in_address_space(cx, ity, fields[], t);
+            ensure_enum_fits_in_address_space(cx, ity, fields.index(&FullRange), t);
 
             General(ity, fields, dtor)
         }
         _ => cx.sess().bug(format!("adt::represent_type called on non-ADT type: {}",
-                           ty_to_string(cx.tcx(), t))[])
+                           ty_to_string(cx.tcx(), t)).index(&FullRange))
     }
 }
 
@@ -412,7 +412,7 @@ fn find_discr_field_candidate<'tcx>(tcx: &ty::ctxt<'tcx>,
 
 impl<'tcx> Case<'tcx> {
     fn is_zerolen<'a>(&self, cx: &CrateContext<'a, 'tcx>, scapegoat: Ty<'tcx>) -> bool {
-        mk_struct(cx, self.tys[], false, scapegoat).size == 0
+        mk_struct(cx, self.tys.index(&FullRange), false, scapegoat).size == 0
     }
 
     fn find_ptr<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> Option<DiscrField> {
@@ -451,9 +451,9 @@ fn mk_struct<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
            .map(|&ty| type_of::sizing_type_of(cx, ty)).collect()
     };
 
-    ensure_struct_fits_in_address_space(cx, lltys[], packed, scapegoat);
+    ensure_struct_fits_in_address_space(cx, lltys.index(&FullRange), packed, scapegoat);
 
-    let llty_rec = Type::struct_(cx, lltys[], packed);
+    let llty_rec = Type::struct_(cx, lltys.index(&FullRange), packed);
     Struct {
         size: machine::llsize_of_alloc(cx, llty_rec),
         align: machine::llalign_of_min(cx, llty_rec),
@@ -482,7 +482,7 @@ fn mk_cenum<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 }
 
 fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntType {
-    debug!("range_to_inttype: {} {}", hint, bounds);
+    debug!("range_to_inttype: {:?} {:?}", hint, bounds);
     // Lists of sizes to try.  u64 is always allowed as a fallback.
     #[allow(non_upper_case_globals)]
     static choose_shortest: &'static[IntType] = &[
@@ -502,7 +502,7 @@ fn range_to_inttype(cx: &CrateContext, hint: Hint, bounds: &IntBounds) -> IntTyp
             return ity;
         }
         attr::ReprExtern => {
-            attempts = match cx.sess().target.target.arch[] {
+            attempts = match cx.sess().target.target.arch.index(&FullRange) {
                 // WARNING: the ARM EABI has two variants; the one corresponding to `at_least_32`
                 // appears to be used on Linux and NetBSD, but some systems may use the variant
                 // corresponding to `choose_shortest`.  However, we don't run on those yet...?
@@ -533,7 +533,7 @@ pub fn ll_inttype(cx: &CrateContext, ity: IntType) -> Type {
 }
 
 fn bounds_usable(cx: &CrateContext, ity: IntType, bounds: &IntBounds) -> bool {
-    debug!("bounds_usable: {} {}", ity, bounds);
+    debug!("bounds_usable: {:?} {:?}", ity, bounds);
     match ity {
         attr::SignedInt(_) => {
             let lllo = C_integral(ll_inttype(cx, ity), bounds.slo as u64, true);
@@ -628,7 +628,7 @@ pub fn finish_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     match *r {
         CEnum(..) | General(..) | RawNullablePointer { .. } => { }
         Univariant(ref st, _) | StructWrappedNullablePointer { nonnull: ref st, .. } =>
-            llty.set_struct_body(struct_llfields(cx, st, false, false)[],
+            llty.set_struct_body(struct_llfields(cx, st, false, false).index(&FullRange),
                                  st.packed)
     }
 }
@@ -644,7 +644,7 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         Univariant(ref st, _) | StructWrappedNullablePointer { nonnull: ref st, .. } => {
             match name {
                 None => {
-                    Type::struct_(cx, struct_llfields(cx, st, sizing, dst)[],
+                    Type::struct_(cx, struct_llfields(cx, st, sizing, dst).index(&FullRange),
                                   st.packed)
                 }
                 Some(name) => { assert_eq!(sizing, false); Type::named_struct(cx, name) }
@@ -663,7 +663,7 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             // of the size.
             //
             // FIXME #10604: this breaks when vector types are present.
-            let (size, align) = union_size_and_align(sts[]);
+            let (size, align) = union_size_and_align(sts.index(&FullRange));
             let align_s = align as u64;
             let discr_ty = ll_inttype(cx, ity);
             let discr_size = machine::llsize_of_alloc(cx, discr_ty);
@@ -684,10 +684,10 @@ fn generic_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                           Type::array(&discr_ty, align_s / discr_size - 1),
                           fill_ty];
             match name {
-                None => Type::struct_(cx, fields[], false),
+                None => Type::struct_(cx, fields.index(&FullRange), false),
                 Some(name) => {
                     let mut llty = Type::named_struct(cx, name);
-                    llty.set_struct_body(fields[], false);
+                    llty.set_struct_body(fields.index(&FullRange), false);
                     llty
                 }
             }
@@ -731,7 +731,7 @@ pub fn trans_get_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
     -> ValueRef {
     let signed;
     let val;
-    debug!("trans_get_discr r: {}", r);
+    debug!("trans_get_discr r: {:?}", r);
     match *r {
         CEnum(ity, min, max) => {
             val = load_discr(bcx, ity, scrutinee, min, max);
@@ -765,7 +765,7 @@ pub fn trans_get_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
 
 fn struct_wrapped_nullable_bitdiscr(bcx: Block, nndiscr: Disr, discrfield: &DiscrField,
                                     scrutinee: ValueRef) -> ValueRef {
-    let llptrptr = GEPi(bcx, scrutinee, discrfield[]);
+    let llptrptr = GEPi(bcx, scrutinee, discrfield.index(&FullRange));
     let llptr = Load(bcx, llptrptr);
     let cmp = if nndiscr == 0 { IntEQ } else { IntNE };
     ICmp(bcx, cmp, llptr, C_null(val_ty(llptr)))
@@ -853,7 +853,7 @@ pub fn trans_set_discr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, r: &Repr<'tcx>,
         }
         StructWrappedNullablePointer { nndiscr, ref discrfield, .. } => {
             if discr != nndiscr {
-                let llptrptr = GEPi(bcx, val, discrfield[]);
+                let llptrptr = GEPi(bcx, val, discrfield.index(&FullRange));
                 let llptrty = val_ty(llptrptr).element_type();
                 Store(bcx, C_null(llptrty), llptrptr)
             }
@@ -935,7 +935,7 @@ pub fn struct_field_ptr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, st: &Struct<'tcx>, v
     let val = if needs_cast {
         let ccx = bcx.ccx();
         let fields = st.fields.iter().map(|&ty| type_of::type_of(ccx, ty)).collect::<Vec<_>>();
-        let real_ty = Type::struct_(ccx, fields[], st.packed);
+        let real_ty = Type::struct_(ccx, fields.index(&FullRange), st.packed);
         PointerCast(bcx, val, real_ty.ptr_to())
     } else {
         val
@@ -967,14 +967,14 @@ pub fn fold_variants<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
 
             for (discr, case) in cases.iter().enumerate() {
                 let mut variant_cx = fcx.new_temp_block(
-                    format!("enum-variant-iter-{}", discr.to_string())[]
+                    format!("enum-variant-iter-{}", discr.to_string()).index(&FullRange)
                 );
                 let rhs_val = C_integral(ll_inttype(ccx, ity), discr as u64, true);
                 AddCase(llswitch, rhs_val, variant_cx.llbb);
 
                 let fields = case.fields.iter().map(|&ty|
                     type_of::type_of(bcx.ccx(), ty)).collect::<Vec<_>>();
-                let real_ty = Type::struct_(ccx, fields[], case.packed);
+                let real_ty = Type::struct_(ccx, fields.index(&FullRange), case.packed);
                 let variant_value = PointerCast(variant_cx, value, real_ty.ptr_to());
 
                 variant_cx = f(variant_cx, case, variant_value);
@@ -1051,14 +1051,14 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr
             let lldiscr = C_integral(ll_inttype(ccx, ity), discr as u64, true);
             let mut f = vec![lldiscr];
             f.push_all(vals);
-            let mut contents = build_const_struct(ccx, case, f[]);
+            let mut contents = build_const_struct(ccx, case, f.index(&FullRange));
             contents.push_all(&[padding(ccx, max_sz - case.size)]);
-            C_struct(ccx, contents[], false)
+            C_struct(ccx, contents.index(&FullRange), false)
         }
         Univariant(ref st, _dro) => {
             assert!(discr == 0);
             let contents = build_const_struct(ccx, st, vals);
-            C_struct(ccx, contents[], st.packed)
+            C_struct(ccx, contents.index(&FullRange), st.packed)
         }
         RawNullablePointer { nndiscr, nnty, .. } => {
             if discr == nndiscr {
@@ -1072,7 +1072,7 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr
             if discr == nndiscr {
                 C_struct(ccx, build_const_struct(ccx,
                                                  nonnull,
-                                                 vals)[],
+                                                 vals).index(&FullRange),
                          false)
             } else {
                 let vals = nonnull.fields.iter().map(|&ty| {
@@ -1082,7 +1082,7 @@ pub fn trans_const<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, r: &Repr<'tcx>, discr
                 }).collect::<Vec<ValueRef>>();
                 C_struct(ccx, build_const_struct(ccx,
                                                  nonnull,
-                                                 vals[])[],
+                                                 vals.index(&FullRange)).index(&FullRange),
                          false)
             }
         }
index f18d483f70328bd3389cdc527f445b729c6247ff..890f046be1b2efd226c8e7c691711aae89c0e414 100644 (file)
@@ -71,7 +71,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
                                     callee::DontAutorefArg)
         })
     }).collect::<Vec<_>>();
-    inputs.push_all(ext_inputs[]);
+    inputs.push_all(ext_inputs.index(&FullRange));
 
     // no failure occurred preparing operands, no need to cleanup
     fcx.pop_custom_cleanup_scope(temp_scope);
@@ -91,18 +91,18 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
         if !clobbers.is_empty() {
             clobbers.push(',');
         }
-        clobbers.push_str(more_clobbers[]);
+        clobbers.push_str(more_clobbers.index(&FullRange));
     }
 
     // Add the clobbers to our constraints list
     if clobbers.len() != 0 && constraints.len() != 0 {
         constraints.push(',');
-        constraints.push_str(clobbers[]);
+        constraints.push_str(clobbers.index(&FullRange));
     } else {
-        constraints.push_str(clobbers[]);
+        constraints.push_str(clobbers.index(&FullRange));
     }
 
-    debug!("Asm Constraints: {}", constraints[]);
+    debug!("Asm Constraints: {}", constraints.index(&FullRange));
 
     let num_outputs = outputs.len();
 
@@ -112,7 +112,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm)
     } else if num_outputs == 1 {
         output_types[0]
     } else {
-        Type::struct_(bcx.ccx(), output_types[], false)
+        Type::struct_(bcx.ccx(), output_types.index(&FullRange), false)
     };
 
     let dialect = match ia.dialect {
index edcfaae0f802d32482aab9ca1f785b2d142d7999..057d0f378e6f41cd37125b55aba7b0914b6530ab 100644 (file)
@@ -249,7 +249,7 @@ fn get_extern_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<'tcx>,
     let f = decl_rust_fn(ccx, fn_ty, name);
 
     csearch::get_item_attrs(&ccx.sess().cstore, did, |attrs| {
-        set_llvm_fn_attrs(ccx, attrs[], f)
+        set_llvm_fn_attrs(ccx, attrs.index(&FullRange), f)
     });
 
     ccx.externs().borrow_mut().insert(name.to_string(), f);
@@ -283,35 +283,40 @@ pub fn decl_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                               fn_ty: Ty<'tcx>, name: &str) -> ValueRef {
     let fn_ty = monomorphize::normalize_associated_type(ccx.tcx(), &fn_ty);
 
-    let (inputs, output, abi, env) = match fn_ty.sty {
+    let function_type; // placeholder so that the memory ownership works out ok
+
+    let (sig, abi, env) = match fn_ty.sty {
         ty::ty_bare_fn(_, ref f) => {
-            (f.sig.0.inputs.clone(), f.sig.0.output, f.abi, None)
+            (&f.sig, f.abi, None)
         }
         ty::ty_unboxed_closure(closure_did, _, substs) => {
             let typer = common::NormalizingUnboxedClosureTyper::new(ccx.tcx());
-            let function_type = typer.unboxed_closure_type(closure_did, substs);
+            function_type = typer.unboxed_closure_type(closure_did, substs);
             let self_type = self_type_for_unboxed_closure(ccx, closure_did, fn_ty);
             let llenvironment_type = type_of_explicit_arg(ccx, self_type);
             debug!("decl_rust_fn: function_type={} self_type={}",
                    function_type.repr(ccx.tcx()),
                    self_type.repr(ccx.tcx()));
-            (function_type.sig.0.inputs,
-             function_type.sig.0.output,
-             RustCall,
-             Some(llenvironment_type))
+            (&function_type.sig, RustCall, Some(llenvironment_type))
         }
         _ => panic!("expected closure or fn")
     };
 
-    let llfty = type_of_rust_fn(ccx, env, inputs[], output, abi);
-    debug!("decl_rust_fn(input count={},type={})",
-           inputs.len(),
+    let sig = ty::erase_late_bound_regions(ccx.tcx(), sig);
+    let sig = ty::Binder(sig);
+
+    let llfty = type_of_rust_fn(ccx, env, &sig, abi);
+
+    debug!("decl_rust_fn(sig={}, type={})",
+           sig.repr(ccx.tcx()),
            ccx.tn().type_to_string(llfty));
 
-    let llfn = decl_fn(ccx, name, llvm::CCallConv, llfty, output);
+    let llfn = decl_fn(ccx, name, llvm::CCallConv, llfty, sig.0.output /* (1) */);
     let attrs = get_fn_llvm_attributes(ccx, fn_ty);
     attrs.apply_llfn(llfn);
 
+    // (1) it's ok to directly access sig.0.output because we erased all late-bound-regions above
+
     llfn
 }
 
@@ -369,7 +374,7 @@ fn require_alloc_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         Err(s) => {
             bcx.sess().fatal(format!("allocation of `{}` {}",
                                      bcx.ty_to_string(info_ty),
-                                     s)[]);
+                                     s).index(&FullRange));
         }
     }
 }
@@ -488,7 +493,7 @@ pub fn unset_split_stack(f: ValueRef) {
 // silently mangles such symbols, breaking our linkage model.
 pub fn note_unique_llvm_symbol(ccx: &CrateContext, sym: String) {
     if ccx.all_llvm_symbols().borrow().contains(&sym) {
-        ccx.sess().bug(format!("duplicate LLVM symbol: {}", sym)[]);
+        ccx.sess().bug(format!("duplicate LLVM symbol: {}", sym).index(&FullRange));
     }
     ccx.all_llvm_symbols().borrow_mut().insert(sym);
 }
@@ -525,7 +530,7 @@ pub fn get_res_dtor<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                      ty::mk_nil(ccx.tcx()));
         get_extern_fn(ccx,
                       &mut *ccx.externs().borrow_mut(),
-                      name[],
+                      name.index(&FullRange),
                       llvm::CCallConv,
                       llty,
                       dtor_ty)
@@ -774,8 +779,8 @@ fn iter_variant<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
                       let variant_cx =
                           fcx.new_temp_block(
                               format!("enum-iter-variant-{}",
-                                      variant.disr_val.to_string()[])
-                                     []);
+                                      variant.disr_val.to_string().index(&FullRange))
+                                     .index(&FullRange));
                       match adt::trans_case(cx, &*repr, variant.disr_val) {
                           _match::SingleResult(r) => {
                               AddCase(llswitch, r.val, variant_cx.llbb)
@@ -800,7 +805,7 @@ fn iter_variant<'blk, 'tcx, F>(cx: Block<'blk, 'tcx>,
       }
       _ => {
           cx.sess().unimpl(format!("type in iter_structural_ty: {}",
-                                   ty_to_string(cx.tcx(), t))[])
+                                   ty_to_string(cx.tcx(), t)).index(&FullRange))
       }
     }
     return cx;
@@ -882,7 +887,7 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
         }
         _ => {
             cx.sess().bug(format!("fail-if-zero on unexpected type: {}",
-                                  ty_to_string(cx.tcx(), rhs_t))[]);
+                                  ty_to_string(cx.tcx(), rhs_t)).index(&FullRange));
         }
     };
     let bcx = with_cond(cx, is_zero, |bcx| {
@@ -903,8 +908,8 @@ pub fn fail_if_zero_or_overflows<'blk, 'tcx>(
             ty::ty_int(t) => {
                 let llty = Type::int_from_ty(cx.ccx(), t);
                 let min = match t {
-                    ast::TyI if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
-                    ast::TyI => i64::MIN as u64,
+                    ast::TyIs if llty == Type::i32(cx.ccx()) => i32::MIN as u64,
+                    ast::TyIs => i64::MIN as u64,
                     ast::TyI8 => i8::MIN as u64,
                     ast::TyI16 => i16::MIN as u64,
                     ast::TyI32 => i32::MIN as u64,
@@ -936,14 +941,14 @@ pub fn trans_external_path<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         ty::ty_bare_fn(_, ref fn_ty) => {
             match ccx.sess().target.target.adjust_abi(fn_ty.abi) {
                 Rust | RustCall => {
-                    get_extern_rust_fn(ccx, t, name[], did)
+                    get_extern_rust_fn(ccx, t, name.index(&FullRange), did)
                 }
                 RustIntrinsic => {
                     ccx.sess().bug("unexpected intrinsic in trans_external_path")
                 }
                 _ => {
                     foreign::register_foreign_item_fn(ccx, fn_ty.abi, t,
-                                                      name[])
+                                                      name.index(&FullRange))
                 }
             }
         }
@@ -976,7 +981,7 @@ pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     }
 
     if need_invoke(bcx) {
-        debug!("invoking {} at {}", bcx.val_to_string(llfn), bcx.llbb);
+        debug!("invoking {} at {:?}", bcx.val_to_string(llfn), bcx.llbb);
         for &llarg in llargs.iter() {
             debug!("arg: {}", bcx.val_to_string(llarg));
         }
@@ -990,13 +995,13 @@ pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
         let llresult = Invoke(bcx,
                               llfn,
-                              llargs[],
+                              llargs.index(&FullRange),
                               normal_bcx.llbb,
                               landing_pad,
                               Some(attributes));
         return (llresult, normal_bcx);
     } else {
-        debug!("calling {} at {}", bcx.val_to_string(llfn), bcx.llbb);
+        debug!("calling {} at {:?}", bcx.val_to_string(llfn), bcx.llbb);
         for &llarg in llargs.iter() {
             debug!("arg: {}", bcx.val_to_string(llarg));
         }
@@ -1006,7 +1011,7 @@ pub fn invoke<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             None => debuginfo::clear_source_location(bcx.fcx)
         };
 
-        let llresult = Call(bcx, llfn, llargs[], Some(attributes));
+        let llresult = Call(bcx, llfn, llargs.index(&FullRange), Some(attributes));
         return (llresult, bcx);
     }
 }
@@ -1123,7 +1128,7 @@ pub fn call_lifetime_end(cx: Block, ptr: ValueRef) {
 pub fn call_memcpy(cx: Block, dst: ValueRef, src: ValueRef, n_bytes: ValueRef, align: u32) {
     let _icx = push_ctxt("call_memcpy");
     let ccx = cx.ccx();
-    let key = match ccx.sess().target.target.target_word_size[] {
+    let key = match ccx.sess().target.target.target_word_size.index(&FullRange) {
         "32" => "llvm.memcpy.p0i8.p0i8.i32",
         "64" => "llvm.memcpy.p0i8.p0i8.i64",
         tws => panic!("Unsupported target word size for memcpy: {}", tws),
@@ -1170,7 +1175,7 @@ fn memzero<'a, 'tcx>(b: &Builder<'a, 'tcx>, llptr: ValueRef, ty: Ty<'tcx>) {
 
     let llty = type_of::type_of(ccx, ty);
 
-    let intrinsic_key = match ccx.sess().target.target.target_word_size[] {
+    let intrinsic_key = match ccx.sess().target.target.target_word_size.index(&FullRange) {
         "32" => "llvm.memset.p0i8.i32",
         "64" => "llvm.memset.p0i8.i64",
         tws => panic!("Unsupported target word size for memset: {}", tws),
@@ -1658,7 +1663,7 @@ fn copy_unboxed_closure_args_to_allocas<'blk, 'tcx>(
                                                          "argtuple",
                                                          arg_scope_id));
     let untupled_arg_types = match monomorphized_arg_types[0].sty {
-        ty::ty_tup(ref types) => types[],
+        ty::ty_tup(ref types) => types.index(&FullRange),
         _ => {
             bcx.tcx().sess.span_bug(args[0].pat.span,
                                     "first arg to `rust-call` ABI function \
@@ -1846,12 +1851,12 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
     let arg_datums = if abi != RustCall {
         create_datums_for_fn_args(&fcx,
-                                  monomorphized_arg_types[])
+                                  monomorphized_arg_types.index(&FullRange))
     } else {
         create_datums_for_fn_args_under_call_abi(
             bcx,
             arg_scope,
-            monomorphized_arg_types[])
+            monomorphized_arg_types.index(&FullRange))
     };
 
     bcx = match closure_env.kind {
@@ -1859,16 +1864,16 @@ pub fn trans_closure<'a, 'b, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             copy_args_to_allocas(&fcx,
                                  arg_scope,
                                  bcx,
-                                 decl.inputs[],
+                                 decl.inputs.index(&FullRange),
                                  arg_datums)
         }
         closure::UnboxedClosure(..) => {
             copy_unboxed_closure_args_to_allocas(
                 bcx,
                 arg_scope,
-                decl.inputs[],
+                decl.inputs.index(&FullRange),
                 arg_datums,
-                monomorphized_arg_types[])
+                monomorphized_arg_types.index(&FullRange))
         }
     };
 
@@ -1938,7 +1943,7 @@ pub fn trans_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     debug!("trans_fn(param_substs={})", param_substs.repr(ccx.tcx()));
     let _icx = push_ctxt("trans_fn");
     let fn_ty = ty::node_id_to_type(ccx.tcx(), id);
-    let output_type = ty::ty_fn_ret(fn_ty);
+    let output_type = ty::erase_late_bound_regions(ccx.tcx(), &ty::ty_fn_ret(fn_ty));
     let abi = ty::ty_fn_abi(fn_ty);
     trans_closure(ccx,
                   decl,
@@ -1981,11 +1986,13 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
     let tcx = ccx.tcx();
 
     let result_ty = match ctor_ty.sty {
-        ty::ty_bare_fn(_, ref bft) => bft.sig.0.output.unwrap(),
+        ty::ty_bare_fn(_, ref bft) => {
+            ty::erase_late_bound_regions(bcx.tcx(), &bft.sig.output()).unwrap()
+        }
         _ => ccx.sess().bug(
             format!("trans_enum_variant_constructor: \
                      unexpected ctor return type {}",
-                     ctor_ty.repr(tcx))[])
+                     ctor_ty.repr(tcx)).index(&FullRange))
     };
 
     // Get location to store the result. If the user does not care about
@@ -2008,7 +2015,7 @@ pub fn trans_named_tuple_constructor<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                 bcx = expr::trans_adt(bcx,
                                       result_ty,
                                       disr,
-                                      fields[],
+                                      fields.index(&FullRange),
                                       None,
                                       expr::SaveIn(llresult),
                                       call_info);
@@ -2053,11 +2060,13 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
     let ctor_ty = monomorphize::apply_param_substs(ccx.tcx(), param_substs, &ctor_ty);
 
     let result_ty = match ctor_ty.sty {
-        ty::ty_bare_fn(_, ref bft) => bft.sig.0.output,
+        ty::ty_bare_fn(_, ref bft) => {
+            ty::erase_late_bound_regions(ccx.tcx(), &bft.sig.output())
+        }
         _ => ccx.sess().bug(
             format!("trans_enum_variant_or_tuple_like_struct: \
                      unexpected ctor return type {}",
-                    ty_to_string(ccx.tcx(), ctor_ty))[])
+                    ty_to_string(ccx.tcx(), ctor_ty)).index(&FullRange))
     };
 
     let arena = TypedArena::new();
@@ -2067,9 +2076,11 @@ fn trans_enum_variant_or_tuple_like_struct<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx
 
     assert!(!fcx.needs_ret_allocas);
 
-    let arg_tys = ty::ty_fn_args(ctor_ty);
+    let arg_tys =
+        ty::erase_late_bound_regions(
+            ccx.tcx(), &ty::ty_fn_args(ctor_ty));
 
-    let arg_datums = create_datums_for_fn_args(&fcx, arg_tys[]);
+    let arg_datums = create_datums_for_fn_args(&fcx, arg_tys.index(&FullRange));
 
     if !type_is_zero_size(fcx.ccx, result_ty.unwrap()) {
         let dest = fcx.get_ret_slot(bcx, result_ty, "eret_slot");
@@ -2155,7 +2166,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span,
                             *lvlsrc.unwrap(), Some(sp),
                             format!("enum variant is more than three times larger \
                                      ({} bytes) than the next largest (ignoring padding)",
-                                    largest)[]);
+                                    largest).index(&FullRange));
 
         ccx.sess().span_note(enum_def.variants[largest_index].span,
                              "this variant is the largest");
@@ -2239,7 +2250,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[], "linkage") {
+            if let Some(name) = attr::first_attr_value_str_by_name(i.attrs.as_slice(), "linkage") {
                 if let Some(linkage) = llvm_linkage_by_name(name.get()) {
                     llvm::SetLinkage(llval, linkage);
                 } else {
@@ -2273,7 +2284,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
     match item.node {
       ast::ItemFn(ref decl, _fn_style, abi, ref generics, ref body) => {
         if !generics.is_type_parameterized() {
-            let trans_everywhere = attr::requests_inline(item.attrs[]);
+            let trans_everywhere = attr::requests_inline(item.attrs.index(&FullRange));
             // Ignore `trans_everywhere` for cross-crate inlined items
             // (`from_external`).  `trans_item` will be called once for each
             // compilation unit that references the item, so it will still get
@@ -2284,7 +2295,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
                     foreign::trans_rust_fn_with_foreign_abi(ccx,
                                                             &**decl,
                                                             &**body,
-                                                            item.attrs[],
+                                                            item.attrs.index(&FullRange),
                                                             llfn,
                                                             &Substs::trans_empty(),
                                                             item.id,
@@ -2296,7 +2307,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
                              llfn,
                              &Substs::trans_empty(),
                              item.id,
-                             item.attrs[]);
+                             item.attrs.index(&FullRange));
                 }
                 update_linkage(ccx,
                                llfn,
@@ -2313,7 +2324,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
       ast::ItemImpl(_, _, ref generics, _, _, ref impl_items) => {
         meth::trans_impl(ccx,
                          item.ident,
-                         impl_items[],
+                         impl_items.index(&FullRange),
                          generics,
                          item.id);
       }
@@ -2343,7 +2354,7 @@ pub fn trans_item(ccx: &CrateContext, item: &ast::Item) {
 
           // Do static_assert checking. It can't really be done much earlier
           // because we need to get the value of the bool out of LLVM
-          if attr::contains_name(item.attrs[], "static_assert") {
+          if attr::contains_name(item.attrs.index(&FullRange), "static_assert") {
               if m == ast::MutMutable {
                   ccx.sess().span_fatal(expr.span,
                                         "cannot have static_assert on a mutable \
@@ -2420,31 +2431,34 @@ fn register_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         _ => panic!("expected bare rust fn")
     };
 
-    let llfn = decl_rust_fn(ccx, node_type, sym[]);
+    let llfn = decl_rust_fn(ccx, node_type, sym.index(&FullRange));
     finish_register_fn(ccx, sp, sym, node_id, llfn);
     llfn
 }
 
 pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<'tcx>)
-                                        -> llvm::AttrBuilder {
+                                        -> llvm::AttrBuilder
+{
     use middle::ty::{BrAnon, ReLateBound};
 
+    let function_type;
     let (fn_sig, abi, has_env) = match fn_ty.sty {
-        ty::ty_bare_fn(_, ref f) => (f.sig.clone(), f.abi, false),
+        ty::ty_bare_fn(_, ref f) => (&f.sig, f.abi, false),
         ty::ty_unboxed_closure(closure_did, _, substs) => {
             let typer = common::NormalizingUnboxedClosureTyper::new(ccx.tcx());
-            let function_type = typer.unboxed_closure_type(closure_did, substs);
-            (function_type.sig, RustCall, true)
+            function_type = typer.unboxed_closure_type(closure_did, substs);
+            (&function_type.sig, RustCall, true)
         }
         _ => ccx.sess().bug("expected closure or function.")
     };
 
+    let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
 
     // Since index 0 is the return value of the llvm func, we start
     // at either 1 or 2 depending on whether there's an env slot or not
     let mut first_arg_offset = if has_env { 2 } else { 1 };
     let mut attrs = llvm::AttrBuilder::new();
-    let ret_ty = fn_sig.0.output;
+    let ret_ty = fn_sig.output;
 
     // These have an odd calling convention, so we need to manually
     // unpack the input ty's
@@ -2452,23 +2466,23 @@ pub fn get_fn_llvm_attributes<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, fn_ty: Ty<
         ty::ty_unboxed_closure(_, _, _) => {
             assert!(abi == RustCall);
 
-            match fn_sig.0.inputs[0].sty {
+            match fn_sig.inputs[0].sty {
                 ty::ty_tup(ref inputs) => inputs.clone(),
                 _ => ccx.sess().bug("expected tuple'd inputs")
             }
         },
         ty::ty_bare_fn(..) if abi == RustCall => {
-            let mut inputs = vec![fn_sig.0.inputs[0]];
+            let mut inputs = vec![fn_sig.inputs[0]];
 
-            match fn_sig.0.inputs[1].sty {
+            match fn_sig.inputs[1].sty {
                 ty::ty_tup(ref t_in) => {
-                    inputs.push_all(t_in[]);
+                    inputs.push_all(t_in.index(&FullRange));
                     inputs
                 }
                 _ => ccx.sess().bug("expected tuple'd inputs")
             }
         }
-        _ => fn_sig.0.inputs.clone()
+        _ => fn_sig.inputs.clone()
     };
 
     if let ty::FnConverging(ret_ty) = ret_ty {
@@ -2597,7 +2611,11 @@ pub fn register_fn_llvmty(ccx: &CrateContext,
                           llfty: Type) -> ValueRef {
     debug!("register_fn_llvmty id={} sym={}", node_id, sym);
 
-    let llfn = decl_fn(ccx, sym[], cc, llfty, ty::FnConverging(ty::mk_nil(ccx.tcx())));
+    let llfn = decl_fn(ccx,
+                       sym.index(&FullRange),
+                       cc,
+                       llfty,
+                       ty::FnConverging(ty::mk_nil(ccx.tcx())));
     finish_register_fn(ccx, sp, sym, node_id, llfn);
     llfn
 }
@@ -2650,7 +2668,7 @@ fn create_entry_fn(ccx: &CrateContext,
             let (start_fn, args) = if use_start_lang_item {
                 let start_def_id = match ccx.tcx().lang_items.require(StartFnLangItem) {
                     Ok(id) => id,
-                    Err(s) => { ccx.sess().fatal(s[]); }
+                    Err(s) => { ccx.sess().fatal(s.index(&FullRange)); }
                 };
                 let start_fn = if start_def_id.krate == ast::LOCAL_CRATE {
                     get_item_val(ccx, start_def_id.node)
@@ -2738,11 +2756,11 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
     }
 
     let item = ccx.tcx().map.get(id);
-    debug!("get_item_val: id={} item={}", id, item);
+    debug!("get_item_val: id={} item={:?}", id, item);
     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.index(&FullRange));
 
             let v = match i.node {
                 ast::ItemStatic(_, _, ref expr) => {
@@ -2765,16 +2783,16 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
                         } else {
                             llvm::LLVMTypeOf(v)
                         };
-                        if contains_null(sym[]) {
+                        if contains_null(sym.index(&FullRange)) {
                             ccx.sess().fatal(
                                 format!("Illegal null byte in export_name \
-                                         value: `{}`", sym)[]);
+                                         value: `{}`", sym).index(&FullRange));
                         }
                         let buf = CString::from_slice(sym.as_bytes());
                         let g = llvm::LLVMAddGlobal(ccx.llmod(), llty,
                                                     buf.as_ptr());
 
-                        if attr::contains_name(i.attrs[],
+                        if attr::contains_name(i.attrs.index(&FullRange),
                                                "thread_local") {
                             llvm::set_thread_local(g, true);
                         }
@@ -2799,19 +2817,19 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
                                                                    sym,
                                                                    i.id)
                     };
-                    set_llvm_fn_attrs(ccx, i.attrs[], llfn);
+                    set_llvm_fn_attrs(ccx, i.attrs.index(&FullRange), llfn);
                     llfn
                 }
 
                 _ => panic!("get_item_val: weird result in table")
             };
 
-            match attr::first_attr_value_str_by_name(i.attrs[],
+            match attr::first_attr_value_str_by_name(i.attrs.index(&FullRange),
                                                      "link_section") {
                 Some(sect) => {
                     if contains_null(sect.get()) {
                         ccx.sess().fatal(format!("Illegal null byte in link_section value: `{}`",
-                                                 sect.get())[]);
+                                                 sect.get()).index(&FullRange));
                     }
                     unsafe {
                         let buf = CString::from_slice(sect.get().as_bytes());
@@ -2854,7 +2872,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
                     let abi = ccx.tcx().map.get_foreign_abi(id);
                     let ty = ty::node_id_to_type(ccx.tcx(), ni.id);
                     let name = foreign::link_name(&*ni);
-                    foreign::register_foreign_item_fn(ccx, abi, ty, name.get()[])
+                    foreign::register_foreign_item_fn(ccx, abi, ty, name.get().index(&FullRange))
                 }
                 ast::ForeignItemStatic(..) => {
                     foreign::register_static(ccx, &*ni)
@@ -2877,7 +2895,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
             let sym = exported_name(ccx,
                                     id,
                                     ty,
-                                    enm.attrs[]);
+                                    enm.attrs.index(&FullRange));
 
             llfn = match enm.node {
                 ast::ItemEnum(_, _) => {
@@ -2905,7 +2923,7 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
                                     id,
                                     ty,
                                     struct_item.attrs
-                                               []);
+                                               .index(&FullRange));
             let llfn = register_fn(ccx, struct_item.span,
                                    sym, ctor_id, ty);
             set_inline_hint(llfn);
@@ -2913,8 +2931,8 @@ pub fn get_item_val(ccx: &CrateContext, id: ast::NodeId) -> ValueRef {
         }
 
         ref variant => {
-            ccx.sess().bug(format!("get_item_val(): unexpected variant: {}",
-                                   variant)[])
+            ccx.sess().bug(format!("get_item_val(): unexpected variant: {:?}",
+                                   variant).index(&FullRange))
         }
     };
 
@@ -2935,10 +2953,10 @@ fn register_method(ccx: &CrateContext, id: ast::NodeId,
                    m: &ast::Method) -> ValueRef {
     let mty = ty::node_id_to_type(ccx.tcx(), id);
 
-    let sym = exported_name(ccx, id, mty, m.attrs[]);
+    let sym = exported_name(ccx, id, mty, m.attrs.index(&FullRange));
 
     let llfn = register_fn(ccx, m.span, sym, id, mty);
-    set_llvm_fn_attrs(ccx, m.attrs[], llfn);
+    set_llvm_fn_attrs(ccx, m.attrs.index(&FullRange), llfn);
     llfn
 }
 
@@ -2977,7 +2995,7 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec<u8> {
         Some(compressed) => compressed,
         None => cx.sess().fatal("failed to compress metadata"),
     }.as_slice());
-    let llmeta = C_bytes_in_context(cx.metadata_llcx(), compressed[]);
+    let llmeta = C_bytes_in_context(cx.metadata_llcx(), compressed.index(&FullRange));
     let llconst = C_struct_in_context(cx.metadata_llcx(), &[llmeta], false);
     let name = format!("rust_metadata_{}_{}",
                        cx.link_meta().crate_name,
@@ -3106,7 +3124,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
     let link_meta = link::build_link_meta(&tcx.sess, krate, name);
 
     let codegen_units = tcx.sess.opts.cg.codegen_units;
-    let shared_ccx = SharedCrateContext::new(link_meta.crate_name[],
+    let shared_ccx = SharedCrateContext::new(link_meta.crate_name.index(&FullRange),
                                              codegen_units,
                                              tcx,
                                              export_map,
@@ -3208,7 +3226,7 @@ pub fn trans_crate<'tcx>(analysis: ty::CrateAnalysis<'tcx>)
         llmod: shared_ccx.metadata_llmod(),
     };
     let formats = shared_ccx.tcx().dependency_formats.borrow().clone();
-    let no_builtins = attr::contains_name(krate.attrs[], "no_builtins");
+    let no_builtins = attr::contains_name(krate.attrs.index(&FullRange), "no_builtins");
 
     let translation = CrateTranslation {
         modules: modules,
index e09d36ddae923188be8407e9942c2aac077713ec..d0eaf799af1bd04a41103f123cbce80eb5311acb 100644 (file)
@@ -552,11 +552,11 @@ pub fn gepi(&self, base: ValueRef, ixs: &[uint]) -> ValueRef {
             for (small_vec_e, &ix) in small_vec.iter_mut().zip(ixs.iter()) {
                 *small_vec_e = C_i32(self.ccx, ix as i32);
             }
-            self.inbounds_gep(base, small_vec[..ixs.len()])
+            self.inbounds_gep(base, small_vec.index(&(0..ixs.len())))
         } else {
             let v = ixs.iter().map(|i| C_i32(self.ccx, *i as i32)).collect::<Vec<ValueRef>>();
             self.count_insn("gepi");
-            self.inbounds_gep(base, v[])
+            self.inbounds_gep(base, v.index(&FullRange))
         }
     }
 
@@ -764,8 +764,8 @@ pub fn add_span_comment(&self, sp: Span, text: &str) {
             let s = format!("{} ({})",
                             text,
                             self.ccx.sess().codemap().span_to_string(sp));
-            debug!("{}", s[]);
-            self.add_comment(s[]);
+            debug!("{}", s.index(&FullRange));
+            self.add_comment(s.index(&FullRange));
         }
     }
 
@@ -802,7 +802,7 @@ pub fn inline_asm_call(&self, asm: *const c_char, cons: *const c_char,
         }).collect::<Vec<_>>();
 
         debug!("Asm Output Type: {}", self.ccx.tn().type_to_string(output));
-        let fty = Type::func(argtys[], &output);
+        let fty = Type::func(argtys.index(&FullRange), &output);
         unsafe {
             let v = llvm::LLVMInlineAsm(
                 fty.to_ref(), asm, cons, volatile, alignstack, dia as c_uint);
index 0e38dd0e5b5967d424a7b7ffc2253835b9db1b73..a901142467b8debfa535b1133190ca84d962fd34 100644 (file)
@@ -108,7 +108,7 @@ pub fn compute_abi_info(ccx: &CrateContext,
                         atys: &[Type],
                         rty: Type,
                         ret_def: bool) -> FnType {
-    match ccx.sess().target.target.arch[] {
+    match ccx.sess().target.target.arch.index(&FullRange) {
         "x86" => cabi_x86::compute_abi_info(ccx, atys, rty, ret_def),
         "x86_64" => if ccx.sess().target.target.options.is_like_windows {
             cabi_x86_win64::compute_abi_info(ccx, atys, rty, ret_def)
@@ -119,6 +119,6 @@ pub fn compute_abi_info(ccx: &CrateContext,
         "aarch64" => cabi_aarch64::compute_abi_info(ccx, atys, rty, ret_def),
         "mips" => cabi_mips::compute_abi_info(ccx, atys, rty, ret_def),
         a => ccx.sess().fatal((format!("unrecognized arch \"{}\" in target specification", a))
-                              []),
+                              .index(&FullRange)),
     }
 }
index 9ec0c822bf5fe4acc92a27aaddf00194d08d8a1d..f40072d1cba3eb33597ecba6aa76da7ebdefe023 100644 (file)
@@ -318,7 +318,7 @@ fn llvec_len(cls: &[RegClass]) -> uint {
                 tys.push(Type::i64(ccx));
             }
             SSEFv => {
-                let vec_len = llvec_len(cls[i + 1u..]);
+                let vec_len = llvec_len(cls.index(&((i + 1u)..)));
                 let vec_ty = Type::vector(&Type::f32(ccx), (vec_len * 2u) as u64);
                 tys.push(vec_ty);
                 i += vec_len;
index 65e6d7e1924b6050f8625c466203fb433a523c5e..b7b486f1d0a52239b329a29560259afd30f818c5 100644 (file)
@@ -114,7 +114,7 @@ fn datum_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, expr: &ast::Expr)
                     expr.span,
                     format!("type of callee is neither bare-fn nor closure: \
                              {}",
-                            bcx.ty_to_string(datum.ty))[]);
+                            bcx.ty_to_string(datum.ty)).index(&FullRange));
             }
         }
     }
@@ -206,8 +206,8 @@ fn trans_def<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             def::DefSelfTy(..) | def::DefAssociatedPath(..) => {
                 bcx.tcx().sess.span_bug(
                     ref_expr.span,
-                    format!("cannot translate def {} \
-                             to a callable thing!", def)[]);
+                    format!("cannot translate def {:?} \
+                             to a callable thing!", def).index(&FullRange));
             }
         }
     }
@@ -223,7 +223,7 @@ pub fn trans_fn_ref<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     let _icx = push_ctxt("trans_fn_ref");
 
     let substs = node_id_substs(ccx, node, param_substs);
-    debug!("trans_fn_ref(def_id={}, node={}, substs={})",
+    debug!("trans_fn_ref(def_id={}, node={:?}, substs={})",
            def_id.repr(ccx.tcx()),
            node,
            substs.repr(ccx.tcx()));
@@ -265,7 +265,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
     let _icx = push_ctxt("trans_fn_pointer_shim");
     let tcx = ccx.tcx();
 
-    let bare_fn_ty = ty::normalize_ty(tcx, bare_fn_ty);
+    let bare_fn_ty = normalize_ty(tcx, bare_fn_ty);
     match ccx.fn_pointer_shims().borrow().get(&bare_fn_ty) {
         Some(&llval) => { return llval; }
         None => { }
@@ -279,24 +279,22 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
 
     // Construct the "tuply" version of `bare_fn_ty`. It takes two arguments: `self`,
     // which is the fn pointer, and `args`, which is the arguments tuple.
-    let (opt_def_id, input_tys, output_ty) =
+    let (opt_def_id, sig) =
         match bare_fn_ty.sty {
             ty::ty_bare_fn(opt_def_id,
                            &ty::BareFnTy { unsafety: ast::Unsafety::Normal,
-                                          abi: synabi::Rust,
-                                          sig: ty::Binder(ty::FnSig { inputs: ref input_tys,
-                                                                      output: output_ty,
-                                                                      variadic: false })}) =>
-            {
-                (opt_def_id, input_tys, output_ty)
+                                           abi: synabi::Rust,
+                                           ref sig }) => {
+                (opt_def_id, sig)
             }
 
             _ => {
                 tcx.sess.bug(format!("trans_fn_pointer_shim invoked on invalid type: {}",
-                                           bare_fn_ty.repr(tcx))[]);
+                                           bare_fn_ty.repr(tcx)).index(&FullRange));
             }
         };
-    let tuple_input_ty = ty::mk_tup(tcx, input_tys.to_vec());
+    let sig = ty::erase_late_bound_regions(tcx, sig);
+    let tuple_input_ty = ty::mk_tup(tcx, sig.inputs.to_vec());
     let tuple_fn_ty = ty::mk_bare_fn(tcx,
                                      opt_def_id,
                                      tcx.mk_bare_fn(ty::BareFnTy {
@@ -305,7 +303,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
                                          sig: ty::Binder(ty::FnSig {
                                              inputs: vec![bare_fn_ty_ref,
                                                           tuple_input_ty],
-                                             output: output_ty,
+                                             output: sig.output,
                                              variadic: false
                                          })}));
     debug!("tuple_fn_ty: {}", tuple_fn_ty.repr(tcx));
@@ -317,7 +315,7 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
     let llfn =
         decl_internal_rust_fn(ccx,
                               tuple_fn_ty,
-                              function_name[]);
+                              function_name.index(&FullRange));
 
     //
     let block_arena = TypedArena::new();
@@ -326,11 +324,11 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
                           llfn,
                           ast::DUMMY_NODE_ID,
                           false,
-                          output_ty,
+                          sig.output,
                           &empty_substs,
                           None,
                           &block_arena);
-    let mut bcx = init_function(&fcx, false, output_ty);
+    let mut bcx = init_function(&fcx, false, sig.output);
 
     // the first argument (`self`) will be ptr to the the fn pointer
     let llfnpointer =
@@ -338,24 +336,24 @@ pub fn trans_fn_pointer_shim<'a, 'tcx>(
 
     // the remaining arguments will be the untupled values
     let llargs: Vec<_> =
-        input_tys.iter()
+        sig.inputs.iter()
         .enumerate()
         .map(|(i, _)| get_param(fcx.llfn, fcx.arg_pos(i+1) as u32))
         .collect();
     assert!(!fcx.needs_ret_allocas);
 
     let dest = fcx.llretslotptr.get().map(|_|
-        expr::SaveIn(fcx.get_ret_slot(bcx, output_ty, "ret_slot"))
+        expr::SaveIn(fcx.get_ret_slot(bcx, sig.output, "ret_slot"))
     );
 
     bcx = trans_call_inner(bcx,
                            None,
                            bare_fn_ty,
                            |bcx, _| Callee { bcx: bcx, data: Fn(llfnpointer) },
-                           ArgVals(llargs[]),
+                           ArgVals(llargs.index(&FullRange)),
                            dest).bcx;
 
-    finish_fn(&fcx, bcx, output_ty);
+    finish_fn(&fcx, bcx, sig.output);
 
     ccx.fn_pointer_shims().borrow_mut().insert(bare_fn_ty, llfn);
 
@@ -386,7 +384,7 @@ pub fn trans_fn_ref_with_substs<'a, 'tcx>(
     let _icx = push_ctxt("trans_fn_ref_with_substs");
     let tcx = ccx.tcx();
 
-    debug!("trans_fn_ref_with_substs(def_id={}, node={}, \
+    debug!("trans_fn_ref_with_substs(def_id={}, node={:?}, \
             param_substs={}, substs={})",
            def_id.repr(tcx),
            node,
@@ -668,7 +666,10 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
     let mut bcx = callee.bcx;
 
     let (abi, ret_ty) = match callee_ty.sty {
-        ty::ty_bare_fn(_, ref f) => (f.abi, f.sig.0.output),
+        ty::ty_bare_fn(_, ref f) => {
+            let output = ty::erase_late_bound_regions(bcx.tcx(), &f.sig.output());
+            (f.abi, output)
+        }
         _ => panic!("expected bare rust fn or closure in trans_call_inner")
     };
 
@@ -775,7 +776,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
         // Invoke the actual rust fn and update bcx/llresult.
         let (llret, b) = base::invoke(bcx,
                                       llfn,
-                                      llargs[],
+                                      llargs.index(&FullRange),
                                       callee_ty,
                                       call_info);
         bcx = b;
@@ -814,7 +815,7 @@ pub fn trans_call_inner<'a, 'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
 
         bcx = foreign::trans_native_call(bcx, callee_ty,
                                          llfn, opt_llretslot.unwrap(),
-                                         llargs[], arg_tys);
+                                         llargs.index(&FullRange), arg_tys);
     }
 
     fcx.pop_and_trans_custom_cleanup_scope(bcx, arg_cleanup_scope);
@@ -865,13 +866,18 @@ fn trans_args_under_call_abi<'blk, 'tcx>(
                              llargs: &mut Vec<ValueRef>,
                              arg_cleanup_scope: cleanup::ScopeId,
                              ignore_self: bool)
-                             -> Block<'blk, 'tcx> {
+                             -> Block<'blk, 'tcx>
+{
+    let args =
+        ty::erase_late_bound_regions(
+            bcx.tcx(), &ty::ty_fn_args(fn_ty));
+
     // Translate the `self` argument first.
     if !ignore_self {
         let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &*arg_exprs[0]));
         llargs.push(unpack_result!(bcx, {
             trans_arg_datum(bcx,
-                            ty::ty_fn_args(fn_ty)[0],
+                            args[0],
                             arg_datum,
                             arg_cleanup_scope,
                             DontAutorefArg)
@@ -926,7 +932,7 @@ fn trans_overloaded_call_args<'blk, 'tcx>(
                               ignore_self: bool)
                               -> Block<'blk, 'tcx> {
     // Translate the `self` argument first.
-    let arg_tys = ty::ty_fn_args(fn_ty);
+    let arg_tys = ty::erase_late_bound_regions(bcx.tcx(),  &ty::ty_fn_args(fn_ty));
     if !ignore_self {
         let arg_datum = unpack_datum!(bcx, expr::trans(bcx, arg_exprs[0]));
         llargs.push(unpack_result!(bcx, {
@@ -974,7 +980,7 @@ pub fn trans_args<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>,
     debug!("trans_args(abi={})", abi);
 
     let _icx = push_ctxt("trans_args");
-    let arg_tys = ty::ty_fn_args(fn_ty);
+    let arg_tys = ty::erase_late_bound_regions(cx.tcx(), &ty::ty_fn_args(fn_ty));
     let variadic = ty::fn_is_variadic(fn_ty);
 
     let mut bcx = cx;
index 79a5898e3d33ea2db7e3aaefd46ac2eee6b0b2e6..92a96cd02b501c67f64af211a42772724a82e2ea 100644 (file)
@@ -24,8 +24,7 @@
 use trans::common::{Block, FunctionContext, ExprId, NodeInfo};
 use trans::debuginfo;
 use trans::glue;
-// Temporary due to slicing syntax hacks (KILLME)
-//use middle::region;
+use middle::region;
 use trans::type_::Type;
 use middle::ty::{self, Ty};
 use std::fmt;
@@ -129,8 +128,7 @@ fn push_ast_cleanup_scope(&self, debug_loc: NodeInfo) {
         // excluding id's that correspond to closure bodies only). For
         // now we just say that if there is already an AST scope on the stack,
         // this new AST scope had better be its immediate child.
-        // Temporarily removed due to slicing syntax hacks (KILLME).
-        /*let top_scope = self.top_ast_scope();
+        let top_scope = self.top_ast_scope();
         if top_scope.is_some() {
             assert_eq!(self.ccx
                            .tcx()
@@ -138,7 +136,7 @@ fn push_ast_cleanup_scope(&self, debug_loc: NodeInfo) {
                            .opt_encl_scope(region::CodeExtent::from_node_id(debug_loc.id))
                            .map(|s|s.node_id()),
                        top_scope);
-        }*/
+        }
 
         self.push_scope(CleanupScope::new(AstScopeKind(debug_loc.id),
                                           Some(debug_loc)));
@@ -229,7 +227,7 @@ fn pop_and_trans_custom_cleanup_scope(&self,
                                           bcx: Block<'blk, 'tcx>,
                                           custom_scope: CustomScopeIndex)
                                           -> Block<'blk, 'tcx> {
-        debug!("pop_and_trans_custom_cleanup_scope({})", custom_scope);
+        debug!("pop_and_trans_custom_cleanup_scope({:?})", custom_scope);
         assert!(self.is_valid_to_pop_custom_scope(custom_scope));
 
         let scope = self.pop_scope();
@@ -267,7 +265,7 @@ fn schedule_lifetime_end(&self,
             ptr: val,
         };
 
-        debug!("schedule_lifetime_end({}, val={})",
+        debug!("schedule_lifetime_end({:?}, val={})",
                cleanup_scope,
                self.ccx.tn().val_to_string(val));
 
@@ -288,7 +286,7 @@ fn schedule_drop_mem(&self,
             zero: false
         };
 
-        debug!("schedule_drop_mem({}, val={}, ty={})",
+        debug!("schedule_drop_mem({:?}, val={}, ty={})",
                cleanup_scope,
                self.ccx.tn().val_to_string(val),
                ty.repr(self.ccx.tcx()));
@@ -310,7 +308,7 @@ fn schedule_drop_and_zero_mem(&self,
             zero: true
         };
 
-        debug!("schedule_drop_and_zero_mem({}, val={}, ty={}, zero={})",
+        debug!("schedule_drop_and_zero_mem({:?}, val={}, ty={}, zero={})",
                cleanup_scope,
                self.ccx.tn().val_to_string(val),
                ty.repr(self.ccx.tcx()),
@@ -334,7 +332,7 @@ fn schedule_drop_immediate(&self,
             zero: false
         };
 
-        debug!("schedule_drop_immediate({}, val={}, ty={})",
+        debug!("schedule_drop_immediate({:?}, val={}, ty={:?})",
                cleanup_scope,
                self.ccx.tn().val_to_string(val),
                ty.repr(self.ccx.tcx()));
@@ -350,7 +348,7 @@ fn schedule_free_value(&self,
                            content_ty: Ty<'tcx>) {
         let drop = box FreeValue { ptr: val, heap: heap, content_ty: content_ty };
 
-        debug!("schedule_free_value({}, val={}, heap={})",
+        debug!("schedule_free_value({:?}, val={}, heap={:?})",
                cleanup_scope,
                self.ccx.tn().val_to_string(val),
                heap);
@@ -367,7 +365,7 @@ fn schedule_free_slice(&self,
                            heap: Heap) {
         let drop = box FreeSlice { ptr: val, size: size, align: align, heap: heap };
 
-        debug!("schedule_free_slice({}, val={}, heap={})",
+        debug!("schedule_free_slice({:?}, val={}, heap={:?})",
                cleanup_scope,
                self.ccx.tn().val_to_string(val),
                heap);
@@ -406,7 +404,7 @@ fn schedule_clean_in_ast_scope(&self,
 
         self.ccx.sess().bug(
             format!("no cleanup scope {} found",
-                    self.ccx.tcx().map.node_to_string(cleanup_scope))[]);
+                    self.ccx.tcx().map.node_to_string(cleanup_scope)).index(&FullRange));
     }
 
     /// Schedules a cleanup to occur in the top-most scope, which must be a temporary scope.
@@ -551,7 +549,7 @@ fn top_scope<R, F>(&self, f: F) -> R where F: FnOnce(&CleanupScope<'blk, 'tcx>)
     fn trans_cleanups_to_exit_scope(&'blk self,
                                     label: EarlyExitLabel)
                                     -> BasicBlockRef {
-        debug!("trans_cleanups_to_exit_scope label={} scopes={}",
+        debug!("trans_cleanups_to_exit_scope label={:?} scopes={}",
                label, self.scopes_len());
 
         let orig_scopes_len = self.scopes_len();
@@ -588,7 +586,7 @@ fn trans_cleanups_to_exit_scope(&'blk self,
                     LoopExit(id, _) => {
                         self.ccx.sess().bug(format!(
                                 "cannot exit from scope {}, \
-                                not in scope", id)[]);
+                                not in scope", id).index(&FullRange));
                     }
                 }
             }
@@ -657,7 +655,7 @@ fn trans_cleanups_to_exit_scope(&'blk self,
                 let name = scope.block_name("clean");
                 debug!("generating cleanups for {}", name);
                 let bcx_in = self.new_block(label.is_unwind(),
-                                            name[],
+                                            name.index(&FullRange),
                                             None);
                 let mut bcx_out = bcx_in;
                 for cleanup in scope.cleanups.iter().rev() {
@@ -677,7 +675,7 @@ fn trans_cleanups_to_exit_scope(&'blk self,
             self.push_scope(scope);
         }
 
-        debug!("trans_cleanups_to_exit_scope: prev_llbb={}", prev_llbb);
+        debug!("trans_cleanups_to_exit_scope: prev_llbb={:?}", prev_llbb);
 
         assert_eq!(self.scopes_len(), orig_scopes_len);
         prev_llbb
@@ -704,7 +702,7 @@ fn get_or_create_landing_pad(&'blk self) -> BasicBlockRef {
                 Some(llbb) => { return llbb; }
                 None => {
                     let name = last_scope.block_name("unwind");
-                    pad_bcx = self.new_block(true, name[], None);
+                    pad_bcx = self.new_block(true, name.index(&FullRange), None);
                     last_scope.cached_landing_pad = Some(pad_bcx.llbb);
                 }
             }
@@ -1020,12 +1018,12 @@ pub fn temporary_scope(tcx: &ty::ctxt,
     match tcx.region_maps.temporary_scope(id) {
         Some(scope) => {
             let r = AstScope(scope.node_id());
-            debug!("temporary_scope({}) = {}", id, r);
+            debug!("temporary_scope({}) = {:?}", id, r);
             r
         }
         None => {
             tcx.sess.bug(format!("no temporary scope available for expr {}",
-                                 id)[])
+                                 id).index(&FullRange))
         }
     }
 }
@@ -1034,7 +1032,7 @@ pub fn var_scope(tcx: &ty::ctxt,
                  id: ast::NodeId)
                  -> ScopeId {
     let r = AstScope(tcx.region_maps.var_scope(id).node_id());
-    debug!("var_scope({}) = {}", id, r);
+    debug!("var_scope({}) = {:?}", id, r);
     r
 }
 
index 6f2def16e7674f867c14e673cc2cb0fdc40269cf..ad2ed67b22c9a315bf4ed3be04e80ce014076da3 100644 (file)
@@ -108,7 +108,7 @@ pub struct EnvValue<'tcx> {
 
 impl<'tcx> EnvValue<'tcx> {
     pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
-        format!("{}({})", self.action, self.datum.to_string(ccx))
+        format!("{:?}({})", self.action, self.datum.to_string(ccx))
     }
 }
 
@@ -154,7 +154,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let tcx = ccx.tcx();
 
     // compute the type of the closure
-    let cdata_ty = mk_closure_tys(tcx, bound_values[]);
+    let cdata_ty = mk_closure_tys(tcx, bound_values.index(&FullRange));
 
     // cbox_ty has the form of a tuple: (a, b, c) we want a ptr to a
     // tuple.  This could be a ptr in uniq or a box or on stack,
@@ -183,7 +183,7 @@ pub fn store_environment<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
         if ccx.sess().asm_comments() {
             add_comment(bcx, format!("Copy {} into closure",
-                                     bv.to_string(ccx))[]);
+                                     bv.to_string(ccx)).index(&FullRange));
         }
 
         let bound_data = GEPi(bcx, llbox, &[0u, abi::BOX_FIELD_BODY, i]);
@@ -420,7 +420,7 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let s = tcx.map.with_path(id, |path| {
         mangle_internal_name_by_path_and_seq(path, "closure")
     });
-    let llfn = decl_internal_rust_fn(ccx, fty, s[]);
+    let llfn = decl_internal_rust_fn(ccx, fty, s.index(&FullRange));
 
     // set an inline hint for all closures
     set_inline_hint(llfn);
@@ -442,9 +442,9 @@ pub fn trans_expr_fn<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                   bcx.fcx.param_substs,
                   id,
                   &[],
-                  ty::ty_fn_ret(fty),
+                  ty::erase_late_bound_regions(ccx.tcx(), &ty::ty_fn_ret(fty)),
                   ty::ty_fn_abi(fty),
-                  ClosureEnv::new(freevars[],
+                  ClosureEnv::new(freevars.index(&FullRange),
                                   BoxedClosure(cdata_ty, store)));
     fill_fn_pair(bcx, dest_addr, llfn, llbox);
     bcx
@@ -466,7 +466,7 @@ pub fn get_or_create_declaration_if_unboxed_closure<'a, 'tcx>(ccx: &CrateContext
 
     // Normalize type so differences in regions and typedefs don't cause
     // duplicate declarations
-    let function_type = ty::normalize_ty(ccx.tcx(), function_type);
+    let function_type = normalize_ty(ccx.tcx(), function_type);
     let params = match function_type.sty {
         ty::ty_unboxed_closure(_, _, ref substs) => substs.types.clone(),
         _ => unreachable!()
@@ -489,13 +489,13 @@ pub fn get_or_create_declaration_if_unboxed_closure<'a, 'tcx>(ccx: &CrateContext
         mangle_internal_name_by_path_and_seq(path, "unboxed_closure")
     });
 
-    let llfn = decl_internal_rust_fn(ccx, function_type, symbol[]);
+    let llfn = decl_internal_rust_fn(ccx, function_type, symbol.index(&FullRange));
 
     // set an inline hint for all closures
     set_inline_hint(llfn);
 
     debug!("get_or_create_declaration_if_unboxed_closure(): inserting new \
-            closure {} (type {})",
+            closure {:?} (type {})",
            mono_id,
            ccx.tn().type_to_string(val_ty(llfn)));
     ccx.unboxed_closure_vals().borrow_mut().insert(mono_id, llfn);
@@ -533,6 +533,8 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
         ty::with_freevars(bcx.tcx(), id, |fv| fv.iter().map(|&fv| fv).collect());
     let freevar_mode = bcx.tcx().capture_mode(id);
 
+    let sig = ty::erase_late_bound_regions(bcx.tcx(), &function_type.sig);
+
     trans_closure(bcx.ccx(),
                   decl,
                   body,
@@ -540,9 +542,9 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
                   bcx.fcx.param_substs,
                   id,
                   &[],
-                  function_type.sig.0.output,
+                  sig.output,
                   function_type.abi,
-                  ClosureEnv::new(freevars[],
+                  ClosureEnv::new(freevars.index(&FullRange),
                                   UnboxedClosure(freevar_mode)));
 
     // Don't hoist this to the top of the function. It's perfectly legitimate
@@ -579,3 +581,4 @@ pub fn trans_unboxed_closure<'blk, 'tcx>(
 
     bcx
 }
+
index 094f98e988aad202fda3fc3e9535f62c1a3cdcaa..237fc1856369b7306e025ce9a89ff83075918542 100644 (file)
 
 pub use trans::context::CrateContext;
 
+/// Returns an equivalent type with all the typedefs and self regions removed.
+pub fn normalize_ty<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
+    let u = TypeNormalizer(cx).fold_ty(ty);
+    debug!("normalize_ty({}) = {}",
+           ty.repr(cx), u.repr(cx));
+    return u;
+
+    struct TypeNormalizer<'a, 'tcx: 'a>(&'a ty::ctxt<'tcx>);
+
+    impl<'a, 'tcx> TypeFolder<'tcx> for TypeNormalizer<'a, 'tcx> {
+        fn tcx(&self) -> &ty::ctxt<'tcx> { self.0 }
+
+        fn fold_ty(&mut self, ty: Ty<'tcx>) -> Ty<'tcx> {
+            match self.tcx().normalized_cache.borrow().get(&ty).cloned() {
+                None => {}
+                Some(u) => return u
+            }
+
+            let t_norm = ty_fold::super_fold_ty(self, ty);
+            self.tcx().normalized_cache.borrow_mut().insert(ty, t_norm);
+            return t_norm;
+        }
+
+        fn fold_binder<T>(&mut self, t: &ty::Binder<T>) -> ty::Binder<T>
+            where T : TypeFoldable<'tcx> + Repr<'tcx>
+        {
+            // FIXME(#20526) this should replace `enter_region_binder`/`exit_region_binder`.
+            let u = ty::anonymize_late_bound_regions(self.tcx(), t);
+            ty_fold::super_fold_binder(self, &u)
+        }
+
+        fn fold_region(&mut self, r: ty::Region) -> ty::Region {
+            // because late-bound regions affect subtyping, we can't
+            // erase the bound/free distinction, but we can replace
+            // all free regions with 'static.
+            //
+            // Note that we *CAN* replace early-bound regions -- the
+            // type system never "sees" those, they get substituted
+            // away. In trans, they will always be erased to 'static
+            // whenever a substitution occurs.
+            match r {
+                ty::ReLateBound(..) => r,
+                _ => ty::ReStatic
+            }
+        }
+
+        fn fold_substs(&mut self,
+                       substs: &subst::Substs<'tcx>)
+                       -> subst::Substs<'tcx> {
+            subst::Substs { regions: subst::ErasedRegions,
+                            types: substs.types.fold_with(self) }
+        }
+    }
+}
+
 // Is the type's representation size known at compile time?
 pub fn type_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
-    ty::type_contents(cx, ty).is_sized(cx)
+ty::type_contents(cx, ty).is_sized(cx)
 }
 
 pub fn lltype_is_sized<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
-    match ty.sty {
-        ty::ty_open(_) => true,
-        _ => type_is_sized(cx, ty),
-    }
+match ty.sty {
+    ty::ty_open(_) => true,
+    _ => type_is_sized(cx, ty),
+}
 }
 
 pub fn type_is_fat_ptr<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> bool {
-    match ty.sty {
-        ty::ty_ptr(ty::mt{ty, ..}) |
-        ty::ty_rptr(_, ty::mt{ty, ..}) |
-        ty::ty_uniq(ty) => {
-            !type_is_sized(cx, ty)
-        }
-        _ => {
-            false
-        }
+match ty.sty {
+    ty::ty_ptr(ty::mt{ty, ..}) |
+    ty::ty_rptr(_, ty::mt{ty, ..}) |
+    ty::ty_uniq(ty) => {
+        !type_is_sized(cx, ty)
     }
+    _ => {
+        false
+    }
+}
 }
 
 // Return the smallest part of `ty` which is unsized. Fails if `ty` is sized.
 // 'Smallest' here means component of the static representation of the type; not
 // the size of an object at runtime.
 pub fn unsized_part_of_type<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx> {
-    match ty.sty {
-        ty::ty_str | ty::ty_trait(..) | ty::ty_vec(..) => ty,
-        ty::ty_struct(def_id, substs) => {
-            let unsized_fields: Vec<_> =
-                ty::struct_fields(cx, def_id, substs)
-                .iter()
-                .map(|f| f.mt.ty)
-                .filter(|ty| !type_is_sized(cx, *ty))
-                .collect();
-
-            // Exactly one of the fields must be unsized.
-            assert!(unsized_fields.len() == 1);
-
-            unsized_part_of_type(cx, unsized_fields[0])
-        }
-        _ => {
-            assert!(type_is_sized(cx, ty),
-                    "unsized_part_of_type failed even though ty is unsized");
-            panic!("called unsized_part_of_type with sized ty");
-        }
+match ty.sty {
+    ty::ty_str | ty::ty_trait(..) | ty::ty_vec(..) => ty,
+    ty::ty_struct(def_id, substs) => {
+        let unsized_fields: Vec<_> =
+            ty::struct_fields(cx, def_id, substs)
+            .iter()
+            .map(|f| f.mt.ty)
+            .filter(|ty| !type_is_sized(cx, *ty))
+            .collect();
+
+        // Exactly one of the fields must be unsized.
+        assert!(unsized_fields.len() == 1);
+
+        unsized_part_of_type(cx, unsized_fields[0])
     }
+    _ => {
+        assert!(type_is_sized(cx, ty),
+                "unsized_part_of_type failed even though ty is unsized");
+        panic!("called unsized_part_of_type with sized ty");
+    }
+}
 }
 
 // Some things don't need cleanups during unwinding because the
@@ -115,93 +170,93 @@ pub fn unsized_part_of_type<'tcx>(cx: &ty::ctxt<'tcx>, ty: Ty<'tcx>) -> Ty<'tcx>
 // that only contain scalars and shared boxes can avoid unwind
 // cleanups.
 pub fn type_needs_unwind_cleanup<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
-    return memoized(ccx.needs_unwind_cleanup_cache(), ty, |ty| {
-        type_needs_unwind_cleanup_(ccx.tcx(), ty, &mut FnvHashSet::new())
-    });
+return memoized(ccx.needs_unwind_cleanup_cache(), ty, |ty| {
+    type_needs_unwind_cleanup_(ccx.tcx(), ty, &mut FnvHashSet::new())
+});
+
+fn type_needs_unwind_cleanup_<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                    ty: Ty<'tcx>,
+                                    tycache: &mut FnvHashSet<Ty<'tcx>>)
+                                    -> bool
+{
+    // Prevent infinite recursion
+    if !tycache.insert(ty) {
+        return false;
+    }
 
-    fn type_needs_unwind_cleanup_<'tcx>(tcx: &ty::ctxt<'tcx>,
-                                        ty: Ty<'tcx>,
-                                        tycache: &mut FnvHashSet<Ty<'tcx>>)
-                                        -> bool
-    {
-        // Prevent infinite recursion
-        if !tycache.insert(ty) {
-            return false;
-        }
+    let mut needs_unwind_cleanup = false;
+    ty::maybe_walk_ty(ty, |ty| {
+        needs_unwind_cleanup |= match ty.sty {
+            ty::ty_bool | ty::ty_int(_) | ty::ty_uint(_) |
+            ty::ty_float(_) | ty::ty_tup(_) | ty::ty_ptr(_) => false,
 
-        let mut needs_unwind_cleanup = false;
-        ty::maybe_walk_ty(ty, |ty| {
-            needs_unwind_cleanup |= match ty.sty {
-                ty::ty_bool | ty::ty_int(_) | ty::ty_uint(_) |
-                ty::ty_float(_) | ty::ty_tup(_) | ty::ty_ptr(_) => false,
-
-                ty::ty_enum(did, substs) =>
-                    ty::enum_variants(tcx, did).iter().any(|v|
-                        v.args.iter().any(|&aty| {
-                            let t = aty.subst(tcx, substs);
-                            type_needs_unwind_cleanup_(tcx, t, tycache)
-                        })
-                    ),
-
-                _ => true
-            };
-            !needs_unwind_cleanup
-        });
-        needs_unwind_cleanup
-    }
+            ty::ty_enum(did, substs) =>
+                ty::enum_variants(tcx, did).iter().any(|v|
+                    v.args.iter().any(|&aty| {
+                        let t = aty.subst(tcx, substs);
+                        type_needs_unwind_cleanup_(tcx, t, tycache)
+                    })
+                ),
+
+            _ => true
+        };
+        !needs_unwind_cleanup
+    });
+    needs_unwind_cleanup
+}
 }
 
 pub fn type_needs_drop<'tcx>(cx: &ty::ctxt<'tcx>,
-                             ty: Ty<'tcx>)
-                             -> bool {
-    ty::type_contents(cx, ty).needs_drop(cx)
+                         ty: Ty<'tcx>)
+                         -> bool {
+ty::type_contents(cx, ty).needs_drop(cx)
 }
 
 fn type_is_newtype_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-                                       ty: Ty<'tcx>) -> bool {
-    match ty.sty {
-        ty::ty_struct(def_id, substs) => {
-            let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
-            fields.len() == 1 &&
-                fields[0].name ==
-                    token::special_idents::unnamed_field.name &&
-                type_is_immediate(ccx, fields[0].mt.ty)
-        }
-        _ => false
+                                   ty: Ty<'tcx>) -> bool {
+match ty.sty {
+    ty::ty_struct(def_id, substs) => {
+        let fields = ty::struct_fields(ccx.tcx(), def_id, substs);
+        fields.len() == 1 &&
+            fields[0].name ==
+                token::special_idents::unnamed_field.name &&
+            type_is_immediate(ccx, fields[0].mt.ty)
     }
+    _ => false
+}
 }
 
 pub fn type_is_immediate<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
-    use trans::machine::llsize_of_alloc;
-    use trans::type_of::sizing_type_of;
-
-    let tcx = ccx.tcx();
-    let simple = ty::type_is_scalar(ty) ||
-        ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) ||
-        type_is_newtype_immediate(ccx, ty) ||
-        ty::type_is_simd(tcx, ty);
-    if simple && !type_is_fat_ptr(tcx, ty) {
-        return true;
-    }
-    if !type_is_sized(tcx, ty) {
-        return false;
-    }
-    match ty.sty {
-        ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) |
-        ty::ty_unboxed_closure(..) => {
-            let llty = sizing_type_of(ccx, ty);
-            llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())
-        }
-        _ => type_is_zero_size(ccx, ty)
+use trans::machine::llsize_of_alloc;
+use trans::type_of::sizing_type_of;
+
+let tcx = ccx.tcx();
+let simple = ty::type_is_scalar(ty) ||
+    ty::type_is_unique(ty) || ty::type_is_region_ptr(ty) ||
+    type_is_newtype_immediate(ccx, ty) ||
+    ty::type_is_simd(tcx, ty);
+if simple && !type_is_fat_ptr(tcx, ty) {
+    return true;
+}
+if !type_is_sized(tcx, ty) {
+    return false;
+}
+match ty.sty {
+    ty::ty_struct(..) | ty::ty_enum(..) | ty::ty_tup(..) |
+    ty::ty_unboxed_closure(..) => {
+        let llty = sizing_type_of(ccx, ty);
+        llsize_of_alloc(ccx, llty) <= llsize_of_alloc(ccx, ccx.int_type())
     }
+    _ => type_is_zero_size(ccx, ty)
+}
 }
 
 /// Identify types which have size zero at runtime.
 pub fn type_is_zero_size<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -> bool {
-    use trans::machine::llsize_of_alloc;
-    use trans::type_of::sizing_type_of;
-    let llty = sizing_type_of(ccx, ty);
-    llsize_of_alloc(ccx, llty) == 0
+use trans::machine::llsize_of_alloc;
+use trans::type_of::sizing_type_of;
+let llty = sizing_type_of(ccx, ty);
+llsize_of_alloc(ccx, llty) == 0
 }
 
 /// Identifies types which we declare to be equivalent to `void` in C for the purpose of function
@@ -209,85 +264,85 @@ pub fn type_is_zero_size<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, ty: Ty<'tcx>) -
 /// zero-size, but not all zero-size types use a `void` return type (in order to aid with C ABI
 /// compatibility).
 pub fn return_type_is_void(ccx: &CrateContext, ty: Ty) -> bool {
-    ty::type_is_nil(ty) || ty::type_is_empty(ccx.tcx(), ty)
+ty::type_is_nil(ty) || ty::type_is_empty(ccx.tcx(), ty)
 }
 
 /// Generates a unique symbol based off the name given. This is used to create
 /// unique symbols for things like closures.
 pub fn gensym_name(name: &str) -> PathElem {
-    let num = token::gensym(name).uint();
-    // use one colon which will get translated to a period by the mangler, and
-    // we're guaranteed that `num` is globally unique for this crate.
-    PathName(token::gensym(format!("{}:{}", name, num)[]))
+let num = token::gensym(name).uint();
+// use one colon which will get translated to a period by the mangler, and
+// we're guaranteed that `num` is globally unique for this crate.
+PathName(token::gensym(format!("{}:{}", name, num).index(&FullRange)))
 }
 
 #[derive(Copy)]
 pub struct tydesc_info<'tcx> {
-    pub ty: Ty<'tcx>,
-    pub tydesc: ValueRef,
-    pub size: ValueRef,
-    pub align: ValueRef,
-    pub name: ValueRef,
+pub ty: Ty<'tcx>,
+pub tydesc: ValueRef,
+pub size: ValueRef,
+pub align: ValueRef,
+pub name: ValueRef,
 }
 
 /*
- * A note on nomenclature of linking: "extern", "foreign", and "upcall".
- *
- * An "extern" is an LLVM symbol we wind up emitting an undefined external
- * reference to. This means "we don't have the thing in this compilation unit,
- * please make sure you link it in at runtime". This could be a reference to
- * C code found in a C library, or rust code found in a rust crate.
- *
- * Most "externs" are implicitly declared (automatically) as a result of a
- * user declaring an extern _module_ dependency; this causes the rust driver
- * to locate an extern crate, scan its compilation metadata, and emit extern
- * declarations for any symbols used by the declaring crate.
- *
- * A "foreign" is an extern that references C (or other non-rust ABI) code.
- * There is no metadata to scan for extern references so in these cases either
- * a header-digester like bindgen, or manual function prototypes, have to
- * serve as declarators. So these are usually given explicitly as prototype
- * declarations, in rust code, with ABI attributes on them noting which ABI to
- * link via.
- *
- * An "upcall" is a foreign call generated by the compiler (not corresponding
- * to any user-written call in the code) into the runtime library, to perform
- * some helper task such as bringing a task to life, allocating memory, etc.
- *
- */
+* A note on nomenclature of linking: "extern", "foreign", and "upcall".
+*
+* An "extern" is an LLVM symbol we wind up emitting an undefined external
+* reference to. This means "we don't have the thing in this compilation unit,
+* please make sure you link it in at runtime". This could be a reference to
+* C code found in a C library, or rust code found in a rust crate.
+*
+* Most "externs" are implicitly declared (automatically) as a result of a
+* user declaring an extern _module_ dependency; this causes the rust driver
+* to locate an extern crate, scan its compilation metadata, and emit extern
+* declarations for any symbols used by the declaring crate.
+*
+* A "foreign" is an extern that references C (or other non-rust ABI) code.
+* There is no metadata to scan for extern references so in these cases either
+* a header-digester like bindgen, or manual function prototypes, have to
+* serve as declarators. So these are usually given explicitly as prototype
+* declarations, in rust code, with ABI attributes on them noting which ABI to
+* link via.
+*
+* An "upcall" is a foreign call generated by the compiler (not corresponding
+* to any user-written call in the code) into the runtime library, to perform
+* some helper task such as bringing a task to life, allocating memory, etc.
+*
+*/
 
 #[derive(Copy)]
 pub struct NodeInfo {
-    pub id: ast::NodeId,
-    pub span: Span,
+pub id: ast::NodeId,
+pub span: Span,
 }
 
 pub fn expr_info(expr: &ast::Expr) -> NodeInfo {
-    NodeInfo { id: expr.id, span: expr.span }
+NodeInfo { id: expr.id, span: expr.span }
 }
 
 pub struct BuilderRef_res {
-    pub b: BuilderRef,
+pub b: BuilderRef,
 }
 
 impl Drop for BuilderRef_res {
-    fn drop(&mut self) {
-        unsafe {
-            llvm::LLVMDisposeBuilder(self.b);
-        }
+fn drop(&mut self) {
+    unsafe {
+        llvm::LLVMDisposeBuilder(self.b);
     }
 }
+}
 
 pub fn BuilderRef_res(b: BuilderRef) -> BuilderRef_res {
-    BuilderRef_res {
-        b: b
-    }
+BuilderRef_res {
+    b: b
+}
 }
 
 pub type ExternMap = FnvHashMap<String, ValueRef>;
 
 pub fn validate_substs(substs: &Substs) {
-    assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
+assert!(substs.types.all(|t| !ty::type_needs_infer(*t)));
 }
 
 // work around bizarre resolve errors
@@ -297,183 +352,183 @@ pub fn validate_substs(substs: &Substs) {
 // Function context.  Every LLVM function we create will have one of
 // these.
 pub struct FunctionContext<'a, 'tcx: 'a> {
-    // The ValueRef returned from a call to llvm::LLVMAddFunction; the
-    // address of the first instruction in the sequence of
-    // instructions for this function that will go in the .text
-    // section of the executable we're generating.
-    pub llfn: ValueRef,
+// The ValueRef returned from a call to llvm::LLVMAddFunction; the
+// address of the first instruction in the sequence of
+// instructions for this function that will go in the .text
+// section of the executable we're generating.
+pub llfn: ValueRef,
 
-    // always an empty parameter-environment
-    pub param_env: ty::ParameterEnvironment<'a, 'tcx>,
+// always an empty parameter-environment
+pub param_env: ty::ParameterEnvironment<'a, 'tcx>,
 
-    // The environment argument in a closure.
-    pub llenv: Option<ValueRef>,
+// The environment argument in a closure.
+pub llenv: Option<ValueRef>,
 
-    // A pointer to where to store the return value. If the return type is
-    // immediate, this points to an alloca in the function. Otherwise, it's a
-    // pointer to the hidden first parameter of the function. After function
-    // construction, this should always be Some.
-    pub llretslotptr: Cell<Option<ValueRef>>,
+// A pointer to where to store the return value. If the return type is
+// immediate, this points to an alloca in the function. Otherwise, it's a
+// pointer to the hidden first parameter of the function. After function
+// construction, this should always be Some.
+pub llretslotptr: Cell<Option<ValueRef>>,
 
-    // These pub elements: "hoisted basic blocks" containing
-    // administrative activities that have to happen in only one place in
-    // the function, due to LLVM's quirks.
-    // A marker for the place where we want to insert the function's static
-    // allocas, so that LLVM will coalesce them into a single alloca call.
-    pub alloca_insert_pt: Cell<Option<ValueRef>>,
-    pub llreturn: Cell<Option<BasicBlockRef>>,
+// These pub elements: "hoisted basic blocks" containing
+// administrative activities that have to happen in only one place in
+// the function, due to LLVM's quirks.
+// A marker for the place where we want to insert the function's static
+// allocas, so that LLVM will coalesce them into a single alloca call.
+pub alloca_insert_pt: Cell<Option<ValueRef>>,
+pub llreturn: Cell<Option<BasicBlockRef>>,
 
-    // If the function has any nested return's, including something like:
-    // fn foo() -> Option<Foo> { Some(Foo { x: return None }) }, then
-    // we use a separate alloca for each return
-    pub needs_ret_allocas: bool,
+// If the function has any nested return's, including something like:
+// fn foo() -> Option<Foo> { Some(Foo { x: return None }) }, then
+// we use a separate alloca for each return
+pub needs_ret_allocas: bool,
 
-    // The a value alloca'd for calls to upcalls.rust_personality. Used when
-    // outputting the resume instruction.
-    pub personality: Cell<Option<ValueRef>>,
+// The a value alloca'd for calls to upcalls.rust_personality. Used when
+// outputting the resume instruction.
+pub personality: Cell<Option<ValueRef>>,
 
-    // True if the caller expects this fn to use the out pointer to
-    // return. Either way, your code should write into the slot llretslotptr
-    // points to, but if this value is false, that slot will be a local alloca.
-    pub caller_expects_out_pointer: bool,
+// True if the caller expects this fn to use the out pointer to
+// return. Either way, your code should write into the slot llretslotptr
+// points to, but if this value is false, that slot will be a local alloca.
+pub caller_expects_out_pointer: bool,
 
-    // Maps the DefId's for local variables to the allocas created for
-    // them in llallocas.
-    pub lllocals: RefCell<NodeMap<LvalueDatum<'tcx>>>,
+// Maps the DefId's for local variables to the allocas created for
+// them in llallocas.
+pub lllocals: RefCell<NodeMap<LvalueDatum<'tcx>>>,
 
-    // Same as above, but for closure upvars
-    pub llupvars: RefCell<NodeMap<ValueRef>>,
+// Same as above, but for closure upvars
+pub llupvars: RefCell<NodeMap<ValueRef>>,
 
-    // The NodeId of the function, or -1 if it doesn't correspond to
-    // a user-defined function.
-    pub id: ast::NodeId,
+// The NodeId of the function, or -1 if it doesn't correspond to
+// a user-defined function.
+pub id: ast::NodeId,
 
-    // If this function is being monomorphized, this contains the type
-    // substitutions used.
-    pub param_substs: &'a Substs<'tcx>,
+// If this function is being monomorphized, this contains the type
+// substitutions used.
+pub param_substs: &'a Substs<'tcx>,
 
-    // The source span and nesting context where this function comes from, for
-    // error reporting and symbol generation.
-    pub span: Option<Span>,
+// The source span and nesting context where this function comes from, for
+// error reporting and symbol generation.
+pub span: Option<Span>,
 
-    // The arena that blocks are allocated from.
-    pub block_arena: &'a TypedArena<BlockS<'a, 'tcx>>,
+// The arena that blocks are allocated from.
+pub block_arena: &'a TypedArena<BlockS<'a, 'tcx>>,
 
-    // This function's enclosing crate context.
-    pub ccx: &'a CrateContext<'a, 'tcx>,
+// This function's enclosing crate context.
+pub ccx: &'a CrateContext<'a, 'tcx>,
 
-    // Used and maintained by the debuginfo module.
-    pub debug_context: debuginfo::FunctionDebugContext,
+// Used and maintained by the debuginfo module.
+pub debug_context: debuginfo::FunctionDebugContext,
 
-    // Cleanup scopes.
-    pub scopes: RefCell<Vec<cleanup::CleanupScope<'a, 'tcx>>>,
+// Cleanup scopes.
+pub scopes: RefCell<Vec<cleanup::CleanupScope<'a, 'tcx>>>,
 
-    pub cfg: Option<cfg::CFG>,
+pub cfg: Option<cfg::CFG>,
 }
 
 impl<'a, 'tcx> FunctionContext<'a, 'tcx> {
-    pub fn arg_pos(&self, arg: uint) -> uint {
-        let arg = self.env_arg_pos() + arg;
-        if self.llenv.is_some() {
-            arg + 1
-        } else {
-            arg
-        }
+pub fn arg_pos(&self, arg: uint) -> uint {
+    let arg = self.env_arg_pos() + arg;
+    if self.llenv.is_some() {
+        arg + 1
+    } else {
+        arg
     }
+}
 
-    pub fn env_arg_pos(&self) -> uint {
-        if self.caller_expects_out_pointer {
-            1u
-        } else {
-            0u
-        }
+pub fn env_arg_pos(&self) -> uint {
+    if self.caller_expects_out_pointer {
+        1u
+    } else {
+        0u
     }
+}
 
-    pub fn cleanup(&self) {
-        unsafe {
-            llvm::LLVMInstructionEraseFromParent(self.alloca_insert_pt
-                                                     .get()
-                                                     .unwrap());
-        }
+pub fn cleanup(&self) {
+    unsafe {
+        llvm::LLVMInstructionEraseFromParent(self.alloca_insert_pt
+                                                 .get()
+                                                 .unwrap());
     }
+}
 
-    pub fn get_llreturn(&self) -> BasicBlockRef {
-        if self.llreturn.get().is_none() {
-
-            self.llreturn.set(Some(unsafe {
-                llvm::LLVMAppendBasicBlockInContext(self.ccx.llcx(), self.llfn,
-                                                    "return\0".as_ptr() as *const _)
-            }))
-        }
+pub fn get_llreturn(&self) -> BasicBlockRef {
+    if self.llreturn.get().is_none() {
 
-        self.llreturn.get().unwrap()
+        self.llreturn.set(Some(unsafe {
+            llvm::LLVMAppendBasicBlockInContext(self.ccx.llcx(), self.llfn,
+                                                "return\0".as_ptr() as *const _)
+        }))
     }
 
-    pub fn get_ret_slot(&self, bcx: Block<'a, 'tcx>,
-                        output: ty::FnOutput<'tcx>,
-                        name: &str) -> ValueRef {
-        if self.needs_ret_allocas {
-            base::alloca_no_lifetime(bcx, match output {
-                ty::FnConverging(output_type) => type_of::type_of(bcx.ccx(), output_type),
-                ty::FnDiverging => Type::void(bcx.ccx())
-            }, name)
-        } else {
-            self.llretslotptr.get().unwrap()
-        }
-    }
+    self.llreturn.get().unwrap()
+}
 
-    pub fn new_block(&'a self,
-                     is_lpad: bool,
-                     name: &str,
-                     opt_node_id: Option<ast::NodeId>)
-                     -> Block<'a, 'tcx> {
-        unsafe {
-            let name = CString::from_slice(name.as_bytes());
-            let llbb = llvm::LLVMAppendBasicBlockInContext(self.ccx.llcx(),
-                                                           self.llfn,
-                                                           name.as_ptr());
-            BlockS::new(llbb, is_lpad, opt_node_id, self)
-        }
+pub fn get_ret_slot(&self, bcx: Block<'a, 'tcx>,
+                    output: ty::FnOutput<'tcx>,
+                    name: &str) -> ValueRef {
+    if self.needs_ret_allocas {
+        base::alloca_no_lifetime(bcx, match output {
+            ty::FnConverging(output_type) => type_of::type_of(bcx.ccx(), output_type),
+            ty::FnDiverging => Type::void(bcx.ccx())
+        }, name)
+    } else {
+        self.llretslotptr.get().unwrap()
     }
+}
 
-    pub fn new_id_block(&'a self,
-                        name: &str,
-                        node_id: ast::NodeId)
-                        -> Block<'a, 'tcx> {
-        self.new_block(false, name, Some(node_id))
+pub fn new_block(&'a self,
+                 is_lpad: bool,
+                 name: &str,
+                 opt_node_id: Option<ast::NodeId>)
+                 -> Block<'a, 'tcx> {
+    unsafe {
+        let name = CString::from_slice(name.as_bytes());
+        let llbb = llvm::LLVMAppendBasicBlockInContext(self.ccx.llcx(),
+                                                       self.llfn,
+                                                       name.as_ptr());
+        BlockS::new(llbb, is_lpad, opt_node_id, self)
     }
+}
 
-    pub fn new_temp_block(&'a self,
-                          name: &str)
-                          -> Block<'a, 'tcx> {
-        self.new_block(false, name, None)
-    }
+pub fn new_id_block(&'a self,
+                    name: &str,
+                    node_id: ast::NodeId)
+                    -> Block<'a, 'tcx> {
+    self.new_block(false, name, Some(node_id))
+}
 
-    pub fn join_blocks(&'a self,
-                       id: ast::NodeId,
-                       in_cxs: &[Block<'a, 'tcx>])
-                       -> Block<'a, 'tcx> {
-        let out = self.new_id_block("join", id);
-        let mut reachable = false;
-        for bcx in in_cxs.iter() {
-            if !bcx.unreachable.get() {
-                build::Br(*bcx, out.llbb);
-                reachable = true;
-            }
-        }
-        if !reachable {
-            build::Unreachable(out);
+pub fn new_temp_block(&'a self,
+                      name: &str)
+                      -> Block<'a, 'tcx> {
+    self.new_block(false, name, None)
+}
+
+pub fn join_blocks(&'a self,
+                   id: ast::NodeId,
+                   in_cxs: &[Block<'a, 'tcx>])
+                   -> Block<'a, 'tcx> {
+    let out = self.new_id_block("join", id);
+    let mut reachable = false;
+    for bcx in in_cxs.iter() {
+        if !bcx.unreachable.get() {
+            build::Br(*bcx, out.llbb);
+            reachable = true;
         }
-        return out;
     }
-
-    pub fn monomorphize<T>(&self, value: &T) -> T
-        where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone
-    {
-        monomorphize::apply_param_substs(self.ccx.tcx(),
-                                         self.param_substs,
-                                         value)
+    if !reachable {
+        build::Unreachable(out);
     }
+    return out;
+}
+
+pub fn monomorphize<T>(&self, value: &T) -> T
+    where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone
+{
+    monomorphize::apply_param_substs(self.ccx.tcx(),
+                                     self.param_substs,
+                                     value)
+}
 }
 
 // Basic block context.  We create a block context for each basic block
@@ -482,277 +537,277 @@ pub fn monomorphize<T>(&self, value: &T) -> T
 // with many basic blocks per function.  All the basic blocks attached to a
 // function are organized as a directed graph.
 pub struct BlockS<'blk, 'tcx: 'blk> {
-    // The BasicBlockRef returned from a call to
-    // llvm::LLVMAppendBasicBlock(llfn, name), which adds a basic
-    // block to the function pointed to by llfn.  We insert
-    // instructions into that block by way of this block context.
-    // The block pointing to this one in the function's digraph.
-    pub llbb: BasicBlockRef,
-    pub terminated: Cell<bool>,
-    pub unreachable: Cell<bool>,
+// The BasicBlockRef returned from a call to
+// llvm::LLVMAppendBasicBlock(llfn, name), which adds a basic
+// block to the function pointed to by llfn.  We insert
+// instructions into that block by way of this block context.
+// The block pointing to this one in the function's digraph.
+pub llbb: BasicBlockRef,
+pub terminated: Cell<bool>,
+pub unreachable: Cell<bool>,
 
-    // Is this block part of a landing pad?
-    pub is_lpad: bool,
+// Is this block part of a landing pad?
+pub is_lpad: bool,
 
-    // AST node-id associated with this block, if any. Used for
-    // debugging purposes only.
-    pub opt_node_id: Option<ast::NodeId>,
+// AST node-id associated with this block, if any. Used for
+// debugging purposes only.
+pub opt_node_id: Option<ast::NodeId>,
 
-    // The function context for the function to which this block is
-    // attached.
-    pub fcx: &'blk FunctionContext<'blk, 'tcx>,
+// The function context for the function to which this block is
+// attached.
+pub fcx: &'blk FunctionContext<'blk, 'tcx>,
 }
 
 pub type Block<'blk, 'tcx> = &'blk BlockS<'blk, 'tcx>;
 
 impl<'blk, 'tcx> BlockS<'blk, 'tcx> {
-    pub fn new(llbb: BasicBlockRef,
-               is_lpad: bool,
-               opt_node_id: Option<ast::NodeId>,
-               fcx: &'blk FunctionContext<'blk, 'tcx>)
-               -> Block<'blk, 'tcx> {
-        fcx.block_arena.alloc(BlockS {
-            llbb: llbb,
-            terminated: Cell::new(false),
-            unreachable: Cell::new(false),
-            is_lpad: is_lpad,
-            opt_node_id: opt_node_id,
-            fcx: fcx
-        })
-    }
+pub fn new(llbb: BasicBlockRef,
+           is_lpad: bool,
+           opt_node_id: Option<ast::NodeId>,
+           fcx: &'blk FunctionContext<'blk, 'tcx>)
+           -> Block<'blk, 'tcx> {
+    fcx.block_arena.alloc(BlockS {
+        llbb: llbb,
+        terminated: Cell::new(false),
+        unreachable: Cell::new(false),
+        is_lpad: is_lpad,
+        opt_node_id: opt_node_id,
+        fcx: fcx
+    })
+}
 
-    pub fn ccx(&self) -> &'blk CrateContext<'blk, 'tcx> {
-        self.fcx.ccx
-    }
-    pub fn tcx(&self) -> &'blk ty::ctxt<'tcx> {
-        self.fcx.ccx.tcx()
-    }
-    pub fn sess(&self) -> &'blk Session { self.fcx.ccx.sess() }
+pub fn ccx(&self) -> &'blk CrateContext<'blk, 'tcx> {
+    self.fcx.ccx
+}
+pub fn tcx(&self) -> &'blk ty::ctxt<'tcx> {
+    self.fcx.ccx.tcx()
+}
+pub fn sess(&self) -> &'blk Session { self.fcx.ccx.sess() }
 
-    pub fn ident(&self, ident: Ident) -> String {
-        token::get_ident(ident).get().to_string()
-    }
+pub fn ident(&self, ident: Ident) -> String {
+    token::get_ident(ident).get().to_string()
+}
 
-    pub fn node_id_to_string(&self, id: ast::NodeId) -> String {
-        self.tcx().map.node_to_string(id).to_string()
-    }
+pub fn node_id_to_string(&self, id: ast::NodeId) -> String {
+    self.tcx().map.node_to_string(id).to_string()
+}
 
-    pub fn expr_to_string(&self, e: &ast::Expr) -> String {
-        e.repr(self.tcx())
-    }
+pub fn expr_to_string(&self, e: &ast::Expr) -> String {
+    e.repr(self.tcx())
+}
 
-    pub fn def(&self, nid: ast::NodeId) -> def::Def {
-        match self.tcx().def_map.borrow().get(&nid) {
-            Some(v) => v.clone(),
-            None => {
-                self.tcx().sess.bug(format!(
-                    "no def associated with node id {}", nid)[]);
-            }
+pub fn def(&self, nid: ast::NodeId) -> def::Def {
+    match self.tcx().def_map.borrow().get(&nid) {
+        Some(v) => v.clone(),
+        None => {
+            self.tcx().sess.bug(format!(
+                "no def associated with node id {}", nid).index(&FullRange));
         }
     }
+}
 
-    pub fn val_to_string(&self, val: ValueRef) -> String {
-        self.ccx().tn().val_to_string(val)
-    }
+pub fn val_to_string(&self, val: ValueRef) -> String {
+    self.ccx().tn().val_to_string(val)
+}
 
-    pub fn llty_str(&self, ty: Type) -> String {
-        self.ccx().tn().type_to_string(ty)
-    }
+pub fn llty_str(&self, ty: Type) -> String {
+    self.ccx().tn().type_to_string(ty)
+}
 
-    pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
-        t.repr(self.tcx())
-    }
+pub fn ty_to_string(&self, t: Ty<'tcx>) -> String {
+    t.repr(self.tcx())
+}
 
-    pub fn to_str(&self) -> String {
-        format!("[block {:p}]", self)
-    }
+pub fn to_str(&self) -> String {
+    format!("[block {:p}]", self)
+}
 
-    pub fn monomorphize<T>(&self, value: &T) -> T
-        where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone
-    {
-        monomorphize::apply_param_substs(self.tcx(),
-                                         self.fcx.param_substs,
-                                         value)
-    }
+pub fn monomorphize<T>(&self, value: &T) -> T
+    where T : TypeFoldable<'tcx> + Repr<'tcx> + HasProjectionTypes + Clone
+{
+    monomorphize::apply_param_substs(self.tcx(),
+                                     self.fcx.param_substs,
+                                     value)
+}
 }
 
 impl<'blk, 'tcx> mc::Typer<'tcx> for BlockS<'blk, 'tcx> {
-    fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
-        self.tcx()
-    }
+fn tcx<'a>(&'a self) -> &'a ty::ctxt<'tcx> {
+    self.tcx()
+}
 
-    fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
-        Ok(node_id_type(self, id))
-    }
+fn node_ty(&self, id: ast::NodeId) -> mc::McResult<Ty<'tcx>> {
+    Ok(node_id_type(self, id))
+}
 
-    fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult<Ty<'tcx>> {
-        Ok(expr_ty_adjusted(self, expr))
-    }
+fn expr_ty_adjusted(&self, expr: &ast::Expr) -> mc::McResult<Ty<'tcx>> {
+    Ok(expr_ty_adjusted(self, expr))
+}
 
-    fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>> {
-        self.tcx()
-            .method_map
-            .borrow()
-            .get(&method_call)
-            .map(|method| monomorphize_type(self, method.ty))
-    }
+fn node_method_ty(&self, method_call: ty::MethodCall) -> Option<Ty<'tcx>> {
+    self.tcx()
+        .method_map
+        .borrow()
+        .get(&method_call)
+        .map(|method| monomorphize_type(self, method.ty))
+}
 
-    fn node_method_origin(&self, method_call: ty::MethodCall)
-                          -> Option<ty::MethodOrigin<'tcx>>
-    {
-        self.tcx()
-            .method_map
-            .borrow()
-            .get(&method_call)
-            .map(|method| method.origin.clone())
-    }
+fn node_method_origin(&self, method_call: ty::MethodCall)
+                      -> Option<ty::MethodOrigin<'tcx>>
+{
+    self.tcx()
+        .method_map
+        .borrow()
+        .get(&method_call)
+        .map(|method| method.origin.clone())
+}
 
-    fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
-        &self.tcx().adjustments
-    }
+fn adjustments<'a>(&'a self) -> &'a RefCell<NodeMap<ty::AutoAdjustment<'tcx>>> {
+    &self.tcx().adjustments
+}
 
-    fn is_method_call(&self, id: ast::NodeId) -> bool {
-        self.tcx().method_map.borrow().contains_key(&ty::MethodCall::expr(id))
-    }
+fn is_method_call(&self, id: ast::NodeId) -> bool {
+    self.tcx().method_map.borrow().contains_key(&ty::MethodCall::expr(id))
+}
 
-    fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<region::CodeExtent> {
-        self.tcx().region_maps.temporary_scope(rvalue_id)
-    }
+fn temporary_scope(&self, rvalue_id: ast::NodeId) -> Option<region::CodeExtent> {
+    self.tcx().region_maps.temporary_scope(rvalue_id)
+}
 
-    fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> Option<ty::UpvarBorrow> {
-        Some(self.tcx().upvar_borrow_map.borrow()[upvar_id].clone())
-    }
+fn upvar_borrow(&self, upvar_id: ty::UpvarId) -> Option<ty::UpvarBorrow> {
+    Some(self.tcx().upvar_borrow_map.borrow()[upvar_id].clone())
+}
 
-    fn capture_mode(&self, closure_expr_id: ast::NodeId)
-                    -> ast::CaptureClause {
-        self.tcx().capture_modes.borrow()[closure_expr_id].clone()
-    }
+fn capture_mode(&self, closure_expr_id: ast::NodeId)
+                -> ast::CaptureClause {
+    self.tcx().capture_modes.borrow()[closure_expr_id].clone()
+}
 
-    fn type_moves_by_default(&self, span: Span, ty: Ty<'tcx>) -> bool {
-        self.fcx.param_env.type_moves_by_default(span, ty)
-    }
+fn type_moves_by_default(&self, span: Span, ty: Ty<'tcx>) -> bool {
+    self.fcx.param_env.type_moves_by_default(span, ty)
+}
 }
 
 impl<'blk, 'tcx> ty::UnboxedClosureTyper<'tcx> for BlockS<'blk, 'tcx> {
-    fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx> {
-        &self.fcx.param_env
-    }
+fn param_env<'a>(&'a self) -> &'a ty::ParameterEnvironment<'a, 'tcx> {
+    &self.fcx.param_env
+}
 
-    fn unboxed_closure_kind(&self,
-                            def_id: ast::DefId)
-                            -> ty::UnboxedClosureKind
-    {
-        let typer = NormalizingUnboxedClosureTyper::new(self.tcx());
-        typer.unboxed_closure_kind(def_id)
-    }
+fn unboxed_closure_kind(&self,
+                        def_id: ast::DefId)
+                        -> ty::UnboxedClosureKind
+{
+    let typer = NormalizingUnboxedClosureTyper::new(self.tcx());
+    typer.unboxed_closure_kind(def_id)
+}
 
-    fn unboxed_closure_type(&self,
-                            def_id: ast::DefId,
-                            substs: &subst::Substs<'tcx>)
-                            -> ty::ClosureTy<'tcx>
-    {
-        let typer = NormalizingUnboxedClosureTyper::new(self.tcx());
-        typer.unboxed_closure_type(def_id, substs)
-    }
+fn unboxed_closure_type(&self,
+                        def_id: ast::DefId,
+                        substs: &subst::Substs<'tcx>)
+                        -> ty::ClosureTy<'tcx>
+{
+    let typer = NormalizingUnboxedClosureTyper::new(self.tcx());
+    typer.unboxed_closure_type(def_id, substs)
+}
 
-    fn unboxed_closure_upvars(&self,
-                              def_id: ast::DefId,
-                              substs: &Substs<'tcx>)
-                              -> Option<Vec<ty::UnboxedClosureUpvar<'tcx>>>
-    {
-        let typer = NormalizingUnboxedClosureTyper::new(self.tcx());
-        typer.unboxed_closure_upvars(def_id, substs)
-    }
+fn unboxed_closure_upvars(&self,
+                          def_id: ast::DefId,
+                          substs: &Substs<'tcx>)
+                          -> Option<Vec<ty::UnboxedClosureUpvar<'tcx>>>
+{
+    let typer = NormalizingUnboxedClosureTyper::new(self.tcx());
+    typer.unboxed_closure_upvars(def_id, substs)
+}
 }
 
 pub struct Result<'blk, 'tcx: 'blk> {
-    pub bcx: Block<'blk, 'tcx>,
-    pub val: ValueRef
+pub bcx: Block<'blk, 'tcx>,
+pub val: ValueRef
 }
 
 impl<'b, 'tcx> Result<'b, 'tcx> {
-    pub fn new(bcx: Block<'b, 'tcx>, val: ValueRef) -> Result<'b, 'tcx> {
-        Result {
-            bcx: bcx,
-            val: val,
-        }
+pub fn new(bcx: Block<'b, 'tcx>, val: ValueRef) -> Result<'b, 'tcx> {
+    Result {
+        bcx: bcx,
+        val: val,
     }
 }
+}
 
 pub fn val_ty(v: ValueRef) -> Type {
-    unsafe {
-        Type::from_ref(llvm::LLVMTypeOf(v))
-    }
+unsafe {
+    Type::from_ref(llvm::LLVMTypeOf(v))
+}
 }
 
 // LLVM constant constructors.
 pub fn C_null(t: Type) -> ValueRef {
-    unsafe {
-        llvm::LLVMConstNull(t.to_ref())
-    }
+unsafe {
+    llvm::LLVMConstNull(t.to_ref())
+}
 }
 
 pub fn C_undef(t: Type) -> ValueRef {
-    unsafe {
-        llvm::LLVMGetUndef(t.to_ref())
-    }
+unsafe {
+    llvm::LLVMGetUndef(t.to_ref())
+}
 }
 
 pub fn C_integral(t: Type, u: u64, sign_extend: bool) -> ValueRef {
-    unsafe {
-        llvm::LLVMConstInt(t.to_ref(), u, sign_extend as Bool)
-    }
+unsafe {
+    llvm::LLVMConstInt(t.to_ref(), u, sign_extend as Bool)
+}
 }
 
 pub fn C_floating(s: &str, t: Type) -> ValueRef {
-    unsafe {
-        let s = CString::from_slice(s.as_bytes());
-        llvm::LLVMConstRealOfString(t.to_ref(), s.as_ptr())
-    }
+unsafe {
+    let s = CString::from_slice(s.as_bytes());
+    llvm::LLVMConstRealOfString(t.to_ref(), s.as_ptr())
+}
 }
 
 pub fn C_nil(ccx: &CrateContext) -> ValueRef {
-    C_struct(ccx, &[], false)
+C_struct(ccx, &[], false)
 }
 
 pub fn C_bool(ccx: &CrateContext, val: bool) -> ValueRef {
-    C_integral(Type::i1(ccx), val as u64, false)
+C_integral(Type::i1(ccx), val as u64, false)
 }
 
 pub fn C_i32(ccx: &CrateContext, i: i32) -> ValueRef {
-    C_integral(Type::i32(ccx), i as u64, true)
+C_integral(Type::i32(ccx), i as u64, true)
 }
 
 pub fn C_i64(ccx: &CrateContext, i: i64) -> ValueRef {
-    C_integral(Type::i64(ccx), i as u64, true)
+C_integral(Type::i64(ccx), i as u64, true)
 }
 
 pub fn C_u64(ccx: &CrateContext, i: u64) -> ValueRef {
-    C_integral(Type::i64(ccx), i, false)
+C_integral(Type::i64(ccx), i, false)
 }
 
 pub fn C_int<I: AsI64>(ccx: &CrateContext, i: I) -> ValueRef {
-    let v = i.as_i64();
+let v = i.as_i64();
 
-    match machine::llbitsize_of_real(ccx, ccx.int_type()) {
-        32 => assert!(v < (1<<31) && v >= -(1<<31)),
-        64 => {},
-        n => panic!("unsupported target size: {}", n)
-    }
+match machine::llbitsize_of_real(ccx, ccx.int_type()) {
+    32 => assert!(v < (1<<31) && v >= -(1<<31)),
+    64 => {},
+    n => panic!("unsupported target size: {}", n)
+}
 
-    C_integral(ccx.int_type(), v as u64, true)
+C_integral(ccx.int_type(), v as u64, true)
 }
 
 pub fn C_uint<I: AsU64>(ccx: &CrateContext, i: I) -> ValueRef {
-    let v = i.as_u64();
+let v = i.as_u64();
 
-    match machine::llbitsize_of_real(ccx, ccx.int_type()) {
-        32 => assert!(v < (1<<32)),
-        64 => {},
-        n => panic!("unsupported target size: {}", n)
-    }
+match machine::llbitsize_of_real(ccx, ccx.int_type()) {
+    32 => assert!(v < (1<<32)),
+    64 => {},
+    n => panic!("unsupported target size: {}", n)
+}
 
-    C_integral(ccx.int_type(), v, false)
+C_integral(ccx.int_type(), v, false)
 }
 
 pub trait AsI64 { fn as_i64(self) -> i64; }
@@ -769,347 +824,347 @@ impl AsU64 for u32  { fn as_u64(self) -> u64 { self as u64 }}
 impl AsU64 for uint { fn as_u64(self) -> u64 { self as u64 }}
 
 pub fn C_u8(ccx: &CrateContext, i: uint) -> ValueRef {
-    C_integral(Type::i8(ccx), i as u64, false)
+C_integral(Type::i8(ccx), i as u64, false)
 }
 
 
 // This is a 'c-like' raw string, which differs from
 // our boxed-and-length-annotated strings.
 pub fn C_cstr(cx: &CrateContext, s: InternedString, null_terminated: bool) -> ValueRef {
-    unsafe {
-        match cx.const_cstr_cache().borrow().get(&s) {
-            Some(&llval) => return llval,
-            None => ()
-        }
+unsafe {
+    match cx.const_cstr_cache().borrow().get(&s) {
+        Some(&llval) => return llval,
+        None => ()
+    }
 
-        let sc = llvm::LLVMConstStringInContext(cx.llcx(),
-                                                s.get().as_ptr() as *const c_char,
-                                                s.get().len() as c_uint,
-                                                !null_terminated as Bool);
+    let sc = llvm::LLVMConstStringInContext(cx.llcx(),
+                                            s.get().as_ptr() as *const c_char,
+                                            s.get().len() as c_uint,
+                                            !null_terminated as Bool);
 
-        let gsym = token::gensym("str");
-        let buf = CString::from_vec(format!("str{}", gsym.uint()).into_bytes());
-        let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(sc).to_ref(), buf.as_ptr());
-        llvm::LLVMSetInitializer(g, sc);
-        llvm::LLVMSetGlobalConstant(g, True);
-        llvm::SetLinkage(g, llvm::InternalLinkage);
+    let gsym = token::gensym("str");
+    let buf = CString::from_vec(format!("str{}", gsym.uint()).into_bytes());
+    let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(sc).to_ref(), buf.as_ptr());
+    llvm::LLVMSetInitializer(g, sc);
+    llvm::LLVMSetGlobalConstant(g, True);
+    llvm::SetLinkage(g, llvm::InternalLinkage);
 
-        cx.const_cstr_cache().borrow_mut().insert(s, g);
-        g
-    }
+    cx.const_cstr_cache().borrow_mut().insert(s, g);
+    g
+}
 }
 
 // NB: Do not use `do_spill_noroot` to make this into a constant string, or
 // you will be kicked off fast isel. See issue #4352 for an example of this.
 pub fn C_str_slice(cx: &CrateContext, s: InternedString) -> ValueRef {
-    let len = s.get().len();
-    let cs = consts::ptrcast(C_cstr(cx, s, false), Type::i8p(cx));
-    C_named_struct(cx.tn().find_type("str_slice").unwrap(), &[cs, C_uint(cx, len)])
+let len = s.get().len();
+let cs = consts::ptrcast(C_cstr(cx, s, false), Type::i8p(cx));
+C_named_struct(cx.tn().find_type("str_slice").unwrap(), &[cs, C_uint(cx, len)])
 }
 
 pub fn C_binary_slice(cx: &CrateContext, data: &[u8]) -> ValueRef {
-    unsafe {
-        let len = data.len();
-        let lldata = C_bytes(cx, data);
-
-        let gsym = token::gensym("binary");
-        let name = format!("binary{}", gsym.uint());
-        let name = CString::from_vec(name.into_bytes());
-        let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(lldata).to_ref(),
-                                    name.as_ptr());
-        llvm::LLVMSetInitializer(g, lldata);
-        llvm::LLVMSetGlobalConstant(g, True);
-        llvm::SetLinkage(g, llvm::InternalLinkage);
-
-        let cs = consts::ptrcast(g, Type::i8p(cx));
-        C_struct(cx, &[cs, C_uint(cx, len)], false)
-    }
+unsafe {
+    let len = data.len();
+    let lldata = C_bytes(cx, data);
+
+    let gsym = token::gensym("binary");
+    let name = format!("binary{}", gsym.uint());
+    let name = CString::from_vec(name.into_bytes());
+    let g = llvm::LLVMAddGlobal(cx.llmod(), val_ty(lldata).to_ref(),
+                                name.as_ptr());
+    llvm::LLVMSetInitializer(g, lldata);
+    llvm::LLVMSetGlobalConstant(g, True);
+    llvm::SetLinkage(g, llvm::InternalLinkage);
+
+    let cs = consts::ptrcast(g, Type::i8p(cx));
+    C_struct(cx, &[cs, C_uint(cx, len)], false)
+}
 }
 
 pub fn C_struct(cx: &CrateContext, elts: &[ValueRef], packed: bool) -> ValueRef {
-    C_struct_in_context(cx.llcx(), elts, packed)
+C_struct_in_context(cx.llcx(), elts, packed)
 }
 
 pub fn C_struct_in_context(llcx: ContextRef, elts: &[ValueRef], packed: bool) -> ValueRef {
-    unsafe {
-        llvm::LLVMConstStructInContext(llcx,
-                                       elts.as_ptr(), elts.len() as c_uint,
-                                       packed as Bool)
-    }
+unsafe {
+    llvm::LLVMConstStructInContext(llcx,
+                                   elts.as_ptr(), elts.len() as c_uint,
+                                   packed as Bool)
+}
 }
 
 pub fn C_named_struct(t: Type, elts: &[ValueRef]) -> ValueRef {
-    unsafe {
-        llvm::LLVMConstNamedStruct(t.to_ref(), elts.as_ptr(), elts.len() as c_uint)
-    }
+unsafe {
+    llvm::LLVMConstNamedStruct(t.to_ref(), elts.as_ptr(), elts.len() as c_uint)
+}
 }
 
 pub fn C_array(ty: Type, elts: &[ValueRef]) -> ValueRef {
-    unsafe {
-        return llvm::LLVMConstArray(ty.to_ref(), elts.as_ptr(), elts.len() as c_uint);
-    }
+unsafe {
+    return llvm::LLVMConstArray(ty.to_ref(), elts.as_ptr(), elts.len() as c_uint);
+}
 }
 
 pub fn C_bytes(cx: &CrateContext, bytes: &[u8]) -> ValueRef {
-    C_bytes_in_context(cx.llcx(), bytes)
+C_bytes_in_context(cx.llcx(), bytes)
 }
 
 pub fn C_bytes_in_context(llcx: ContextRef, bytes: &[u8]) -> ValueRef {
-    unsafe {
-        let ptr = bytes.as_ptr() as *const c_char;
-        return llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True);
-    }
+unsafe {
+    let ptr = bytes.as_ptr() as *const c_char;
+    return llvm::LLVMConstStringInContext(llcx, ptr, bytes.len() as c_uint, True);
+}
 }
 
 pub fn const_get_elt(cx: &CrateContext, v: ValueRef, us: &[c_uint])
-                  -> ValueRef {
-    unsafe {
-        let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint);
+              -> ValueRef {
+unsafe {
+    let r = llvm::LLVMConstExtractValue(v, us.as_ptr(), us.len() as c_uint);
 
-        debug!("const_get_elt(v={}, us={}, r={})",
-               cx.tn().val_to_string(v), us, cx.tn().val_to_string(r));
+    debug!("const_get_elt(v={}, us={:?}, r={})",
+           cx.tn().val_to_string(v), us, cx.tn().val_to_string(r));
 
-        return r;
-    }
+    return r;
+}
 }
 
 pub fn is_const(v: ValueRef) -> bool {
-    unsafe {
-        llvm::LLVMIsConstant(v) == True
-    }
+unsafe {
+    llvm::LLVMIsConstant(v) == True
+}
 }
 
 pub fn const_to_int(v: ValueRef) -> i64 {
-    unsafe {
-        llvm::LLVMConstIntGetSExtValue(v)
-    }
+unsafe {
+    llvm::LLVMConstIntGetSExtValue(v)
+}
 }
 
 pub fn const_to_uint(v: ValueRef) -> u64 {
-    unsafe {
-        llvm::LLVMConstIntGetZExtValue(v)
-    }
+unsafe {
+    llvm::LLVMConstIntGetZExtValue(v)
+}
 }
 
 pub fn is_undef(val: ValueRef) -> bool {
-    unsafe {
-        llvm::LLVMIsUndef(val) != False
-    }
+unsafe {
+    llvm::LLVMIsUndef(val) != False
+}
 }
 
 #[allow(dead_code)] // potentially useful
 pub fn is_null(val: ValueRef) -> bool {
-    unsafe {
-        llvm::LLVMIsNull(val) != False
-    }
+unsafe {
+    llvm::LLVMIsNull(val) != False
+}
 }
 
 pub fn monomorphize_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, t: Ty<'tcx>) -> Ty<'tcx> {
-    bcx.fcx.monomorphize(&t)
+bcx.fcx.monomorphize(&t)
 }
 
 pub fn node_id_type<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, id: ast::NodeId) -> Ty<'tcx> {
-    let tcx = bcx.tcx();
-    let t = ty::node_id_to_type(tcx, id);
-    monomorphize_type(bcx, t)
+let tcx = bcx.tcx();
+let t = ty::node_id_to_type(tcx, id);
+monomorphize_type(bcx, t)
 }
 
 pub fn expr_ty<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
-    node_id_type(bcx, ex.id)
+node_id_type(bcx, ex.id)
 }
 
 pub fn expr_ty_adjusted<'blk, 'tcx>(bcx: &BlockS<'blk, 'tcx>, ex: &ast::Expr) -> Ty<'tcx> {
-    monomorphize_type(bcx, ty::expr_ty_adjusted(bcx.tcx(), ex))
+monomorphize_type(bcx, ty::expr_ty_adjusted(bcx.tcx(), ex))
 }
 
 /// Attempts to resolve an obligation. The result is a shallow vtable resolution -- meaning that we
 /// do not (necessarily) resolve all nested obligations on the impl. Note that type check should
 /// guarantee to us that all nested obligations *could be* resolved if we wanted to.
 pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-                                    span: Span,
-                                    trait_ref: ty::PolyTraitRef<'tcx>)
-                                    -> traits::Vtable<'tcx, ()>
+                                span: Span,
+                                trait_ref: ty::PolyTraitRef<'tcx>)
+                                -> traits::Vtable<'tcx, ()>
 {
-    let tcx = ccx.tcx();
-
-    // Remove any references to regions; this helps improve caching.
-    let trait_ref = ty_fold::erase_regions(tcx, trait_ref);
-
-    // First check the cache.
-    match ccx.trait_cache().borrow().get(&trait_ref) {
-        Some(vtable) => {
-            info!("Cache hit: {}", trait_ref.repr(ccx.tcx()));
-            return (*vtable).clone();
-        }
-        None => { }
-    }
-
-    debug!("trans fulfill_obligation: trait_ref={}", trait_ref.repr(ccx.tcx()));
-
-    ty::populate_implementations_for_trait_if_necessary(tcx, trait_ref.def_id());
-    let infcx = infer::new_infer_ctxt(tcx);
-
-    // Do the initial selection for the obligation. This yields the
-    // shallow result we are looking for -- that is, what specific impl.
-    let typer = NormalizingUnboxedClosureTyper::new(tcx);
-    let mut selcx = traits::SelectionContext::new(&infcx, &typer);
-    let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),
-                                             trait_ref.to_poly_trait_predicate());
-    let selection = match selcx.select(&obligation) {
-        Ok(Some(selection)) => selection,
-        Ok(None) => {
-            // Ambiguity can happen when monomorphizing during trans
-            // expands to some humongo type that never occurred
-            // statically -- this humongo type can then overflow,
-            // leading to an ambiguous result. So report this as an
-            // overflow bug, since I believe this is the only case
-            // where ambiguity can result.
-            debug!("Encountered ambiguity selecting `{}` during trans, \
-                    presuming due to overflow",
-                   trait_ref.repr(tcx));
-            ccx.sess().span_fatal(
-                span,
-                "reached the recursion limit during monomorphization");
-        }
-        Err(e) => {
-            tcx.sess.span_bug(
-                span,
-                format!("Encountered error `{}` selecting `{}` during trans",
-                        e.repr(tcx),
-                        trait_ref.repr(tcx))[])
-        }
-    };
-
-    // Currently, we use a fulfillment context to completely resolve
-    // all nested obligations. This is because they can inform the
-    // inference of the impl's type parameters.
-    let mut fulfill_cx = traits::FulfillmentContext::new();
-    let vtable = selection.map_move_nested(|predicate| {
-        fulfill_cx.register_predicate_obligation(&infcx, predicate);
-    });
-    let vtable = drain_fulfillment_cx(span, &infcx, &mut fulfill_cx, &vtable);
-
-    info!("Cache miss: {}", trait_ref.repr(ccx.tcx()));
-    ccx.trait_cache().borrow_mut().insert(trait_ref,
-                                          vtable.clone());
-
-    vtable
+let tcx = ccx.tcx();
+
+// Remove any references to regions; this helps improve caching.
+let trait_ref = ty_fold::erase_regions(tcx, trait_ref);
+
+// First check the cache.
+match ccx.trait_cache().borrow().get(&trait_ref) {
+    Some(vtable) => {
+        info!("Cache hit: {}", trait_ref.repr(ccx.tcx()));
+        return (*vtable).clone();
+    }
+    None => { }
+}
+
+debug!("trans fulfill_obligation: trait_ref={}", trait_ref.repr(ccx.tcx()));
+
+ty::populate_implementations_for_trait_if_necessary(tcx, trait_ref.def_id());
+let infcx = infer::new_infer_ctxt(tcx);
+
+// Do the initial selection for the obligation. This yields the
+// shallow result we are looking for -- that is, what specific impl.
+let typer = NormalizingUnboxedClosureTyper::new(tcx);
+let mut selcx = traits::SelectionContext::new(&infcx, &typer);
+let obligation = traits::Obligation::new(traits::ObligationCause::dummy(),
+                                         trait_ref.to_poly_trait_predicate());
+let selection = match selcx.select(&obligation) {
+    Ok(Some(selection)) => selection,
+    Ok(None) => {
+        // Ambiguity can happen when monomorphizing during trans
+        // expands to some humongo type that never occurred
+        // statically -- this humongo type can then overflow,
+        // leading to an ambiguous result. So report this as an
+        // overflow bug, since I believe this is the only case
+        // where ambiguity can result.
+        debug!("Encountered ambiguity selecting `{}` during trans, \
+                presuming due to overflow",
+               trait_ref.repr(tcx));
+        ccx.sess().span_fatal(
+            span,
+            "reached the recursion limit during monomorphization");
+    }
+    Err(e) => {
+        tcx.sess.span_bug(
+            span,
+            format!("Encountered error `{}` selecting `{}` during trans",
+                    e.repr(tcx),
+                    trait_ref.repr(tcx)).index(&FullRange))
+    }
+};
+
+// Currently, we use a fulfillment context to completely resolve
+// all nested obligations. This is because they can inform the
+// inference of the impl's type parameters.
+let mut fulfill_cx = traits::FulfillmentContext::new();
+let vtable = selection.map_move_nested(|predicate| {
+    fulfill_cx.register_predicate_obligation(&infcx, predicate);
+});
+let vtable = drain_fulfillment_cx(span, &infcx, &mut fulfill_cx, &vtable);
+
+info!("Cache miss: {}", trait_ref.repr(ccx.tcx()));
+ccx.trait_cache().borrow_mut().insert(trait_ref,
+                                      vtable.clone());
+
+vtable
 }
 
 pub struct NormalizingUnboxedClosureTyper<'a,'tcx:'a> {
-    param_env: ty::ParameterEnvironment<'a, 'tcx>
+param_env: ty::ParameterEnvironment<'a, 'tcx>
 }
 
 impl<'a,'tcx> NormalizingUnboxedClosureTyper<'a,'tcx> {
-    pub fn new(tcx: &'a ty::ctxt<'tcx>) -> NormalizingUnboxedClosureTyper<'a,'tcx> {
-        // Parameter environment is used to give details about type parameters,
-        // but since we are in trans, everything is fully monomorphized.
-        NormalizingUnboxedClosureTyper { param_env: ty::empty_parameter_environment(tcx) }
-    }
+pub fn new(tcx: &'a ty::ctxt<'tcx>) -> NormalizingUnboxedClosureTyper<'a,'tcx> {
+    // Parameter environment is used to give details about type parameters,
+    // but since we are in trans, everything is fully monomorphized.
+    NormalizingUnboxedClosureTyper { param_env: ty::empty_parameter_environment(tcx) }
+}
 }
 
 impl<'a,'tcx> ty::UnboxedClosureTyper<'tcx> for NormalizingUnboxedClosureTyper<'a,'tcx> {
-    fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> {
-        &self.param_env
-    }
+fn param_env<'b>(&'b self) -> &'b ty::ParameterEnvironment<'b,'tcx> {
+    &self.param_env
+}
 
-    fn unboxed_closure_kind(&self,
-                            def_id: ast::DefId)
-                            -> ty::UnboxedClosureKind
-    {
-        self.param_env.tcx.unboxed_closure_kind(def_id)
-    }
+fn unboxed_closure_kind(&self,
+                        def_id: ast::DefId)
+                        -> ty::UnboxedClosureKind
+{
+    self.param_env.tcx.unboxed_closure_kind(def_id)
+}
 
-    fn unboxed_closure_type(&self,
-                            def_id: ast::DefId,
-                            substs: &subst::Substs<'tcx>)
-                            -> ty::ClosureTy<'tcx>
-    {
-        // the substitutions in `substs` are already monomorphized,
-        // but we still must normalize associated types
-        let closure_ty = self.param_env.tcx.unboxed_closure_type(def_id, substs);
-        monomorphize::normalize_associated_type(self.param_env.tcx, &closure_ty)
-    }
+fn unboxed_closure_type(&self,
+                        def_id: ast::DefId,
+                        substs: &subst::Substs<'tcx>)
+                        -> ty::ClosureTy<'tcx>
+{
+    // the substitutions in `substs` are already monomorphized,
+    // but we still must normalize associated types
+    let closure_ty = self.param_env.tcx.unboxed_closure_type(def_id, substs);
+    monomorphize::normalize_associated_type(self.param_env.tcx, &closure_ty)
+}
 
-    fn unboxed_closure_upvars(&self,
-                              def_id: ast::DefId,
-                              substs: &Substs<'tcx>)
-                              -> Option<Vec<ty::UnboxedClosureUpvar<'tcx>>>
-    {
-        // the substitutions in `substs` are already monomorphized,
-        // but we still must normalize associated types
-        let result = ty::unboxed_closure_upvars(&self.param_env, def_id, substs);
-        monomorphize::normalize_associated_type(self.param_env.tcx, &result)
-    }
+fn unboxed_closure_upvars(&self,
+                          def_id: ast::DefId,
+                          substs: &Substs<'tcx>)
+                          -> Option<Vec<ty::UnboxedClosureUpvar<'tcx>>>
+{
+    // the substitutions in `substs` are already monomorphized,
+    // but we still must normalize associated types
+    let result = ty::unboxed_closure_upvars(&self.param_env, def_id, substs);
+    monomorphize::normalize_associated_type(self.param_env.tcx, &result)
+}
 }
 
 pub fn drain_fulfillment_cx<'a,'tcx,T>(span: Span,
-                                       infcx: &infer::InferCtxt<'a,'tcx>,
-                                       fulfill_cx: &mut traits::FulfillmentContext<'tcx>,
-                                       result: &T)
-                                       -> T
-    where T : TypeFoldable<'tcx> + Repr<'tcx>
+                                   infcx: &infer::InferCtxt<'a,'tcx>,
+                                   fulfill_cx: &mut traits::FulfillmentContext<'tcx>,
+                                   result: &T)
+                                   -> T
+where T : TypeFoldable<'tcx> + Repr<'tcx>
 {
-    debug!("drain_fulfillment_cx(result={})",
-           result.repr(infcx.tcx));
-
-    // In principle, we only need to do this so long as `result`
-    // contains unbound type parameters. It could be a slight
-    // optimization to stop iterating early.
-    let typer = NormalizingUnboxedClosureTyper::new(infcx.tcx);
-    match fulfill_cx.select_all_or_error(infcx, &typer) {
-        Ok(()) => { }
-        Err(errors) => {
-            if errors.iter().all(|e| e.is_overflow()) {
-                // See Ok(None) case above.
-                infcx.tcx.sess.span_fatal(
-                    span,
-                    "reached the recursion limit during monomorphization");
-            } else {
-                infcx.tcx.sess.span_bug(
-                    span,
-                    format!("Encountered errors `{}` fulfilling during trans",
-                            errors.repr(infcx.tcx))[]);
-            }
+debug!("drain_fulfillment_cx(result={})",
+       result.repr(infcx.tcx));
+
+// In principle, we only need to do this so long as `result`
+// contains unbound type parameters. It could be a slight
+// optimization to stop iterating early.
+let typer = NormalizingUnboxedClosureTyper::new(infcx.tcx);
+match fulfill_cx.select_all_or_error(infcx, &typer) {
+    Ok(()) => { }
+    Err(errors) => {
+        if errors.iter().all(|e| e.is_overflow()) {
+            // See Ok(None) case above.
+            infcx.tcx.sess.span_fatal(
+                span,
+                "reached the recursion limit during monomorphization");
+        } else {
+            infcx.tcx.sess.span_bug(
+                span,
+                format!("Encountered errors `{}` fulfilling during trans",
+                        errors.repr(infcx.tcx)).index(&FullRange));
         }
     }
+}
 
-    // Use freshen to simultaneously replace all type variables with
-    // their bindings and replace all regions with 'static.  This is
-    // sort of overkill because we do not expect there to be any
-    // unbound type variables, hence no `TyFresh` types should ever be
-    // inserted.
-    result.fold_with(&mut infcx.freshener())
+// Use freshen to simultaneously replace all type variables with
+// their bindings and replace all regions with 'static.  This is
+// sort of overkill because we do not expect there to be any
+// unbound type variables, hence no `TyFresh` types should ever be
+// inserted.
+result.fold_with(&mut infcx.freshener())
 }
 
 // Key used to lookup values supplied for type parameters in an expr.
 #[derive(Copy, PartialEq, Show)]
 pub enum ExprOrMethodCall {
-    // Type parameters for a path like `None::<int>`
-    ExprId(ast::NodeId),
+// Type parameters for a path like `None::<int>`
+ExprId(ast::NodeId),
 
-    // Type parameters for a method call like `a.foo::<int>()`
-    MethodCallKey(ty::MethodCall)
+// Type parameters for a method call like `a.foo::<int>()`
+MethodCallKey(ty::MethodCall)
 }
 
 pub fn node_id_substs<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-                                node: ExprOrMethodCall,
-                                param_substs: &subst::Substs<'tcx>)
-                                -> subst::Substs<'tcx> {
-    let tcx = ccx.tcx();
-
-    let substs = match node {
-        ExprId(id) => {
-            ty::node_id_item_substs(tcx, id).substs
-        }
-        MethodCallKey(method_call) => {
-            (*tcx.method_map.borrow())[method_call].substs.clone()
-        }
-    };
+                            node: ExprOrMethodCall,
+                            param_substs: &subst::Substs<'tcx>)
+                            -> subst::Substs<'tcx> {
+let tcx = ccx.tcx();
+
+let substs = match node {
+    ExprId(id) => {
+        ty::node_id_item_substs(tcx, id).substs
+    }
+    MethodCallKey(method_call) => {
+        (*tcx.method_map.borrow())[method_call].substs.clone()
+    }
+};
 
-    if substs.types.any(|t| ty::type_needs_infer(*t)) {
-        tcx.sess.bug(format!("type parameters for node {} include inference types: {}",
-                             node, substs.repr(tcx))[]);
+if substs.types.any(|t| ty::type_needs_infer(*t)) {
+        tcx.sess.bug(format!("type parameters for node {:?} include inference types: {:?}",
+                             node, substs.repr(tcx)).index(&FullRange));
     }
 
     monomorphize::apply_param_substs(tcx,
@@ -1127,8 +1182,8 @@ pub fn langcall(bcx: Block,
         Err(s) => {
             let msg = format!("{} {}", msg, s);
             match span {
-                Some(span) => bcx.tcx().sess.span_fatal(span, msg[]),
-                None => bcx.tcx().sess.fatal(msg[]),
+                Some(span) => bcx.tcx().sess.span_fatal(span, msg.index(&FullRange)),
+                None => bcx.tcx().sess.fatal(msg.index(&FullRange)),
             }
         }
     }
index a3861e71d83de56c614d8c676c5a203167d1065e..b0474d7e011a5fcc17e8d8a3788cb4de41acdb19 100644 (file)
@@ -32,7 +32,7 @@
 pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
     -> ValueRef {
     let _icx = push_ctxt("trans_lit");
-    debug!("const_lit: {}", lit);
+    debug!("const_lit: {:?}", lit);
     match lit.node {
         ast::LitByte(b) => C_integral(Type::uint_from_ty(cx, ast::TyU8), b as u64, false),
         ast::LitChar(i) => C_integral(Type::char(cx), i as u64, false),
@@ -54,7 +54,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
                 _ => cx.sess().span_bug(lit.span,
                         format!("integer literal has type {} (expected int \
                                  or uint)",
-                                ty_to_string(cx.tcx(), lit_int_ty))[])
+                                ty_to_string(cx.tcx(), lit_int_ty)).index(&FullRange))
             }
         }
         ast::LitFloat(ref fs, t) => {
@@ -74,7 +74,7 @@ pub fn const_lit(cx: &CrateContext, e: &ast::Expr, lit: &ast::Lit)
         }
         ast::LitBool(b) => C_bool(cx, b),
         ast::LitStr(ref s, _) => C_str_slice(cx, (*s).clone()),
-        ast::LitBinary(ref data) => C_binary_slice(cx, data[]),
+        ast::LitBinary(ref data) => C_binary_slice(cx, data.index(&FullRange)),
     }
 }
 
@@ -93,9 +93,9 @@ fn const_vec(cx: &CrateContext, e: &ast::Expr,
                       .collect::<Vec<_>>();
     // If the vector contains enums, an LLVM array won't work.
     let v = if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
-        C_struct(cx, vs[], false)
+        C_struct(cx, vs.index(&FullRange), false)
     } else {
-        C_array(llunitty, vs[])
+        C_array(llunitty, vs.index(&FullRange))
     };
     (v, llunitty)
 }
@@ -149,13 +149,13 @@ fn const_deref<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, v: ValueRef,
                 }
                 _ => {
                     cx.sess().bug(format!("unexpected dereferenceable type {}",
-                                          ty_to_string(cx.tcx(), t))[])
+                                          ty_to_string(cx.tcx(), t)).index(&FullRange))
                 }
             }
         }
         None => {
             cx.sess().bug(format!("cannot dereference const of type {}",
-                                  ty_to_string(cx.tcx(), t))[])
+                                  ty_to_string(cx.tcx(), t)).index(&FullRange))
         }
     }
 }
@@ -187,7 +187,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
         None => { }
         Some(adj) => {
             match adj {
-                ty::AdjustReifyFnPointer(_def_id) => {
+               ty::AdjustReifyFnPointer(_def_id) => {
                     // FIXME(#19925) once fn item types are
                     // zero-sized, we'll need to do something here
                 }
@@ -252,15 +252,15 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
                                         }
                                         _ => cx.sess().span_bug(e.span,
                                             format!("unimplemented type in const unsize: {}",
-                                                    ty_to_string(cx.tcx(), ty))[])
+                                                    ty_to_string(cx.tcx(), ty)).index(&FullRange))
                                     }
                                 }
                                 _ => {
                                     cx.sess()
                                       .span_bug(e.span,
                                                 format!("unimplemented const \
-                                                         autoref {}",
-                                                        autoref)[])
+                                                         autoref {:?}",
+                                                        autoref).index(&FullRange))
                                 }
                             }
                         }
@@ -281,7 +281,7 @@ pub fn const_expr<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, e: &ast::Expr)
         }
         cx.sess().bug(format!("const {} of type {} has size {} instead of {}",
                          e.repr(cx.tcx()), ty_to_string(cx.tcx(), ety),
-                         csize, tsize)[]);
+                         csize, tsize).index(&FullRange));
     }
     (llconst, ety_adjusted)
 }
@@ -431,7 +431,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
                       _ => cx.sess().span_bug(base.span,
                                               format!("index-expr base must be a vector \
                                                        or string type, found {}",
-                                                      ty_to_string(cx.tcx(), bt))[])
+                                                      ty_to_string(cx.tcx(), bt)).index(&FullRange))
                   },
                   ty::ty_rptr(_, mt) => match mt.ty.sty {
                       ty::ty_vec(_, Some(u)) => {
@@ -440,12 +440,12 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
                       _ => cx.sess().span_bug(base.span,
                                               format!("index-expr base must be a vector \
                                                        or string type, found {}",
-                                                      ty_to_string(cx.tcx(), bt))[])
+                                                      ty_to_string(cx.tcx(), bt)).index(&FullRange))
                   },
                   _ => cx.sess().span_bug(base.span,
                                           format!("index-expr base must be a vector \
                                                    or string type, found {}",
-                                                  ty_to_string(cx.tcx(), bt))[])
+                                                  ty_to_string(cx.tcx(), bt)).index(&FullRange))
               };
 
               let len = llvm::LLVMConstIntGetZExtValue(len) as u64;
@@ -546,8 +546,8 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
           ast::ExprTup(ref es) => {
               let ety = ty::expr_ty(cx.tcx(), e);
               let repr = adt::represent_type(cx, ety);
-              let vals = map_list(es[]);
-              adt::trans_const(cx, &*repr, 0, vals[])
+              let vals = map_list(es.index(&FullRange));
+              adt::trans_const(cx, &*repr, 0, vals.index(&FullRange))
           }
           ast::ExprStruct(_, ref fs, ref base_opt) => {
               let ety = ty::expr_ty(cx.tcx(), e);
@@ -578,7 +578,7 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
                           }
                       }
                   }).collect::<Vec<_>>();
-                  adt::trans_const(cx, &*repr, discr, cs[])
+                  adt::trans_const(cx, &*repr, discr, cs.index(&FullRange))
               })
           }
           ast::ExprVec(ref es) => {
@@ -595,9 +595,9 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
             };
             let vs: Vec<_> = repeat(const_expr(cx, &**elem).0).take(n).collect();
             if vs.iter().any(|vi| val_ty(*vi) != llunitty) {
-                C_struct(cx, vs[], false)
+                C_struct(cx, vs.index(&FullRange), false)
             } else {
-                C_array(llunitty, vs[])
+                C_array(llunitty, vs.index(&FullRange))
             }
           }
           ast::ExprPath(_) => {
@@ -645,8 +645,8 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
                   Some(def::DefStruct(_)) => {
                       let ety = ty::expr_ty(cx.tcx(), e);
                       let repr = adt::represent_type(cx, ety);
-                      let arg_vals = map_list(args[]);
-                      adt::trans_const(cx, &*repr, 0, arg_vals[])
+                      let arg_vals = map_list(args.index(&FullRange));
+                      adt::trans_const(cx, &*repr, 0, arg_vals.index(&FullRange))
                   }
                   Some(def::DefVariant(enum_did, variant_did, _)) => {
                       let ety = ty::expr_ty(cx.tcx(), e);
@@ -654,11 +654,11 @@ fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef {
                       let vinfo = ty::enum_variant_with_id(cx.tcx(),
                                                            enum_did,
                                                            variant_did);
-                      let arg_vals = map_list(args[]);
+                      let arg_vals = map_list(args.index(&FullRange));
                       adt::trans_const(cx,
                                        &*repr,
                                        vinfo.disr_val,
-                                       arg_vals[])
+                                       arg_vals.index(&FullRange))
                   }
                   _ => cx.sess().span_bug(e.span, "expected a struct or variant def")
               }
index 3726cf14023ee35c88ac7b05af5cbe377ff75b87..35fb34eafb4d02a8a6312a21873652dfc315d3a6 100644 (file)
@@ -284,7 +284,7 @@ pub fn new(crate_name: &str,
             // such as a function name in the module.
             // 1. http://llvm.org/bugs/show_bug.cgi?id=11479
             let llmod_id = format!("{}.{}.rs", crate_name, i);
-            let local_ccx = LocalCrateContext::new(&shared_ccx, llmod_id[]);
+            let local_ccx = LocalCrateContext::new(&shared_ccx, llmod_id.index(&FullRange));
             shared_ccx.local_ccxs.push(local_ccx);
         }
 
@@ -374,7 +374,7 @@ fn new(shared: &SharedCrateContext<'tcx>,
                                           .target
                                           .target
                                           .data_layout
-                                          []);
+                                          .index(&FullRange));
 
             let dbg_cx = if shared.tcx.sess.opts.debuginfo != NoDebugInfo {
                 Some(debuginfo::CrateDebugContext::new(llmod))
@@ -721,7 +721,7 @@ pub fn trait_cache(&self) -> &RefCell<FnvHashMap<ty::PolyTraitRef<'tcx>,
     /// currently conservatively bounded to 1 << 47 as that is enough to cover the current usable
     /// address space on 64-bit ARMv8 and x86_64.
     pub fn obj_size_bound(&self) -> u64 {
-        match self.sess().target.target.target_word_size[] {
+        match self.sess().target.target.target_word_size.index(&FullRange) {
             "32" => 1 << 31,
             "64" => 1 << 47,
             _ => unreachable!() // error handled by config::build_target_config
@@ -731,13 +731,13 @@ pub fn obj_size_bound(&self) -> u64 {
     pub fn report_overbig_object(&self, obj: Ty<'tcx>) -> ! {
         self.sess().fatal(
             format!("the type `{}` is too big for the current architecture",
-                    obj.repr(self.tcx()))[])
+                    obj.repr(self.tcx())).index(&FullRange))
     }
 }
 
 fn declare_intrinsic(ccx: &CrateContext, key: & &'static str) -> Option<ValueRef> {
     macro_rules! ifn {
-        ($name:expr fn() -> $ret:expr) => (
+        ($name:expr, fn() -> $ret:expr) => (
             if *key == $name {
                 let f = base::decl_cdecl_fn(
                     ccx, $name, Type::func(&[], &$ret),
@@ -746,7 +746,7 @@ macro_rules! ifn {
                 return Some(f);
             }
         );
-        ($name:expr fn($($arg:expr),*) -> $ret:expr) => (
+        ($name:expr, fn($($arg:expr),*) -> $ret:expr) => (
             if *key == $name {
                 let f = base::decl_cdecl_fn(ccx, $name,
                                   Type::func(&[$($arg),*], &$ret), ty::mk_nil(ccx.tcx()));
@@ -769,111 +769,111 @@ macro_rules! mk_struct {
     let t_f32 = Type::f32(ccx);
     let t_f64 = Type::f64(ccx);
 
-    ifn!("llvm.memcpy.p0i8.p0i8.i32" fn(i8p, i8p, t_i32, t_i32, i1) -> void);
-    ifn!("llvm.memcpy.p0i8.p0i8.i64" fn(i8p, i8p, t_i64, t_i32, i1) -> void);
-    ifn!("llvm.memmove.p0i8.p0i8.i32" fn(i8p, i8p, t_i32, t_i32, i1) -> void);
-    ifn!("llvm.memmove.p0i8.p0i8.i64" fn(i8p, i8p, t_i64, t_i32, i1) -> void);
-    ifn!("llvm.memset.p0i8.i32" fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
-    ifn!("llvm.memset.p0i8.i64" fn(i8p, t_i8, t_i64, t_i32, i1) -> void);
-
-    ifn!("llvm.trap" fn() -> void);
-    ifn!("llvm.debugtrap" fn() -> void);
-    ifn!("llvm.frameaddress" fn(t_i32) -> i8p);
-
-    ifn!("llvm.powi.f32" fn(t_f32, t_i32) -> t_f32);
-    ifn!("llvm.powi.f64" fn(t_f64, t_i32) -> t_f64);
-    ifn!("llvm.pow.f32" fn(t_f32, t_f32) -> t_f32);
-    ifn!("llvm.pow.f64" fn(t_f64, t_f64) -> t_f64);
-
-    ifn!("llvm.sqrt.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.sqrt.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.sin.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.sin.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.cos.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.cos.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.exp.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.exp.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.exp2.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.exp2.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.log.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.log.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.log10.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.log10.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.log2.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.log2.f64" fn(t_f64) -> t_f64);
-
-    ifn!("llvm.fma.f32" fn(t_f32, t_f32, t_f32) -> t_f32);
-    ifn!("llvm.fma.f64" fn(t_f64, t_f64, t_f64) -> t_f64);
-
-    ifn!("llvm.fabs.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.fabs.f64" fn(t_f64) -> t_f64);
-
-    ifn!("llvm.floor.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.floor.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.ceil.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.ceil.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.trunc.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.trunc.f64" fn(t_f64) -> t_f64);
-
-    ifn!("llvm.rint.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.rint.f64" fn(t_f64) -> t_f64);
-    ifn!("llvm.nearbyint.f32" fn(t_f32) -> t_f32);
-    ifn!("llvm.nearbyint.f64" fn(t_f64) -> t_f64);
-
-    ifn!("llvm.ctpop.i8" fn(t_i8) -> t_i8);
-    ifn!("llvm.ctpop.i16" fn(t_i16) -> t_i16);
-    ifn!("llvm.ctpop.i32" fn(t_i32) -> t_i32);
-    ifn!("llvm.ctpop.i64" fn(t_i64) -> t_i64);
-
-    ifn!("llvm.ctlz.i8" fn(t_i8 , i1) -> t_i8);
-    ifn!("llvm.ctlz.i16" fn(t_i16, i1) -> t_i16);
-    ifn!("llvm.ctlz.i32" fn(t_i32, i1) -> t_i32);
-    ifn!("llvm.ctlz.i64" fn(t_i64, i1) -> t_i64);
-
-    ifn!("llvm.cttz.i8" fn(t_i8 , i1) -> t_i8);
-    ifn!("llvm.cttz.i16" fn(t_i16, i1) -> t_i16);
-    ifn!("llvm.cttz.i32" fn(t_i32, i1) -> t_i32);
-    ifn!("llvm.cttz.i64" fn(t_i64, i1) -> t_i64);
-
-    ifn!("llvm.bswap.i16" fn(t_i16) -> t_i16);
-    ifn!("llvm.bswap.i32" fn(t_i32) -> t_i32);
-    ifn!("llvm.bswap.i64" fn(t_i64) -> t_i64);
-
-    ifn!("llvm.sadd.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
-    ifn!("llvm.sadd.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
-    ifn!("llvm.sadd.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
-    ifn!("llvm.sadd.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
-
-    ifn!("llvm.uadd.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
-    ifn!("llvm.uadd.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
-    ifn!("llvm.uadd.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
-    ifn!("llvm.uadd.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
-
-    ifn!("llvm.ssub.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
-    ifn!("llvm.ssub.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
-    ifn!("llvm.ssub.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
-    ifn!("llvm.ssub.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
-
-    ifn!("llvm.usub.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
-    ifn!("llvm.usub.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
-    ifn!("llvm.usub.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
-    ifn!("llvm.usub.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
-
-    ifn!("llvm.smul.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
-    ifn!("llvm.smul.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
-    ifn!("llvm.smul.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
-    ifn!("llvm.smul.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
-
-    ifn!("llvm.umul.with.overflow.i8" fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
-    ifn!("llvm.umul.with.overflow.i16" fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
-    ifn!("llvm.umul.with.overflow.i32" fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
-    ifn!("llvm.umul.with.overflow.i64" fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
-
-    ifn!("llvm.lifetime.start" fn(t_i64,i8p) -> void);
-    ifn!("llvm.lifetime.end" fn(t_i64, i8p) -> void);
-
-    ifn!("llvm.expect.i1" fn(i1, i1) -> i1);
-    ifn!("llvm.assume" fn(i1) -> void);
+    ifn!("llvm.memcpy.p0i8.p0i8.i32", fn(i8p, i8p, t_i32, t_i32, i1) -> void);
+    ifn!("llvm.memcpy.p0i8.p0i8.i64", fn(i8p, i8p, t_i64, t_i32, i1) -> void);
+    ifn!("llvm.memmove.p0i8.p0i8.i32", fn(i8p, i8p, t_i32, t_i32, i1) -> void);
+    ifn!("llvm.memmove.p0i8.p0i8.i64", fn(i8p, i8p, t_i64, t_i32, i1) -> void);
+    ifn!("llvm.memset.p0i8.i32", fn(i8p, t_i8, t_i32, t_i32, i1) -> void);
+    ifn!("llvm.memset.p0i8.i64", fn(i8p, t_i8, t_i64, t_i32, i1) -> void);
+
+    ifn!("llvm.trap", fn() -> void);
+    ifn!("llvm.debugtrap", fn() -> void);
+    ifn!("llvm.frameaddress", fn(t_i32) -> i8p);
+
+    ifn!("llvm.powi.f32", fn(t_f32, t_i32) -> t_f32);
+    ifn!("llvm.powi.f64", fn(t_f64, t_i32) -> t_f64);
+    ifn!("llvm.pow.f32", fn(t_f32, t_f32) -> t_f32);
+    ifn!("llvm.pow.f64", fn(t_f64, t_f64) -> t_f64);
+
+    ifn!("llvm.sqrt.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.sqrt.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.sin.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.sin.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.cos.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.cos.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.exp.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.exp.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.exp2.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.exp2.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.log.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.log.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.log10.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.log10.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.log2.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.log2.f64", fn(t_f64) -> t_f64);
+
+    ifn!("llvm.fma.f32", fn(t_f32, t_f32, t_f32) -> t_f32);
+    ifn!("llvm.fma.f64", fn(t_f64, t_f64, t_f64) -> t_f64);
+
+    ifn!("llvm.fabs.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.fabs.f64", fn(t_f64) -> t_f64);
+
+    ifn!("llvm.floor.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.floor.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.ceil.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.ceil.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.trunc.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.trunc.f64", fn(t_f64) -> t_f64);
+
+    ifn!("llvm.rint.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.rint.f64", fn(t_f64) -> t_f64);
+    ifn!("llvm.nearbyint.f32", fn(t_f32) -> t_f32);
+    ifn!("llvm.nearbyint.f64", fn(t_f64) -> t_f64);
+
+    ifn!("llvm.ctpop.i8", fn(t_i8) -> t_i8);
+    ifn!("llvm.ctpop.i16", fn(t_i16) -> t_i16);
+    ifn!("llvm.ctpop.i32", fn(t_i32) -> t_i32);
+    ifn!("llvm.ctpop.i64", fn(t_i64) -> t_i64);
+
+    ifn!("llvm.ctlz.i8", fn(t_i8 , i1) -> t_i8);
+    ifn!("llvm.ctlz.i16", fn(t_i16, i1) -> t_i16);
+    ifn!("llvm.ctlz.i32", fn(t_i32, i1) -> t_i32);
+    ifn!("llvm.ctlz.i64", fn(t_i64, i1) -> t_i64);
+
+    ifn!("llvm.cttz.i8", fn(t_i8 , i1) -> t_i8);
+    ifn!("llvm.cttz.i16", fn(t_i16, i1) -> t_i16);
+    ifn!("llvm.cttz.i32", fn(t_i32, i1) -> t_i32);
+    ifn!("llvm.cttz.i64", fn(t_i64, i1) -> t_i64);
+
+    ifn!("llvm.bswap.i16", fn(t_i16) -> t_i16);
+    ifn!("llvm.bswap.i32", fn(t_i32) -> t_i32);
+    ifn!("llvm.bswap.i64", fn(t_i64) -> t_i64);
+
+    ifn!("llvm.sadd.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
+    ifn!("llvm.sadd.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
+    ifn!("llvm.sadd.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
+    ifn!("llvm.sadd.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
+
+    ifn!("llvm.uadd.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
+    ifn!("llvm.uadd.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
+    ifn!("llvm.uadd.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
+    ifn!("llvm.uadd.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
+
+    ifn!("llvm.ssub.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
+    ifn!("llvm.ssub.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
+    ifn!("llvm.ssub.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
+    ifn!("llvm.ssub.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
+
+    ifn!("llvm.usub.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
+    ifn!("llvm.usub.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
+    ifn!("llvm.usub.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
+    ifn!("llvm.usub.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
+
+    ifn!("llvm.smul.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
+    ifn!("llvm.smul.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
+    ifn!("llvm.smul.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
+    ifn!("llvm.smul.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
+
+    ifn!("llvm.umul.with.overflow.i8", fn(t_i8, t_i8) -> mk_struct!{t_i8, i1});
+    ifn!("llvm.umul.with.overflow.i16", fn(t_i16, t_i16) -> mk_struct!{t_i16, i1});
+    ifn!("llvm.umul.with.overflow.i32", fn(t_i32, t_i32) -> mk_struct!{t_i32, i1});
+    ifn!("llvm.umul.with.overflow.i64", fn(t_i64, t_i64) -> mk_struct!{t_i64, i1});
+
+    ifn!("llvm.lifetime.start", fn(t_i64,i8p) -> void);
+    ifn!("llvm.lifetime.end", fn(t_i64, i8p) -> void);
+
+    ifn!("llvm.expect.i1", fn(i1, i1) -> i1);
+    ifn!("llvm.assume", fn(i1) -> void);
 
     // Some intrinsics were introduced in later versions of LLVM, but they have
     // fallbacks in libc or libm and such. Currently, all of these intrinsics
@@ -882,7 +882,7 @@ macro_rules! compatible_ifn {
         ($name:expr, $cname:ident ($($arg:expr),*) -> $ret:expr) => (
             if unsafe { llvm::LLVMVersionMinor() >= 4 } {
                 // The `if key == $name` is already in ifn!
-                ifn!($name fn($($arg),*) -> $ret);
+                ifn!($name, fn($($arg),*) -> $ret);
             } else if *key == $name {
                 let f = base::decl_cdecl_fn(ccx, stringify!($cname),
                                       Type::func(&[$($arg),*], &$ret),
@@ -900,8 +900,8 @@ macro_rules! compatible_ifn {
 
 
     if ccx.sess().opts.debuginfo != NoDebugInfo {
-        ifn!("llvm.dbg.declare" fn(Type::metadata(ccx), Type::metadata(ccx)) -> void);
-        ifn!("llvm.dbg.value" fn(Type::metadata(ccx), t_i64, Type::metadata(ccx)) -> void);
+        ifn!("llvm.dbg.declare", fn(Type::metadata(ccx), Type::metadata(ccx)) -> void);
+        ifn!("llvm.dbg.value", fn(Type::metadata(ccx), t_i64, Type::metadata(ccx)) -> void);
     }
     return None;
 }
index 768de89d5935d0803c44427b6d66e2cfcc751f2e..38d40a8322f900ae728f9ebe899d08b310f63fe8 100644 (file)
@@ -48,7 +48,7 @@ pub fn trans_stmt<'blk, 'tcx>(cx: Block<'blk, 'tcx>,
     debug!("trans_stmt({})", s.repr(cx.tcx()));
 
     if cx.sess().asm_comments() {
-        add_span_comment(cx, s.span, s.repr(cx.tcx())[]);
+        add_span_comment(cx, s.span, s.repr(cx.tcx()).index(&FullRange));
     }
 
     let mut bcx = cx;
@@ -188,7 +188,7 @@ pub fn trans_if<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     }
 
     let name = format!("then-block-{}-", thn.id);
-    let then_bcx_in = bcx.fcx.new_id_block(name[], thn.id);
+    let then_bcx_in = bcx.fcx.new_id_block(name.index(&FullRange), thn.id);
     let then_bcx_out = trans_block(then_bcx_in, &*thn, dest);
     trans::debuginfo::clear_source_location(bcx.fcx);
 
@@ -265,7 +265,8 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                              pat: &ast::Pat,
                              head: &ast::Expr,
                              body: &ast::Block)
-                             -> Block<'blk, 'tcx> {
+                             -> Block<'blk, 'tcx>
+{
     let _icx = push_ctxt("trans_for");
 
     //            bcx
@@ -306,7 +307,9 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                                      .borrow())[method_call]
                                      .ty;
     let method_type = monomorphize_type(loopback_bcx_in, method_type);
-    let method_result_type = ty::ty_fn_ret(method_type).unwrap();
+    let method_result_type =
+        ty::assert_no_late_bound_regions( // LB regions are instantiated in invoked methods
+            loopback_bcx_in.tcx(), &ty::ty_fn_ret(method_type)).unwrap();
     let option_cleanup_scope = body_bcx_in.fcx.push_custom_cleanup_scope();
     let option_cleanup_scope_id = cleanup::CustomScope(option_cleanup_scope);
 
@@ -436,8 +439,8 @@ pub fn trans_break_cont<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             match bcx.tcx().def_map.borrow().get(&expr_id) {
                 Some(&def::DefLabel(loop_id)) => loop_id,
                 ref r => {
-                    bcx.tcx().sess.bug(format!("{} in def-map for label",
-                                               r)[])
+                    bcx.tcx().sess.bug(format!("{:?} in def-map for label",
+                                               r).index(&FullRange))
                 }
             }
         }
@@ -501,7 +504,7 @@ pub fn trans_fail<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     let v_str = C_str_slice(ccx, fail_str);
     let loc = bcx.sess().codemap().lookup_char_pos(sp.lo);
-    let filename = token::intern_and_get_ident(loc.file.name[]);
+    let filename = token::intern_and_get_ident(loc.file.name.index(&FullRange));
     let filename = C_str_slice(ccx, filename);
     let line = C_uint(ccx, loc.line);
     let expr_file_line_const = C_struct(ccx, &[v_str, filename, line], false);
@@ -510,7 +513,7 @@ pub fn trans_fail<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let did = langcall(bcx, Some(sp), "", PanicFnLangItem);
     let bcx = callee::trans_lang_call(bcx,
                                       did,
-                                      args[],
+                                      args.index(&FullRange),
                                       Some(expr::Ignore)).bcx;
     Unreachable(bcx);
     return bcx;
@@ -526,7 +529,7 @@ pub fn trans_fail_bounds_check<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     // Extract the file/line from the span
     let loc = bcx.sess().codemap().lookup_char_pos(sp.lo);
-    let filename = token::intern_and_get_ident(loc.file.name[]);
+    let filename = token::intern_and_get_ident(loc.file.name.index(&FullRange));
 
     // Invoke the lang item
     let filename = C_str_slice(ccx,  filename);
@@ -537,7 +540,7 @@ pub fn trans_fail_bounds_check<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let did = langcall(bcx, Some(sp), "", PanicBoundsCheckFnLangItem);
     let bcx = callee::trans_lang_call(bcx,
                                       did,
-                                      args[],
+                                      args.index(&FullRange),
                                       Some(expr::Ignore)).bcx;
     Unreachable(bcx);
     return bcx;
index d73b3f6b4e420e9ab27b9f153942dafad1129148..26518d4092fa3d7b2710d5b38760ba5356cf0100 100644 (file)
@@ -464,7 +464,7 @@ pub fn get_element<'blk, F>(&self, bcx: Block<'blk, 'tcx>, ty: Ty<'tcx>,
             }
             _ => bcx.tcx().sess.bug(
                 format!("Unexpected unsized type in get_element: {}",
-                        bcx.ty_to_string(self.ty))[])
+                        bcx.ty_to_string(self.ty)).index(&FullRange))
         };
         Datum {
             val: val,
@@ -552,7 +552,7 @@ pub fn shallow_copy<'blk>(&self,
 
     #[allow(dead_code)] // useful for debugging
     pub fn to_string<'a>(&self, ccx: &CrateContext<'a, 'tcx>) -> String {
-        format!("Datum({}, {}, {})",
+        format!("Datum({}, {}, {:?})",
                 ccx.tn().val_to_string(self.val),
                 ty_to_string(ccx.tcx(), self.ty),
                 self.kind)
index 3f0f7fd9bd3032564c37beff27febf777b1aecb3..e2e1b3a799bfc82f0cbce46786b8dec5171291c7 100644 (file)
@@ -285,7 +285,7 @@ fn register_type_with_metadata<'a>(&mut self,
                                        metadata: DIType) {
         if self.type_to_metadata.insert(type_, metadata).is_some() {
             cx.sess().bug(format!("Type metadata for Ty '{}' is already in the TypeMap!",
-                                   ppaux::ty_to_string(cx.tcx(), type_))[]);
+                                   ppaux::ty_to_string(cx.tcx(), type_)).index(&FullRange));
         }
     }
 
@@ -298,7 +298,7 @@ fn register_unique_id_with_metadata(&mut self,
         if self.unique_id_to_metadata.insert(unique_type_id, metadata).is_some() {
             let unique_type_id_str = self.get_unique_type_id_as_string(unique_type_id);
             cx.sess().bug(format!("Type metadata for unique id '{}' is already in the TypeMap!",
-                                  unique_type_id_str[])[]);
+                                  unique_type_id_str.index(&FullRange)).index(&FullRange));
         }
     }
 
@@ -335,13 +335,13 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
         // unique ptr (~)       -> {~ :pointee-uid:}
         // @-ptr (@)            -> {@ :pointee-uid:}
         // sized vec ([T; x])   -> {[:size:] :element-uid:}
-        // unsized vec ([T])    -> {[] :element-uid:}
+        // unsized vec ([T])    -> {.index(&FullRange) :element-uid:}
         // trait (T)            -> {trait_:svh: / :node-id:_<(:param-uid:),*> }
         // closure              -> {<unsafe_> <once_> :store-sigil: |(:param-uid:),* <,_...>| -> \
         //                             :return-type-uid: : (:bounds:)*}
         // function             -> {<unsafe_> <abi_> fn( (:param-uid:)* <,_...> ) -> \
         //                             :return-type-uid:}
-        // unique vec box (~[]) -> {HEAP_VEC_BOX<:pointee-uid:>}
+        // unique vec box (~.index(&FullRange)) -> {HEAP_VEC_BOX<:pointee-uid:>}
         // gc box               -> {GC_BOX<:pointee-uid:>}
 
         match self.type_to_unique_id.get(&type_).cloned() {
@@ -379,14 +379,14 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
                         self.get_unique_type_id_of_type(cx, component_type);
                     let component_type_id =
                         self.get_unique_type_id_as_string(component_type_id);
-                    unique_type_id.push_str(component_type_id[]);
+                    unique_type_id.push_str(component_type_id.index(&FullRange));
                 }
             },
             ty::ty_uniq(inner_type) => {
                 unique_type_id.push('~');
                 let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
                 let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
-                unique_type_id.push_str(inner_type_id[]);
+                unique_type_id.push_str(inner_type_id.index(&FullRange));
             },
             ty::ty_ptr(ty::mt { ty: inner_type, mutbl } ) => {
                 unique_type_id.push('*');
@@ -396,7 +396,7 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
 
                 let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
                 let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
-                unique_type_id.push_str(inner_type_id[]);
+                unique_type_id.push_str(inner_type_id.index(&FullRange));
             },
             ty::ty_rptr(_, ty::mt { ty: inner_type, mutbl }) => {
                 unique_type_id.push('&');
@@ -406,12 +406,12 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
 
                 let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
                 let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
-                unique_type_id.push_str(inner_type_id[]);
+                unique_type_id.push_str(inner_type_id.index(&FullRange));
             },
             ty::ty_vec(inner_type, optional_length) => {
                 match optional_length {
                     Some(len) => {
-                        unique_type_id.push_str(format!("[{}]", len)[]);
+                        unique_type_id.push_str(format!("[{}]", len).index(&FullRange));
                     }
                     None => {
                         unique_type_id.push_str("[]");
@@ -420,15 +420,19 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
 
                 let inner_type_id = self.get_unique_type_id_of_type(cx, inner_type);
                 let inner_type_id = self.get_unique_type_id_as_string(inner_type_id);
-                unique_type_id.push_str(inner_type_id[]);
+                unique_type_id.push_str(inner_type_id.index(&FullRange));
             },
             ty::ty_trait(ref trait_data) => {
                 unique_type_id.push_str("trait ");
 
+                let principal =
+                    ty::erase_late_bound_regions(cx.tcx(),
+                                                 &trait_data.principal);
+
                 from_def_id_and_substs(self,
                                        cx,
-                                       trait_data.principal_def_id(),
-                                       trait_data.principal.0.substs,
+                                       principal.def_id,
+                                       principal.substs,
                                        &mut unique_type_id);
             },
             ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
@@ -440,25 +444,27 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
 
                 unique_type_id.push_str(" fn(");
 
-                for &parameter_type in sig.0.inputs.iter() {
+                let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
+
+                for &parameter_type in sig.inputs.iter() {
                     let parameter_type_id =
                         self.get_unique_type_id_of_type(cx, parameter_type);
                     let parameter_type_id =
                         self.get_unique_type_id_as_string(parameter_type_id);
-                    unique_type_id.push_str(parameter_type_id[]);
+                    unique_type_id.push_str(parameter_type_id.index(&FullRange));
                     unique_type_id.push(',');
                 }
 
-                if sig.0.variadic {
+                if sig.variadic {
                     unique_type_id.push_str("...");
                 }
 
                 unique_type_id.push_str(")->");
-                match sig.0.output {
+                match sig.output {
                     ty::FnConverging(ret_ty) => {
                         let return_type_id = self.get_unique_type_id_of_type(cx, ret_ty);
                         let return_type_id = self.get_unique_type_id_as_string(return_type_id);
-                        unique_type_id.push_str(return_type_id[]);
+                        unique_type_id.push_str(return_type_id.index(&FullRange));
                     }
                     ty::FnDiverging => {
                         unique_type_id.push_str("!");
@@ -473,9 +479,9 @@ fn get_unique_type_id_of_type<'a>(&mut self, cx: &CrateContext<'a, 'tcx>,
                                                         &mut unique_type_id);
             },
             _ => {
-                cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {}",
-                                      ppaux::ty_to_string(cx.tcx(), type_)[],
-                                      type_.sty)[])
+                cx.sess().bug(format!("get_unique_type_id_of_type() - unexpected type: {}, {:?}",
+                                      ppaux::ty_to_string(cx.tcx(), type_).index(&FullRange),
+                                      type_.sty).index(&FullRange))
             }
         };
 
@@ -518,7 +524,7 @@ fn from_def_id_and_substs<'a, 'tcx>(type_map: &mut TypeMap<'tcx>,
 
             output.push_str(crate_hash.as_str());
             output.push_str("/");
-            output.push_str(format!("{:x}", def_id.node)[]);
+            output.push_str(format!("{:x}", def_id.node).index(&FullRange));
 
             // Maybe check that there is no self type here.
 
@@ -531,7 +537,7 @@ fn from_def_id_and_substs<'a, 'tcx>(type_map: &mut TypeMap<'tcx>,
                         type_map.get_unique_type_id_of_type(cx, type_parameter);
                     let param_type_id =
                         type_map.get_unique_type_id_as_string(param_type_id);
-                    output.push_str(param_type_id[]);
+                    output.push_str(param_type_id.index(&FullRange));
                     output.push(',');
                 }
 
@@ -568,26 +574,28 @@ fn get_unique_type_id_of_closure_type<'a>(&mut self,
             }
         };
 
-        for &parameter_type in sig.0.inputs.iter() {
+        let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
+
+        for &parameter_type in sig.inputs.iter() {
             let parameter_type_id =
                 self.get_unique_type_id_of_type(cx, parameter_type);
             let parameter_type_id =
                 self.get_unique_type_id_as_string(parameter_type_id);
-            unique_type_id.push_str(parameter_type_id[]);
+            unique_type_id.push_str(parameter_type_id.index(&FullRange));
             unique_type_id.push(',');
         }
 
-        if sig.0.variadic {
+        if sig.variadic {
             unique_type_id.push_str("...");
         }
 
         unique_type_id.push_str("|->");
 
-        match sig.0.output {
+        match sig.output {
             ty::FnConverging(ret_ty) => {
                 let return_type_id = self.get_unique_type_id_of_type(cx, ret_ty);
                 let return_type_id = self.get_unique_type_id_as_string(return_type_id);
-                unique_type_id.push_str(return_type_id[]);
+                unique_type_id.push_str(return_type_id.index(&FullRange));
             }
             ty::FnDiverging => {
                 unique_type_id.push_str("!");
@@ -618,7 +626,7 @@ fn get_unique_type_id_of_enum_variant<'a>(&mut self,
         let enum_type_id = self.get_unique_type_id_of_type(cx, enum_type);
         let enum_variant_type_id = format!("{}::{}",
                                            self.get_unique_type_id_as_string(enum_type_id)
-                                               [],
+                                               .index(&FullRange),
                                            variant_name);
         let interner_key = self.unique_id_interner.intern(Rc::new(enum_variant_type_id));
         UniqueTypeId(interner_key)
@@ -798,20 +806,20 @@ pub fn create_global_var_metadata(cx: &CrateContext,
                                 format!("debuginfo::\
                                          create_global_var_metadata() -
                                          Captured var-id refers to \
-                                         unexpected ast_item variant: {}",
-                                        var_item)[])
+                                         unexpected ast_item variant: {:?}",
+                                        var_item).index(&FullRange))
                 }
             }
         },
         _ => cx.sess().bug(format!("debuginfo::create_global_var_metadata() \
                                     - Captured var-id refers to unexpected \
-                                    ast_map variant: {}",
-                                   var_item)[])
+                                    ast_map variant: {:?}",
+                                   var_item).index(&FullRange))
     };
 
     let (file_metadata, line_number) = if span != codemap::DUMMY_SP {
         let loc = span_start(cx, span);
-        (file_metadata(cx, loc.file.name[]), loc.line as c_uint)
+        (file_metadata(cx, loc.file.name.index(&FullRange)), loc.line as c_uint)
     } else {
         (UNKNOWN_FILE_METADATA, UNKNOWN_LINE_NUMBER)
     };
@@ -822,7 +830,7 @@ pub fn create_global_var_metadata(cx: &CrateContext,
     let namespace_node = namespace_for_item(cx, ast_util::local_def(node_id));
     let var_name = token::get_ident(ident).get().to_string();
     let linkage_name =
-        namespace_node.mangled_name_of_contained_item(var_name[]);
+        namespace_node.mangled_name_of_contained_item(var_name.index(&FullRange));
     let var_scope = namespace_node.scope;
 
     let var_name = CString::from_slice(var_name.as_bytes());
@@ -861,7 +869,7 @@ pub fn create_local_var_metadata(bcx: Block, local: &ast::Local) {
             None => {
                 bcx.sess().span_bug(span,
                     format!("no entry in lllocals table for {}",
-                            node_id)[]);
+                            node_id).index(&FullRange));
             }
         };
 
@@ -914,8 +922,8 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                 format!(
                                 "debuginfo::create_captured_var_metadata() - \
                                  Captured var-id refers to unexpected \
-                                 ast_map variant: {}",
-                                 ast_item)[]);
+                                 ast_map variant: {:?}",
+                                 ast_item).index(&FullRange));
                 }
             }
         }
@@ -924,8 +932,8 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
               .span_bug(span,
                         format!("debuginfo::create_captured_var_metadata() - \
                                  Captured var-id refers to unexpected \
-                                 ast_map variant: {}",
-                                ast_item)[]);
+                                 ast_map variant: {:?}",
+                                ast_item).index(&FullRange));
         }
     };
 
@@ -955,7 +963,7 @@ pub fn create_captured_var_metadata<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     let variable_access = IndirectVariable {
         alloca: env_pointer,
-        address_operations: address_operations[..address_op_count]
+        address_operations: address_operations.index(&(0..address_op_count))
     };
 
     declare_local(bcx,
@@ -1032,7 +1040,7 @@ pub fn create_argument_metadata(bcx: Block, arg: &ast::Arg) {
             None => {
                 bcx.sess().span_bug(span,
                     format!("no entry in lllocals table for {}",
-                            node_id)[]);
+                            node_id).index(&FullRange));
             }
         };
 
@@ -1146,7 +1154,7 @@ pub fn get_cleanup_debug_loc_for_ast_node<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         if let Some(code_snippet) = code_snippet {
             let bytes = code_snippet.as_bytes();
 
-            if bytes.len() > 0 && bytes[bytes.len()-1 ..] == b"}" {
+            if bytes.len() > 0 && bytes.index(&((bytes.len()-1)..)) == b"}" {
                 cleanup_span = Span {
                     lo: node_span.hi - codemap::BytePos(1),
                     hi: node_span.hi,
@@ -1290,7 +1298,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             match expr.node {
                 ast::ExprClosure(_, _, ref fn_decl, ref top_level_block) => {
                     let name = format!("fn{}", token::gensym("fn"));
-                    let name = token::str_to_ident(name[]);
+                    let name = token::str_to_ident(name.index(&FullRange));
                     (name, &**fn_decl,
                         // This is not quite right. It should actually inherit
                         // the generics of the enclosing function.
@@ -1321,8 +1329,8 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 _ => {
                     cx.sess()
                       .bug(format!("create_function_debug_context: \
-                                    unexpected sort of node: {}",
-                                    fnitem)[])
+                                    unexpected sort of node: {:?}",
+                                    fnitem).index(&FullRange))
                 }
             }
         }
@@ -1332,8 +1340,8 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             return FunctionDebugContext::FunctionWithoutDebugInfo;
         }
         _ => cx.sess().bug(format!("create_function_debug_context: \
-                                    unexpected sort of node: {}",
-                                   fnitem)[])
+                                    unexpected sort of node: {:?}",
+                                   fnitem).index(&FullRange))
     };
 
     // This can be the case for functions inlined from another crate
@@ -1342,7 +1350,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     }
 
     let loc = span_start(cx, span);
-    let file_metadata = file_metadata(cx, loc.file.name[]);
+    let file_metadata = file_metadata(cx, loc.file.name.index(&FullRange));
 
     let function_type_metadata = unsafe {
         let fn_signature = get_function_signature(cx,
@@ -1369,7 +1377,7 @@ pub fn create_function_debug_context<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     let (linkage_name, containing_scope) = if has_path {
         let namespace_node = namespace_for_item(cx, ast_util::local_def(fn_ast_id));
         let linkage_name = namespace_node.mangled_name_of_contained_item(
-            function_name[]);
+            function_name.index(&FullRange));
         let containing_scope = namespace_node.scope;
         (linkage_name, containing_scope)
     } else {
@@ -1457,7 +1465,7 @@ fn get_function_signature<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             signature.push(type_metadata(cx, arg_type, codemap::DUMMY_SP));
         }
 
-        return create_DIArray(DIB(cx), signature[]);
+        return create_DIArray(DIB(cx), signature.index(&FullRange));
     }
 
     fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
@@ -1492,7 +1500,7 @@ fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 actual_self_type,
                 true);
 
-            name_to_append_suffix_to.push_str(actual_self_type_name[]);
+            name_to_append_suffix_to.push_str(actual_self_type_name.index(&FullRange));
 
             if generics.is_type_parameterized() {
                 name_to_append_suffix_to.push_str(",");
@@ -1531,7 +1539,7 @@ fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             let actual_type_name = compute_debuginfo_type_name(cx,
                                                                actual_type,
                                                                true);
-            name_to_append_suffix_to.push_str(actual_type_name[]);
+            name_to_append_suffix_to.push_str(actual_type_name.index(&FullRange));
 
             if index != generics.ty_params.len() - 1 {
                 name_to_append_suffix_to.push_str(",");
@@ -1558,7 +1566,7 @@ fn get_template_parameters<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
         name_to_append_suffix_to.push('>');
 
-        return create_DIArray(DIB(cx), template_params[]);
+        return create_DIArray(DIB(cx), template_params.index(&FullRange));
     }
 }
 
@@ -1615,7 +1623,7 @@ fn compile_unit_metadata(cx: &CrateContext) -> DIDescriptor {
         }
     };
 
-    debug!("compile_unit_metadata: {}", compile_unit_name);
+    debug!("compile_unit_metadata: {:?}", compile_unit_name);
     let producer = format!("rustc version {}",
                            (option_env!("CFG_VERSION")).expect("CFG_VERSION"));
 
@@ -1652,7 +1660,7 @@ fn declare_local<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let cx: &CrateContext = bcx.ccx();
 
     let filename = span_start(cx, span).file.name.clone();
-    let file_metadata = file_metadata(cx, filename[]);
+    let file_metadata = file_metadata(cx, filename.index(&FullRange));
 
     let name = token::get_ident(variable_ident);
     let loc = span_start(cx, span);
@@ -1738,7 +1746,7 @@ fn file_metadata(cx: &CrateContext, full_path: &str) -> DIFile {
     let work_dir = cx.sess().working_dir.as_str().unwrap();
     let file_name =
         if full_path.starts_with(work_dir) {
-            full_path[work_dir.len() + 1u..full_path.len()]
+            full_path.index(&((work_dir.len() + 1u)..full_path.len()))
         } else {
             full_path
         };
@@ -1769,8 +1777,8 @@ fn scope_metadata(fcx: &FunctionContext,
             let node = fcx.ccx.tcx().map.get(node_id);
 
             fcx.ccx.sess().span_bug(error_reporting_span,
-                format!("debuginfo: Could not find scope info for node {}",
-                        node)[]);
+                format!("debuginfo: Could not find scope info for node {:?}",
+                        node).index(&FullRange));
         }
     }
 }
@@ -1789,7 +1797,7 @@ fn diverging_type_metadata(cx: &CrateContext) -> DIType {
 fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                  t: Ty<'tcx>) -> DIType {
 
-    debug!("basic_type_metadata: {}", t);
+    debug!("basic_type_metadata: {:?}", t);
 
     let (name, encoding) = match t.sty {
         ty::ty_tup(ref elements) if elements.is_empty() =>
@@ -1797,14 +1805,14 @@ fn basic_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_bool => ("bool".to_string(), DW_ATE_boolean),
         ty::ty_char => ("char".to_string(), DW_ATE_unsigned_char),
         ty::ty_int(int_ty) => match int_ty {
-            ast::TyI => ("int".to_string(), DW_ATE_signed),
+            ast::TyIs => ("isize".to_string(), DW_ATE_signed),
             ast::TyI8 => ("i8".to_string(), DW_ATE_signed),
             ast::TyI16 => ("i16".to_string(), DW_ATE_signed),
             ast::TyI32 => ("i32".to_string(), DW_ATE_signed),
             ast::TyI64 => ("i64".to_string(), DW_ATE_signed)
         },
         ty::ty_uint(uint_ty) => match uint_ty {
-            ast::TyU => ("uint".to_string(), DW_ATE_unsigned),
+            ast::TyUs => ("usize".to_string(), DW_ATE_unsigned),
             ast::TyU8 => ("u8".to_string(), DW_ATE_unsigned),
             ast::TyU16 => ("u16".to_string(), DW_ATE_unsigned),
             ast::TyU32 => ("u32".to_string(), DW_ATE_unsigned),
@@ -1966,7 +1974,7 @@ fn finalize<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> MetadataCreationResult {
                         cx.sess().bug(format!("Forward declaration of potentially recursive type \
                                               '{}' was not found in TypeMap!",
                                               ppaux::ty_to_string(cx.tcx(), unfinished_type))
-                                      []);
+                                      .index(&FullRange));
                     }
                 }
 
@@ -1978,7 +1986,7 @@ fn finalize<'a>(&self, cx: &CrateContext<'a, 'tcx>) -> MetadataCreationResult {
                 set_members_of_composite_type(cx,
                                               metadata_stub,
                                               llvm_type,
-                                              member_descriptions[]);
+                                              member_descriptions.index(&FullRange));
                 return MetadataCreationResult::new(metadata_stub, true);
             }
         }
@@ -2050,7 +2058,7 @@ fn prepare_struct_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
     let struct_metadata_stub = create_struct_stub(cx,
                                                   struct_llvm_type,
-                                                  struct_name[],
+                                                  struct_name.index(&FullRange),
                                                   unique_type_id,
                                                   containing_scope);
 
@@ -2111,7 +2119,7 @@ fn prepare_tuple_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         unique_type_id,
         create_struct_stub(cx,
                            tuple_llvm_type,
-                           tuple_name[],
+                           tuple_name.index(&FullRange),
                            unique_type_id,
                            UNKNOWN_SCOPE_METADATA),
         tuple_llvm_type,
@@ -2171,7 +2179,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
                         set_members_of_composite_type(cx,
                                                       variant_type_metadata,
                                                       variant_llvm_type,
-                                                      member_descriptions[]);
+                                                      member_descriptions.index(&FullRange));
                         MemberDescription {
                             name: "".to_string(),
                             llvm_type: variant_llvm_type,
@@ -2204,7 +2212,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
                     set_members_of_composite_type(cx,
                                                   variant_type_metadata,
                                                   variant_llvm_type,
-                                                  member_descriptions[]);
+                                                  member_descriptions.index(&FullRange));
                     vec![
                         MemberDescription {
                             name: "".to_string(),
@@ -2304,7 +2312,7 @@ fn create_member_descriptions<'a>(&self, cx: &CrateContext<'a, 'tcx>)
                 set_members_of_composite_type(cx,
                                               variant_type_metadata,
                                               variant_llvm_type,
-                                              variant_member_descriptions[]);
+                                              variant_member_descriptions.index(&FullRange));
 
                 // Encode the information about the null variant in the union
                 // member's name.
@@ -2383,7 +2391,7 @@ fn describe_enum_variant<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                     .iter()
                                     .map(|&t| type_of::type_of(cx, t))
                                     .collect::<Vec<_>>()
-                                    [],
+                                    .index(&FullRange),
                       struct_def.packed);
     // Could do some consistency checks here: size, align, field count, discr type
 
@@ -2450,7 +2458,7 @@ fn prepare_enum_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
     let (containing_scope, definition_span) = get_namespace_and_span_for_item(cx, enum_def_id);
     let loc = span_start(cx, definition_span);
-    let file_metadata = file_metadata(cx, loc.file.name[]);
+    let file_metadata = file_metadata(cx, loc.file.name.index(&FullRange));
 
     let variants = ty::enum_variants(cx.tcx(), enum_def_id);
 
@@ -2637,7 +2645,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
                                         Please use a rustc built with anewer \
                                         version of LLVM.",
                                        llvm_version_major,
-                                       llvm_version_minor)[]);
+                                       llvm_version_minor).index(&FullRange));
             } else {
                 cx.sess().bug("debuginfo::set_members_of_composite_type() - \
                                Already completed forward declaration re-encountered.");
@@ -2675,7 +2683,7 @@ fn set_members_of_composite_type(cx: &CrateContext,
         .collect();
 
     unsafe {
-        let type_array = create_DIArray(DIB(cx), member_metadata[]);
+        let type_array = create_DIArray(DIB(cx), member_metadata.index(&FullRange));
         llvm::LLVMDICompositeTypeSetTypeArray(composite_type_metadata, type_array);
     }
 }
@@ -2774,7 +2782,7 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
     let member_llvm_types = slice_llvm_type.field_types();
     assert!(slice_layout_is_correct(cx,
-                                    member_llvm_types[],
+                                    member_llvm_types.index(&FullRange),
                                     element_type));
     let member_descriptions = [
         MemberDescription {
@@ -2796,11 +2804,11 @@ fn vec_slice_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     assert!(member_descriptions.len() == member_llvm_types.len());
 
     let loc = span_start(cx, span);
-    let file_metadata = file_metadata(cx, loc.file.name[]);
+    let file_metadata = file_metadata(cx, loc.file.name.index(&FullRange));
 
     let metadata = composite_type_metadata(cx,
                                            slice_llvm_type,
-                                           slice_type_name[],
+                                           slice_type_name.index(&FullRange),
                                            unique_type_id,
                                            &member_descriptions,
                                            UNKNOWN_SCOPE_METADATA,
@@ -2822,11 +2830,14 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                       unique_type_id: UniqueTypeId,
                                       signature: &ty::PolyFnSig<'tcx>,
                                       span: Span)
-                                      -> MetadataCreationResult {
-    let mut signature_metadata: Vec<DIType> = Vec::with_capacity(signature.0.inputs.len() + 1);
+                                      -> MetadataCreationResult
+{
+    let signature = ty::erase_late_bound_regions(cx.tcx(), signature);
+
+    let mut signature_metadata: Vec<DIType> = Vec::with_capacity(signature.inputs.len() + 1);
 
     // return type
-    signature_metadata.push(match signature.0.output {
+    signature_metadata.push(match signature.output {
         ty::FnConverging(ret_ty) => match ret_ty.sty {
             ty::ty_tup(ref tys) if tys.is_empty() => ptr::null_mut(),
             _ => type_metadata(cx, ret_ty, span)
@@ -2835,7 +2846,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     });
 
     // regular arguments
-    for &argument_type in signature.0.inputs.iter() {
+    for &argument_type in signature.inputs.iter() {
         signature_metadata.push(type_metadata(cx, argument_type, span));
     }
 
@@ -2846,7 +2857,7 @@ fn subroutine_type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             llvm::LLVMDIBuilderCreateSubroutineType(
                 DIB(cx),
                 UNKNOWN_FILE_METADATA,
-                create_DIArray(DIB(cx), signature_metadata[]))
+                create_DIArray(DIB(cx), signature_metadata.index(&FullRange)))
         },
         false);
 }
@@ -2872,7 +2883,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             let pp_type_name = ppaux::ty_to_string(cx.tcx(), trait_type);
             cx.sess().bug(format!("debuginfo: Unexpected trait-object type in \
                                    trait_pointer_metadata(): {}",
-                                   pp_type_name[])[]);
+                                   pp_type_name.index(&FullRange)).index(&FullRange));
         }
     };
 
@@ -2886,7 +2897,7 @@ fn trait_pointer_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
     composite_type_metadata(cx,
                             trait_llvm_type,
-                            trait_type_name[],
+                            trait_type_name.index(&FullRange),
                             unique_type_id,
                             &[],
                             containing_scope,
@@ -2931,7 +2942,7 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         }
     };
 
-    debug!("type_metadata: {}", t);
+    debug!("type_metadata: {:?}", t);
 
     let sty = &t.sty;
     let MetadataCreationResult { metadata, already_stored_in_typemap } = match *sty {
@@ -3006,13 +3017,13 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_tup(ref elements) => {
             prepare_tuple_metadata(cx,
                                    t,
-                                   elements[],
+                                   elements.index(&FullRange),
                                    unique_type_id,
                                    usage_site_span).finalize(cx)
         }
         _ => {
-            cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {}",
-                                  sty)[])
+            cx.sess().bug(format!("debuginfo: unexpected type in type_metadata: {:?}",
+                                  sty).index(&FullRange))
         }
     };
 
@@ -3030,9 +3041,9 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                                  type id '{}' to already be in \
                                                  the debuginfo::TypeMap but it \
                                                  was not. (Ty = {})",
-                                                unique_type_id_str[],
+                                                unique_type_id_str.index(&FullRange),
                                                 ppaux::ty_to_string(cx.tcx(), t));
-                    cx.sess().span_bug(usage_site_span, error_message[]);
+                    cx.sess().span_bug(usage_site_span, error_message.index(&FullRange));
                 }
             };
 
@@ -3045,9 +3056,9 @@ fn type_metadata<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                                      UniqueTypeId maps in \
                                                      debuginfo::TypeMap. \
                                                      UniqueTypeId={}, Ty={}",
-                            unique_type_id_str[],
+                            unique_type_id_str.index(&FullRange),
                             ppaux::ty_to_string(cx.tcx(), t));
-                        cx.sess().span_bug(usage_site_span, error_message[]);
+                        cx.sess().span_bug(usage_site_span, error_message.index(&FullRange));
                     }
                 }
                 None => {
@@ -3253,7 +3264,7 @@ fn with_new_scope<F>(cx: &CrateContext,
     {
         // Create a new lexical scope and push it onto the stack
         let loc = cx.sess().codemap().lookup_char_pos(scope_span.lo);
-        let file_metadata = file_metadata(cx, loc.file.name[]);
+        let file_metadata = file_metadata(cx, loc.file.name.index(&FullRange));
         let parent_scope = scope_stack.last().unwrap().scope_metadata;
 
         let scope_metadata = unsafe {
@@ -3375,7 +3386,7 @@ fn walk_pattern(cx: &CrateContext,
                     if need_new_scope {
                         // Create a new lexical scope and push it onto the stack
                         let loc = cx.sess().codemap().lookup_char_pos(pat.span.lo);
-                        let file_metadata = file_metadata(cx, loc.file.name[]);
+                        let file_metadata = file_metadata(cx, loc.file.name.index(&FullRange));
                         let parent_scope = scope_stack.last().unwrap().scope_metadata;
 
                         let scope_metadata = unsafe {
@@ -3729,12 +3740,12 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_bool              => output.push_str("bool"),
         ty::ty_char              => output.push_str("char"),
         ty::ty_str               => output.push_str("str"),
-        ty::ty_int(ast::TyI)     => output.push_str("int"),
+        ty::ty_int(ast::TyIs)     => output.push_str("isize"),
         ty::ty_int(ast::TyI8)    => output.push_str("i8"),
         ty::ty_int(ast::TyI16)   => output.push_str("i16"),
         ty::ty_int(ast::TyI32)   => output.push_str("i32"),
         ty::ty_int(ast::TyI64)   => output.push_str("i64"),
-        ty::ty_uint(ast::TyU)    => output.push_str("uint"),
+        ty::ty_uint(ast::TyUs)    => output.push_str("usize"),
         ty::ty_uint(ast::TyU8)   => output.push_str("u8"),
         ty::ty_uint(ast::TyU16)  => output.push_str("u16"),
         ty::ty_uint(ast::TyU32)  => output.push_str("u32"),
@@ -3794,8 +3805,9 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
             output.push(']');
         },
         ty::ty_trait(ref trait_data) => {
-            push_item_name(cx, trait_data.principal_def_id(), false, output);
-            push_type_params(cx, trait_data.principal.0.substs, output);
+            let principal = ty::erase_late_bound_regions(cx.tcx(), &trait_data.principal);
+            push_item_name(cx, principal.def_id, false, output);
+            push_type_params(cx, principal.substs, output);
         },
         ty::ty_bare_fn(_, &ty::BareFnTy{ unsafety, abi, ref sig } ) => {
             if unsafety == ast::Unsafety::Unsafe {
@@ -3810,8 +3822,9 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
             output.push_str("fn(");
 
-            if sig.0.inputs.len() > 0 {
-                for &parameter_type in sig.0.inputs.iter() {
+            let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
+            if sig.inputs.len() > 0 {
+                for &parameter_type in sig.inputs.iter() {
                     push_debuginfo_type_name(cx, parameter_type, true, output);
                     output.push_str(", ");
                 }
@@ -3819,8 +3832,8 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                 output.pop();
             }
 
-            if sig.0.variadic {
-                if sig.0.inputs.len() > 0 {
+            if sig.variadic {
+                if sig.inputs.len() > 0 {
                     output.push_str(", ...");
                 } else {
                     output.push_str("...");
@@ -3829,7 +3842,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
 
             output.push(')');
 
-            match sig.0.output {
+            match sig.output {
                 ty::FnConverging(result_type) if ty::type_is_nil(result_type) => {}
                 ty::FnConverging(result_type) => {
                     output.push_str(" -> ");
@@ -3849,7 +3862,7 @@ fn push_debuginfo_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
         ty::ty_projection(..) |
         ty::ty_param(_) => {
             cx.sess().bug(format!("debuginfo: Trying to create type name for \
-                unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t))[]);
+                unexpected type: {}", ppaux::ty_to_string(cx.tcx(), t)).index(&FullRange));
         }
     }
 
@@ -3932,13 +3945,13 @@ fn fill_nested(node: &NamespaceTreeNode, output: &mut String) {
                 None => {}
             }
             let string = token::get_name(node.name);
-            output.push_str(format!("{}", string.get().len())[]);
+            output.push_str(format!("{}", string.get().len()).index(&FullRange));
             output.push_str(string.get());
         }
 
         let mut name = String::from_str("_ZN");
         fill_nested(self, &mut name);
-        name.push_str(format!("{}", item_name.len())[]);
+        name.push_str(format!("{}", item_name.len()).index(&FullRange));
         name.push_str(item_name);
         name.push('E');
         name
@@ -3946,7 +3959,7 @@ fn fill_nested(node: &NamespaceTreeNode, output: &mut String) {
 }
 
 fn crate_root_namespace<'a>(cx: &'a CrateContext) -> &'a str {
-    cx.link_meta().crate_name[]
+    cx.link_meta().crate_name.index(&FullRange)
 }
 
 fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTreeNode> {
@@ -4022,8 +4035,8 @@ fn namespace_for_item(cx: &CrateContext, def_id: ast::DefId) -> Rc<NamespaceTree
             Some(node) => node,
             None => {
                 cx.sess().bug(format!("debuginfo::namespace_for_item(): \
-                                       path too short for {}",
-                                      def_id)[]);
+                                       path too short for {:?}",
+                                      def_id).index(&FullRange));
             }
         }
     })
index 9221ae09df98aa7ad3f5ec174cc86ae605911785..120e2e955e4be5a000fa94542139935c762433ce 100644 (file)
@@ -306,7 +306,7 @@ fn unsized_info<'blk, 'tcx, F>(bcx: Block<'blk, 'tcx>,
         // FIXME(#19596) workaround: `|t| t` causes monomorphization recursion
         fn identity<T>(t: T) -> T { t }
 
-        debug!("unsized_info(kind={}, id={}, unadjusted_ty={})",
+        debug!("unsized_info(kind={:?}, id={}, unadjusted_ty={})",
                kind, id, unadjusted_ty.repr(bcx.tcx()));
         match kind {
             &ty::UnsizeLength(len) => C_uint(bcx.ccx(), len),
@@ -318,7 +318,7 @@ fn identity<T>(t: T) -> T { t }
                     unsized_info(bcx, k, id, ty_substs[tp_index], identity)
                 }
                 _ => bcx.sess().bug(format!("UnsizeStruct with bad sty: {}",
-                                          bcx.ty_to_string(unadjusted_ty))[])
+                                          bcx.ty_to_string(unadjusted_ty)).index(&FullRange))
             },
             &ty::UnsizeVtable(ty::TyTrait { ref principal, .. }, _) => {
                 // Note that we preserve binding levels here:
@@ -451,7 +451,7 @@ fn unsize_unique_expr<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         let unboxed_ty = match datum_ty.sty {
             ty::ty_uniq(t) => t,
             _ => bcx.sess().bug(format!("Expected ty_uniq, found {}",
-                                        bcx.ty_to_string(datum_ty))[])
+                                        bcx.ty_to_string(datum_ty)).index(&FullRange))
         };
         let result_ty = ty::mk_uniq(tcx, ty::unsize_ty(tcx, unboxed_ty, k, expr.span));
 
@@ -573,40 +573,7 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             trans_rec_tup_field(bcx, &**base, idx.node)
         }
         ast::ExprIndex(ref base, ref idx) => {
-            match idx.node {
-                ast::ExprRange(ref start, ref end) => {
-                    // Special case for slicing syntax (KILLME).
-                    let _icx = push_ctxt("trans_slice");
-                    let ccx = bcx.ccx();
-
-                    let method_call = MethodCall::expr(expr.id);
-                    let method_ty = ccx.tcx()
-                                       .method_map
-                                       .borrow()
-                                       .get(&method_call)
-                                       .map(|method| method.ty);
-                    let base_datum = unpack_datum!(bcx, trans(bcx, &**base));
-
-                    let mut args = vec![];
-                    start.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
-                    end.as_ref().map(|e| args.push((unpack_datum!(bcx, trans(bcx, &**e)), e.id)));
-
-                    let result_ty = ty::ty_fn_ret(monomorphize_type(bcx,
-                                                                    method_ty.unwrap())).unwrap();
-                    let scratch = rvalue_scratch_datum(bcx, result_ty, "trans_slice");
-
-                    unpack_result!(bcx,
-                                   trans_overloaded_op(bcx,
-                                                       expr,
-                                                       method_call,
-                                                       base_datum,
-                                                       args,
-                                                       Some(SaveIn(scratch.val)),
-                                                       true));
-                    DatumBlock::new(bcx, scratch.to_expr_datum())
-                }
-                _ => trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
-            }
+            trans_index(bcx, expr, &**base, &**idx, MethodCall::expr(expr.id))
         }
         ast::ExprBox(_, ref contents) => {
             // Special case for `Box<T>`
@@ -656,8 +623,8 @@ fn trans_datum_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             bcx.tcx().sess.span_bug(
                 expr.span,
                 format!("trans_rvalue_datum_unadjusted reached \
-                         fall-through case: {}",
-                        expr.node)[]);
+                         fall-through case: {:?}",
+                        expr.node).index(&FullRange));
         }
     }
 }
@@ -732,12 +699,16 @@ fn trans_index<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                        .map(|method| method.ty);
     let elt_datum = match method_ty {
         Some(method_ty) => {
+            let method_ty = monomorphize_type(bcx, method_ty);
+
             let base_datum = unpack_datum!(bcx, trans(bcx, base));
 
             // Translate index expression.
             let ix_datum = unpack_datum!(bcx, trans(bcx, idx));
 
-            let ref_ty = ty::ty_fn_ret(monomorphize_type(bcx, method_ty)).unwrap();
+            let ref_ty = // invoked methods have LB regions instantiated:
+                ty::assert_no_late_bound_regions(
+                    bcx.tcx(), &ty::ty_fn_ret(method_ty)).unwrap();
             let elt_ty = match ty::deref(ref_ty, true) {
                 None => {
                     bcx.tcx().sess.span_bug(index_expr.span,
@@ -1005,8 +976,8 @@ fn trans_rvalue_stmt_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             bcx.tcx().sess.span_bug(
                 expr.span,
                 format!("trans_rvalue_stmt_unadjusted reached \
-                         fall-through case: {}",
-                        expr.node)[]);
+                         fall-through case: {:?}",
+                        expr.node).index(&FullRange));
         }
     }
 }
@@ -1032,14 +1003,14 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             controlflow::trans_if(bcx, expr.id, &**cond, &**thn, els.as_ref().map(|e| &**e), dest)
         }
         ast::ExprMatch(ref discr, ref arms, _) => {
-            _match::trans_match(bcx, expr, &**discr, arms[], dest)
+            _match::trans_match(bcx, expr, &**discr, arms.index(&FullRange), dest)
         }
         ast::ExprBlock(ref blk) => {
             controlflow::trans_block(bcx, &**blk, dest)
         }
         ast::ExprStruct(_, ref fields, ref base) => {
             trans_struct(bcx,
-                         fields[],
+                         fields.index(&FullRange),
                          base.as_ref().map(|e| &**e),
                          expr.span,
                          expr.id,
@@ -1104,7 +1075,7 @@ fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
             trans_adt(bcx,
                       expr_ty(bcx, expr),
                       0,
-                      numbered_fields[],
+                      numbered_fields.index(&FullRange),
                       None,
                       dest,
                       Some(NodeInfo { id: expr.id, span: expr.span }))
@@ -1148,13 +1119,13 @@ fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
                 trans_overloaded_call(bcx,
                                       expr,
                                       &**f,
-                                      args[],
+                                      args.index(&FullRange),
                                       Some(dest))
             } else {
                 callee::trans_call(bcx,
                                    expr,
                                    &**f,
-                                   callee::ArgExprs(args[]),
+                                   callee::ArgExprs(args.index(&FullRange)),
                                    dest)
             }
         }
@@ -1162,7 +1133,7 @@ fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
             callee::trans_method_call(bcx,
                                       expr,
                                       &*args[0],
-                                      callee::ArgExprs(args[]),
+                                      callee::ArgExprs(args.index(&FullRange)),
                                       dest)
         }
         ast::ExprBinary(op, ref lhs, ref rhs) => {
@@ -1210,8 +1181,8 @@ fn make_field(field_name: &str, expr: P<ast::Expr>) -> ast::Field {
             bcx.tcx().sess.span_bug(
                 expr.span,
                 format!("trans_rvalue_dps_unadjusted reached fall-through \
-                         case: {}",
-                        expr.node)[]);
+                         case: {:?}",
+                        expr.node).index(&FullRange));
         }
     }
 }
@@ -1260,8 +1231,8 @@ fn trans_def_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         }
         _ => {
             bcx.tcx().sess.span_bug(ref_expr.span, format!(
-                "Non-DPS def {} referened by {}",
-                def, bcx.node_id_to_string(ref_expr.id))[]);
+                "Non-DPS def {:?} referened by {}",
+                def, bcx.node_id_to_string(ref_expr.id)).index(&FullRange));
         }
     }
 }
@@ -1288,9 +1259,9 @@ pub fn trans_def_fn_unadjusted<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         }
         _ => {
             ccx.tcx().sess.span_bug(ref_expr.span, format!(
-                    "trans_def_fn_unadjusted invoked on: {} for {}",
+                    "trans_def_fn_unadjusted invoked on: {:?} for {}",
                     def,
-                    ref_expr.repr(ccx.tcx()))[]);
+                    ref_expr.repr(ccx.tcx())).index(&FullRange));
         }
     }
 }
@@ -1310,7 +1281,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 None => {
                     bcx.sess().bug(format!(
                         "trans_local_var: no llval for upvar {} found",
-                        nid)[]);
+                        nid).index(&FullRange));
                 }
             }
         }
@@ -1320,7 +1291,7 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 None => {
                     bcx.sess().bug(format!(
                         "trans_local_var: no datum for local/arg {} found",
-                        nid)[]);
+                        nid).index(&FullRange));
                 }
             };
             debug!("take_local(nid={}, v={}, ty={})",
@@ -1329,8 +1300,8 @@ pub fn trans_local_var<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         }
         _ => {
             bcx.sess().unimpl(format!(
-                "unsupported def type in trans_local_var: {}",
-                def)[]);
+                "unsupported def type in trans_local_var: {:?}",
+                def).index(&FullRange));
         }
     }
 }
@@ -1347,11 +1318,11 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
 {
     match ty.sty {
         ty::ty_struct(did, substs) => {
-            op(0, struct_fields(tcx, did, substs)[])
+            op(0, struct_fields(tcx, did, substs).index(&FullRange))
         }
 
         ty::ty_tup(ref v) => {
-            op(0, tup_fields(v[])[])
+            op(0, tup_fields(v.index(&FullRange)).index(&FullRange))
         }
 
         ty::ty_enum(_, substs) => {
@@ -1361,7 +1332,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
                     tcx.sess.bug(format!(
                         "cannot get field types from the enum type {} \
                          without a node ID",
-                        ty.repr(tcx))[]);
+                        ty.repr(tcx)).index(&FullRange));
                 }
                 Some(node_id) => {
                     let def = tcx.def_map.borrow()[node_id].clone();
@@ -1372,7 +1343,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
                             op(variant_info.disr_val,
                                struct_fields(tcx,
                                              variant_id,
-                                             substs)[])
+                                             substs).index(&FullRange))
                         }
                         _ => {
                             tcx.sess.bug("resolve didn't map this expr to a \
@@ -1386,7 +1357,7 @@ pub fn with_field_tys<'tcx, R, F>(tcx: &ty::ctxt<'tcx>,
         _ => {
             tcx.sess.bug(format!(
                 "cannot get field types from the type {}",
-                ty.repr(tcx))[]);
+                ty.repr(tcx)).index(&FullRange));
         }
     }
 }
@@ -1402,13 +1373,13 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     let tcx = bcx.tcx();
     with_field_tys(tcx, ty, Some(expr_id), |discr, field_tys| {
-        let mut need_base: Vec<_> = repeat(true).take(field_tys.len()).collect();
+        let mut need_base: Vec<bool> = repeat(true).take(field_tys.len()).collect();
 
         let numbered_fields = fields.iter().map(|field| {
             let opt_pos =
                 field_tys.iter().position(|field_ty|
                                           field_ty.name == field.ident.node.name);
-            match opt_pos {
+            let result = match opt_pos {
                 Some(i) => {
                     need_base[i] = false;
                     (i, &*field.expr)
@@ -1417,14 +1388,15 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                     tcx.sess.span_bug(field.span,
                                       "Couldn't find field in struct type")
                 }
-            }
+            };
+            result
         }).collect::<Vec<_>>();
         let optbase = match base {
             Some(base_expr) => {
                 let mut leftovers = Vec::new();
                 for (i, b) in need_base.iter().enumerate() {
                     if *b {
-                        leftovers.push((i, field_tys[i].mt.ty))
+                        leftovers.push((i, field_tys[i].mt.ty));
                     }
                 }
                 Some(StructBaseInfo {expr: base_expr,
@@ -1441,7 +1413,7 @@ fn trans_struct<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         trans_adt(bcx,
                   ty,
                   discr,
-                  numbered_fields[],
+                  numbered_fields.as_slice(),
                   optbase,
                   dest,
                   Some(NodeInfo { id: expr_id, span: expr_span }))
@@ -2074,20 +2046,20 @@ fn trans_imm_cast<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 cast_float => SIToFP(bcx, lldiscrim_a, ll_t_out),
                 _ => {
                     ccx.sess().bug(format!("translating unsupported cast: \
-                                            {} ({}) -> {} ({})",
+                                            {} ({:?}) -> {} ({:?})",
                                             t_in.repr(bcx.tcx()),
                                             k_in,
                                             t_out.repr(bcx.tcx()),
-                                            k_out)[])
+                                            k_out).index(&FullRange))
                 }
             }
         }
         _ => ccx.sess().bug(format!("translating unsupported cast: \
-                                    {} ({}) -> {} ({})",
+                                    {} ({:?}) -> {} ({:?})",
                                     t_in.repr(bcx.tcx()),
                                     k_in,
                                     t_out.repr(bcx.tcx()),
-                                    k_out)[])
+                                    k_out).index(&FullRange))
     };
     return immediate_rvalue_bcx(bcx, newval, t_out).to_expr_datumblock();
 }
@@ -2169,7 +2141,7 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                           -> DatumBlock<'blk, 'tcx, Expr> {
     let ccx = bcx.ccx();
 
-    debug!("deref_once(expr={}, datum={}, method_call={})",
+    debug!("deref_once(expr={}, datum={}, method_call={:?})",
            expr.repr(bcx.tcx()),
            datum.to_string(ccx),
            method_call);
@@ -2181,6 +2153,8 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                        .get(&method_call).map(|method| method.ty);
     let datum = match method_ty {
         Some(method_ty) => {
+            let method_ty = monomorphize_type(bcx, method_ty);
+
             // Overloaded. Evaluate `trans_overloaded_op`, which will
             // invoke the user's deref() method, which basically
             // converts from the `Smaht<T>` pointer that we have into
@@ -2192,7 +2166,9 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 _ => datum
             };
 
-            let ref_ty = ty::ty_fn_ret(monomorphize_type(bcx, method_ty)).unwrap();
+            let ref_ty = // invoked methods have their LB regions instantiated
+                ty::assert_no_late_bound_regions(
+                    ccx.tcx(), &ty::ty_fn_ret(method_ty)).unwrap();
             let scratch = rvalue_scratch_datum(bcx, ref_ty, "overloaded_deref");
 
             unpack_result!(bcx, trans_overloaded_op(bcx, expr, method_call,
@@ -2249,11 +2225,11 @@ fn deref_once<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
             bcx.tcx().sess.span_bug(
                 expr.span,
                 format!("deref invoked on expr of illegal type {}",
-                        datum.ty.repr(bcx.tcx()))[]);
+                        datum.ty.repr(bcx.tcx())).index(&FullRange));
         }
     };
 
-    debug!("deref_once(expr={}, method_call={}, result={})",
+    debug!("deref_once(expr={}, method_call={:?}, result={})",
            expr.id, method_call, r.datum.to_string(ccx));
 
     return r;
index 1c9be6ae4a8ba5e357566cf1ff2d65834ac56020..25eb66ab2eb7311c3abf70880a0e00470b955ee2 100644 (file)
@@ -43,7 +43,7 @@
 
 struct ForeignTypes<'tcx> {
     /// Rust signature of the function
-    fn_sig: ty::PolyFnSig<'tcx>,
+    fn_sig: ty::FnSig<'tcx>,
 
     /// Adapter object for handling native ABI rules (trust me, you
     /// don't want to know)
@@ -109,7 +109,7 @@ pub fn register_static(ccx: &CrateContext,
     let llty = type_of::type_of(ccx, ty);
 
     let ident = link_name(foreign_item);
-    match attr::first_attr_value_str_by_name(foreign_item.attrs[],
+    match attr::first_attr_value_str_by_name(foreign_item.attrs.index(&FullRange),
                                              "linkage") {
         // If this is a static with a linkage specified, then we need to handle
         // it a little specially. The typesystem prevents things like &T and
@@ -180,7 +180,7 @@ pub fn register_foreign_item_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
     // Make sure the calling convention is right for variadic functions
     // (should've been caught if not in typeck)
-    if tys.fn_sig.0.variadic {
+    if tys.fn_sig.variadic {
         assert!(cc == llvm::CCallConv);
     }
 
@@ -218,7 +218,8 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                      llretptr: ValueRef,
                                      llargs_rust: &[ValueRef],
                                      passed_arg_tys: Vec<Ty<'tcx>>)
-                                     -> Block<'blk, 'tcx> {
+                                     -> Block<'blk, 'tcx>
+{
     let ccx = bcx.ccx();
     let tcx = bcx.tcx();
 
@@ -230,16 +231,17 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
            ccx.tn().val_to_string(llretptr));
 
     let (fn_abi, fn_sig) = match callee_ty.sty {
-        ty::ty_bare_fn(_, ref fn_ty) => (fn_ty.abi, fn_ty.sig.clone()),
+        ty::ty_bare_fn(_, ref fn_ty) => (fn_ty.abi, &fn_ty.sig),
         _ => ccx.sess().bug("trans_native_call called on non-function type")
     };
-    let llsig = foreign_signature(ccx, &fn_sig, passed_arg_tys[]);
+    let fn_sig = ty::erase_late_bound_regions(ccx.tcx(), fn_sig);
+    let llsig = foreign_signature(ccx, &fn_sig, passed_arg_tys.index(&FullRange));
     let fn_type = cabi::compute_abi_info(ccx,
-                                         llsig.llarg_tys[],
+                                         llsig.llarg_tys.index(&FullRange),
                                          llsig.llret_ty,
                                          llsig.ret_def);
 
-    let arg_tys: &[cabi::ArgType] = fn_type.arg_tys[];
+    let arg_tys: &[cabi::ArgType] = fn_type.arg_tys.index(&FullRange);
 
     let mut llargs_foreign = Vec::new();
 
@@ -365,7 +367,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     let llforeign_retval = CallWithConv(bcx,
                                         llfn,
-                                        llargs_foreign[],
+                                        llargs_foreign.index(&FullRange),
                                         cc,
                                         Some(attrs));
 
@@ -387,7 +389,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         debug!("llforeign_ret_ty={}", ccx.tn().type_to_string(llforeign_ret_ty));
 
         if llrust_ret_ty == llforeign_ret_ty {
-            match fn_sig.0.output {
+            match fn_sig.output {
                 ty::FnConverging(result_ty) => {
                     base::store_ty(bcx, llforeign_retval, llretptr, result_ty)
                 }
@@ -435,7 +437,7 @@ pub fn trans_foreign_mod(ccx: &CrateContext, foreign_mod: &ast::ForeignMod) {
                 abi => {
                     let ty = ty::node_id_to_type(ccx.tcx(), foreign_item.id);
                     register_foreign_item_fn(ccx, abi, ty,
-                                             lname.get()[]);
+                                             lname.get().index(&FullRange));
                     // Unlike for other items, we shouldn't call
                     // `base::update_linkage` here.  Foreign items have
                     // special linkage requirements, which are handled
@@ -567,7 +569,7 @@ fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                 ccx.sess().bug(format!("build_rust_fn: extern fn {} has ty {}, \
                                         expected a bare fn ty",
                                        ccx.tcx().map.path_to_string(id),
-                                       t.repr(tcx))[]);
+                                       t.repr(tcx)).index(&FullRange));
             }
         };
 
@@ -575,7 +577,7 @@ fn build_rust_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                ccx.tcx().map.path_to_string(id),
                id, t.repr(tcx));
 
-        let llfn = base::decl_internal_rust_fn(ccx, t, ps[]);
+        let llfn = base::decl_internal_rust_fn(ccx, t, ps.index(&FullRange));
         base::set_llvm_fn_attrs(ccx, attrs, llfn);
         base::trans_fn(ccx, decl, body, llfn, param_substs, id, &[]);
         llfn
@@ -635,7 +637,7 @@ unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         };
 
         // Push Rust return pointer, using null if it will be unused.
-        let rust_uses_outptr = match tys.fn_sig.0.output {
+        let rust_uses_outptr = match tys.fn_sig.output {
             ty::FnConverging(ret_ty) => type_of::return_uses_outptr(ccx, ret_ty),
             ty::FnDiverging => false
         };
@@ -668,7 +670,7 @@ unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                             return_ty={}",
                            ccx.tn().val_to_string(slot),
                            ccx.tn().type_to_string(llrust_ret_ty),
-                           tys.fn_sig.0.output.repr(tcx));
+                           tys.fn_sig.output.repr(tcx));
                     llrust_args.push(slot);
                     return_alloca = Some(slot);
                 }
@@ -683,8 +685,8 @@ unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         // Build up the arguments to the call to the rust function.
         // Careful to adapt for cases where the native convention uses
         // a pointer and Rust does not or vice versa.
-        for i in range(0, tys.fn_sig.0.inputs.len()) {
-            let rust_ty = tys.fn_sig.0.inputs[i];
+        for i in range(0, tys.fn_sig.inputs.len()) {
+            let rust_ty = tys.fn_sig.inputs[i];
             let llrust_ty = tys.llsig.llarg_tys[i];
             let rust_indirect = type_of::arg_is_indirect(ccx, rust_ty);
             let llforeign_arg_ty = tys.fn_ty.arg_tys[i];
@@ -748,7 +750,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[], Some(attributes));
+        let llrust_ret_val = builder.call(llrustfn, llrust_args.as_slice(), Some(attributes));
 
         // Get the return value where the foreign fn expects it.
         let llforeign_ret_ty = match tys.fn_ty.ret_ty.cast {
@@ -815,9 +817,9 @@ unsafe fn build_wrap_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 // the massive simplifications that have occurred.
 
 pub fn link_name(i: &ast::ForeignItem) -> InternedString {
-    match attr::first_attr_value_str_by_name(i.attrs[], "link_name") {
+    match attr::first_attr_value_str_by_name(i.attrs.index(&FullRange), "link_name") {
         Some(ln) => ln.clone(),
-        None => match weak_lang_items::link_name(i.attrs[]) {
+        None => match weak_lang_items::link_name(i.attrs.index(&FullRange)) {
             Some(name) => name,
             None => token::get_ident(i.ident),
         }
@@ -829,10 +831,11 @@ pub fn link_name(i: &ast::ForeignItem) -> InternedString {
 /// because foreign functions just plain ignore modes. They also don't pass aggregate values by
 /// pointer like we do.
 fn foreign_signature<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
-                               fn_sig: &ty::PolyFnSig<'tcx>, arg_tys: &[Ty<'tcx>])
+                               fn_sig: &ty::FnSig<'tcx>,
+                               arg_tys: &[Ty<'tcx>])
                                -> LlvmSignature {
     let llarg_tys = arg_tys.iter().map(|&arg| arg_type_of(ccx, arg)).collect();
-    let (llret_ty, ret_def) = match fn_sig.0.output {
+    let (llret_ty, ret_def) = match fn_sig.output {
         ty::FnConverging(ret_ty) =>
             (type_of::arg_type_of(ccx, ret_ty), !return_type_is_void(ccx, ret_ty)),
         ty::FnDiverging =>
@@ -853,12 +856,13 @@ fn foreign_types_for_id<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                                      ty: Ty<'tcx>) -> ForeignTypes<'tcx> {
     let fn_sig = match ty.sty {
-        ty::ty_bare_fn(_, ref fn_ty) => fn_ty.sig.clone(),
+        ty::ty_bare_fn(_, ref fn_ty) => &fn_ty.sig,
         _ => ccx.sess().bug("foreign_types_for_fn_ty called on non-function type")
     };
-    let llsig = foreign_signature(ccx, &fn_sig, fn_sig.0.inputs.as_slice());
+    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 fn_ty = cabi::compute_abi_info(ccx,
-                                       llsig.llarg_tys[],
+                                       llsig.llarg_tys.index(&FullRange),
                                        llsig.llret_ty,
                                        llsig.ret_def);
     debug!("foreign_types_for_fn_ty(\
@@ -867,9 +871,9 @@ fn foreign_types_for_fn_ty<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
            fn_ty={} -> {}, \
            ret_def={}",
            ty.repr(ccx.tcx()),
-           ccx.tn().types_to_str(llsig.llarg_tys[]),
+           ccx.tn().types_to_str(llsig.llarg_tys.index(&FullRange)),
            ccx.tn().type_to_string(llsig.llret_ty),
-           ccx.tn().types_to_str(fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>()[]),
+           ccx.tn().types_to_str(fn_ty.arg_tys.iter().map(|t| t.ty).collect::<Vec<_>>().as_slice()),
            ccx.tn().type_to_string(fn_ty.ret_ty.ty),
            llsig.ret_def);
 
@@ -916,10 +920,10 @@ fn lltype_for_fn_from_foreign_types(ccx: &CrateContext, tys: &ForeignTypes) -> T
         llargument_tys.push(llarg_ty);
     }
 
-    if tys.fn_sig.0.variadic {
+    if tys.fn_sig.variadic {
         Type::variadic_func(llargument_tys.as_slice(), &llreturn_ty)
     } else {
-        Type::func(llargument_tys[], &llreturn_ty)
+        Type::func(llargument_tys.index(&FullRange), &llreturn_ty)
     }
 }
 
index 2fd9031fdfe4cc7f6e74fc1d70c40da040c26ad0..52e7a986d7e988a17222cecbad342ef59fe928c8 100644 (file)
@@ -161,7 +161,7 @@ pub fn get_drop_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Val
 
     let (glue, new_sym) = match ccx.available_drop_glues().borrow().get(&t) {
         Some(old_sym) => {
-            let glue = decl_cdecl_fn(ccx, old_sym[], llfnty, ty::mk_nil(ccx.tcx()));
+            let glue = decl_cdecl_fn(ccx, old_sym.index(&FullRange), llfnty, ty::mk_nil(ccx.tcx()));
             (glue, None)
         },
         None => {
@@ -212,7 +212,8 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                  dtor_did: ast::DefId,
                                  class_did: ast::DefId,
                                  substs: &subst::Substs<'tcx>)
-                                 -> Block<'blk, 'tcx> {
+                                 -> Block<'blk, 'tcx>
+{
     let repr = adt::represent_type(bcx.ccx(), t);
 
     // Find and call the actual destructor
@@ -228,11 +229,12 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
     let fty = ty::lookup_item_type(bcx.tcx(), dtor_did).ty.subst(bcx.tcx(), substs);
     let self_ty = match fty.sty {
         ty::ty_bare_fn(_, ref f) => {
-            assert!(f.sig.0.inputs.len() == 1);
-            f.sig.0.inputs[0]
+            let sig = ty::erase_late_bound_regions(bcx.tcx(), &f.sig);
+            assert!(sig.inputs.len() == 1);
+            sig.inputs[0]
         }
         _ => bcx.sess().bug(format!("Expected function type, found {}",
-                                    bcx.ty_to_string(fty))[])
+                                    bcx.ty_to_string(fty)).index(&FullRange))
     };
 
     let (struct_data, info) = if type_is_sized(bcx.tcx(), t) {
@@ -293,7 +295,7 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                                      class_did,
                                      &[get_drop_glue_type(bcx.ccx(), t)],
                                      ty::mk_nil(bcx.tcx()));
-        let (_, variant_cx) = invoke(variant_cx, dtor_addr, args[], dtor_ty, None);
+        let (_, variant_cx) = invoke(variant_cx, dtor_addr, args.index(&FullRange), dtor_ty, None);
 
         variant_cx.fcx.pop_and_trans_custom_cleanup_scope(variant_cx, field_scope);
         variant_cx
@@ -352,7 +354,7 @@ fn size_and_align_of_dst<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, t: Ty<'tcx>, info:
             (Mul(bcx, info, C_uint(bcx.ccx(), unit_size)), C_uint(bcx.ccx(), 8u))
         }
         _ => bcx.sess().bug(format!("Unexpected unsized type, found {}",
-                                    bcx.ty_to_string(t))[])
+                                    bcx.ty_to_string(t)).index(&FullRange))
     }
 }
 
@@ -424,7 +426,7 @@ fn make_drop_glue<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, v0: ValueRef, t: Ty<'tcx>)
                         bcx.sess().warn(format!("Ignoring drop flag in destructor for {}\
                                                  because the struct is unsized. See issue\
                                                  #16758",
-                                                bcx.ty_to_string(t))[]);
+                                                bcx.ty_to_string(t)).index(&FullRange));
                         trans_struct_drop(bcx, t, v0, dtor, did, substs)
                     }
                 }
@@ -494,7 +496,7 @@ pub fn declare_tydesc<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>)
     note_unique_llvm_symbol(ccx, name);
 
     let ty_name = token::intern_and_get_ident(
-        ppaux::ty_to_string(ccx.tcx(), t)[]);
+        ppaux::ty_to_string(ccx.tcx(), t).index(&FullRange));
     let ty_name = C_str_slice(ccx, ty_name);
 
     debug!("--- declare_tydesc {}", ppaux::ty_to_string(ccx.tcx(), t));
@@ -513,8 +515,8 @@ fn declare_generic_glue<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>,
     let fn_nm = mangle_internal_name_by_type_and_seq(
         ccx,
         t,
-        format!("glue_{}", name)[]);
-    let llfn = decl_cdecl_fn(ccx, fn_nm[], llfnty, ty::mk_nil(ccx.tcx()));
+        format!("glue_{}", name).index(&FullRange));
+    let llfn = decl_cdecl_fn(ccx, fn_nm.index(&FullRange), llfnty, ty::mk_nil(ccx.tcx()));
     note_unique_llvm_symbol(ccx, fn_nm.clone());
     return (fn_nm, llfn);
 }
index 6e716538911818bc971e6370f2901b03460c02f7..ed75445b9939be9b1266334364a9e229c827e244 100644 (file)
@@ -150,14 +150,16 @@ pub fn trans_intrinsic_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>,
                                             dest: expr::Dest,
                                             substs: subst::Substs<'tcx>,
                                             call_info: NodeInfo)
-                                            -> Result<'blk, 'tcx> {
-
+                                            -> Result<'blk, 'tcx>
+{
     let fcx = bcx.fcx;
     let ccx = fcx.ccx;
     let tcx = bcx.tcx();
 
     let ret_ty = match callee_ty.sty {
-        ty::ty_bare_fn(_, ref f) => f.sig.0.output,
+        ty::ty_bare_fn(_, ref f) => {
+            ty::erase_late_bound_regions(bcx.tcx(), &f.sig.output())
+        }
         _ => panic!("expected bare_fn in trans_intrinsic_call")
     };
     let foreign_item = tcx.map.expect_foreign_item(node);
index 7f45c05fbbdd9149d6a93bf1fe1c45196d823c85..28718ffa980a0113c08f463b980a3cfa187ec67f 100644 (file)
@@ -77,7 +77,7 @@ pub fn trans_impl(ccx: &CrateContext,
         match *impl_item {
             ast::MethodImplItem(ref method) => {
                 if method.pe_generics().ty_params.len() == 0u {
-                    let trans_everywhere = attr::requests_inline(method.attrs[]);
+                    let trans_everywhere = attr::requests_inline(method.attrs.index(&FullRange));
                     for (ref ccx, is_origin) in ccx.maybe_iter(trans_everywhere) {
                         let llfn = get_item_val(ccx, method.id);
                         trans_fn(ccx,
@@ -135,7 +135,7 @@ pub fn trans_method_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         }) => {
             let trait_ref = ty::Binder(bcx.monomorphize(trait_ref));
             let span = bcx.tcx().map.span(method_call.expr_id);
-            debug!("method_call={} trait_ref={}",
+            debug!("method_call={:?} trait_ref={}",
                    method_call,
                    trait_ref.repr(bcx.tcx()));
             let origin = fulfill_obligation(bcx.ccx(),
@@ -177,7 +177,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     let _icx = push_ctxt("meth::trans_static_method_callee");
     let tcx = ccx.tcx();
 
-    debug!("trans_static_method_callee(method_id={}, trait_id={}, \
+    debug!("trans_static_method_callee(method_id={:?}, trait_id={}, \
             expr_id={})",
            method_id,
            ty::item_path_str(tcx, trait_id),
@@ -201,7 +201,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     } else {
         csearch::get_item_path(tcx, method_id).last().unwrap().name()
     };
-    debug!("trans_static_method_callee: method_id={}, expr_id={}, \
+    debug!("trans_static_method_callee: method_id={:?}, expr_id={}, \
             name={}", method_id, expr_id, token::get_name(mname));
 
     // Find the substitutions for the fn itself. This includes
@@ -229,7 +229,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     // Here, in this call, which I've written with explicit UFCS
     // notation, the set of type parameters will be:
     //
-    //     rcvr_type: [] <-- nothing declared on the trait itself
+    //     rcvr_type: .index(&FullRange) <-- nothing declared on the trait itself
     //     rcvr_self: [Vec<int>] <-- the self type
     //     rcvr_method: [String] <-- method type parameter
     //
@@ -268,11 +268,11 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             //
             // Recall that we matched `<Vec<int> as Convert>`. Trait
             // resolution will have given us a substitution
-            // containing `impl_substs=[[T=int],[],[]]` (the type
+            // containing `impl_substs=[[T=int],.index(&FullRange),.index(&FullRange)]` (the type
             // parameters defined on the impl). We combine
             // that with the `rcvr_method` from before, which tells us
             // the type parameters from the *method*, to yield
-            // `callee_substs=[[T=int],[],[U=String]]`.
+            // `callee_substs=[[T=int],.index(&FullRange),[U=String]]`.
             let subst::SeparateVecsPerParamSpace {
                 types: impl_type,
                 selfs: impl_self,
@@ -290,7 +290,7 @@ pub fn trans_static_method_callee<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         }
         _ => {
             tcx.sess.bug(format!("static call to invalid vtable: {}",
-                                 vtbl.repr(tcx))[]);
+                                 vtbl.repr(tcx)).index(&FullRange));
         }
     }
 }
@@ -378,7 +378,7 @@ fn trans_monomorphized_callee<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
         traits::VtableParam(..) => {
             bcx.sess().bug(
                 format!("resolved vtable bad vtable {} in trans",
-                        vtable.repr(bcx.tcx()))[]);
+                        vtable.repr(bcx.tcx())).index(&FullRange));
         }
     }
 }
@@ -477,13 +477,19 @@ pub fn trans_trait_callee_from_llval<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
 
     // Load the function from the vtable and cast it to the expected type.
     debug!("(translating trait callee) loading method");
+
     // Replace the self type (&Self or Box<Self>) with an opaque pointer.
     let llcallee_ty = match callee_ty.sty {
         ty::ty_bare_fn(_, ref f) if f.abi == Rust || f.abi == RustCall => {
+            let fake_sig =
+                ty::Binder(ty::FnSig {
+                    inputs: f.sig.0.inputs.slice_from(1).to_vec(),
+                    output: f.sig.0.output,
+                    variadic: f.sig.0.variadic,
+                });
             type_of_rust_fn(ccx,
                             Some(Type::i8p(ccx)),
-                            f.sig.0.inputs.slice_from(1),
-                            f.sig.0.output,
+                            &fake_sig,
                             f.abi)
         }
         _ => {
@@ -557,7 +563,8 @@ pub fn trans_object_shim<'a, 'tcx>(
 
     // Upcast to the trait in question and extract out the substitutions.
     let upcast_trait_ref = traits::upcast(ccx.tcx(), object_trait_ref.clone(), trait_id).unwrap();
-    let object_substs = upcast_trait_ref.substs().clone().erase_regions();
+    let upcast_trait_ref = ty::erase_late_bound_regions(tcx, &upcast_trait_ref);
+    let object_substs = upcast_trait_ref.substs.clone().erase_regions();
     debug!("trans_object_shim: object_substs={}", object_substs.repr(tcx));
 
     // Lookup the type of this method as declared in the trait and apply substitutions.
@@ -579,6 +586,8 @@ pub fn trans_object_shim<'a, 'tcx>(
     let llfn =
         decl_internal_rust_fn(ccx, method_bare_fn_ty, function_name.as_slice());
 
+    let sig = ty::erase_late_bound_regions(ccx.tcx(), &fty.sig);
+
     //
     let block_arena = TypedArena::new();
     let empty_substs = Substs::trans_empty();
@@ -586,11 +595,11 @@ pub fn trans_object_shim<'a, 'tcx>(
                           llfn,
                           ast::DUMMY_NODE_ID,
                           false,
-                          fty.sig.0.output,
+                          sig.output,
                           &empty_substs,
                           None,
                           &block_arena);
-    let mut bcx = init_function(&fcx, false, fty.sig.0.output);
+    let mut bcx = init_function(&fcx, false, sig.output);
 
     // the first argument (`self`) will be a trait object
     let llobject = get_param(fcx.llfn, fcx.arg_pos(0) as u32);
@@ -603,18 +612,18 @@ pub fn trans_object_shim<'a, 'tcx>(
         match fty.abi {
             RustCall => {
                 // unpack the tuple to extract the input type arguments:
-                match fty.sig.0.inputs[1].sty {
+                match sig.inputs[1].sty {
                     ty::ty_tup(ref tys) => tys.as_slice(),
                     _ => {
                         bcx.sess().bug(
                             format!("rust-call expects a tuple not {}",
-                                    fty.sig.0.inputs[1].repr(tcx)).as_slice());
+                                    sig.inputs[1].repr(tcx)).as_slice());
                     }
                 }
             }
             _ => {
                 // skip the self parameter:
-                fty.sig.0.inputs.slice_from(1)
+                sig.inputs.slice_from(1)
             }
         };
 
@@ -631,9 +640,12 @@ pub fn trans_object_shim<'a, 'tcx>(
 
     assert!(!fcx.needs_ret_allocas);
 
+    let sig =
+        ty::erase_late_bound_regions(bcx.tcx(), &fty.sig);
+
     let dest =
         fcx.llretslotptr.get().map(
-            |_| expr::SaveIn(fcx.get_ret_slot(bcx, fty.sig.0.output, "ret_slot")));
+            |_| expr::SaveIn(fcx.get_ret_slot(bcx, sig.output, "ret_slot")));
 
     let method_offset_in_vtable =
         traits::get_vtable_index_of_object_method(bcx.tcx(),
@@ -653,7 +665,7 @@ pub fn trans_object_shim<'a, 'tcx>(
                            ArgVals(llargs.as_slice()),
                            dest).bcx;
 
-    finish_fn(&fcx, bcx, fty.sig.0.output);
+    finish_fn(&fcx, bcx, sig.output);
 
     llfn
 }
@@ -728,7 +740,7 @@ pub fn get_vtable<'blk, 'tcx>(bcx: Block<'blk, 'tcx>,
                 bcx.sess().bug(
                     format!("resolved vtable for {} to bad vtable {} in trans",
                             trait_ref.repr(bcx.tcx()),
-                            vtable.repr(bcx.tcx()))[]);
+                            vtable.repr(bcx.tcx())).index(&FullRange));
             }
         }
     });
@@ -760,7 +772,7 @@ pub fn make_vtable<I: Iterator<Item=ValueRef>>(ccx: &CrateContext,
     let components: Vec<_> = head.into_iter().chain(ptrs).collect();
 
     unsafe {
-        let tbl = C_struct(ccx, components[], false);
+        let tbl = C_struct(ccx, components.index(&FullRange), false);
         let sym = token::gensym("vtable");
         let buf = CString::from_vec(format!("vtable{}", sym.uint()).into_bytes());
         let vt_gvar = llvm::LLVMAddGlobal(ccx.llmod(), val_ty(tbl).to_ref(),
index fa9cd5a698bbe05784d661832f89cbb630529f90..42134789546958bbb3d2a47d835bfc0e6126a4bc 100644 (file)
@@ -16,8 +16,7 @@
 pub use self::context::CrateContext;
 pub use self::common::gensym_name;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod macros;
 
 mod doc;
index e6db462a342da21d05c3c731077441b1da369b2f..e2594765f4fdaaa929286bec3529642466a168b2 100644 (file)
@@ -42,7 +42,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     debug!("monomorphic_fn(\
             fn_id={}, \
             real_substs={}, \
-            ref_id={})",
+            ref_id={:?})",
            fn_id.repr(ccx.tcx()),
            psubsts.repr(ccx.tcx()),
            ref_id);
@@ -73,7 +73,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     debug!("monomorphic_fn(\
             fn_id={}, \
             psubsts={}, \
-            hash_id={})",
+            hash_id={:?})",
            fn_id.repr(ccx.tcx()),
            psubsts.repr(ccx.tcx()),
            hash_id);
@@ -83,7 +83,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         ccx.sess(),
         ccx.tcx().map.find(fn_id.node),
         || {
-            format!("while monomorphizing {}, couldn't find it in \
+            format!("while monomorphizing {:?}, couldn't find it in \
                      the item map (may have attempted to monomorphize \
                      an item defined in a different crate?)",
                     fn_id)
@@ -131,7 +131,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
         hash = format!("h{}", state.result());
         ccx.tcx().map.with_path(fn_id.node, |path| {
-            exported_name(path, hash[])
+            exported_name(path, hash.index(&FullRange))
         })
     };
 
@@ -141,9 +141,9 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
     let mut hash_id = Some(hash_id);
     let mut mk_lldecl = |&mut : abi: abi::Abi| {
         let lldecl = if abi != abi::Rust {
-            foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, s[])
+            foreign::decl_rust_fn_with_foreign_abi(ccx, mono_ty, s.index(&FullRange))
         } else {
-            decl_internal_rust_fn(ccx, mono_ty, s[])
+            decl_internal_rust_fn(ccx, mono_ty, s.index(&FullRange))
         };
 
         ccx.monomorphized().borrow_mut().insert(hash_id.take().unwrap(), lldecl);
@@ -177,12 +177,12 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                   ..
               } => {
                   let d = mk_lldecl(abi);
-                  let needs_body = setup_lldecl(d, i.attrs[]);
+                  let needs_body = setup_lldecl(d, i.attrs.index(&FullRange));
                   if needs_body {
                       if abi != abi::Rust {
                           foreign::trans_rust_fn_with_foreign_abi(
                               ccx, &**decl, &**body, &[], d, psubsts, fn_id.node,
-                              Some(hash[]));
+                              Some(hash.index(&FullRange)));
                       } else {
                           trans_fn(ccx, &**decl, &**body, d, psubsts, fn_id.node, &[]);
                       }
@@ -206,7 +206,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                     trans_enum_variant(ccx,
                                        parent,
                                        &*v,
-                                       args[],
+                                       args.index(&FullRange),
                                        this_tv.disr_val,
                                        psubsts,
                                        d);
@@ -220,7 +220,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             match *ii {
                 ast::MethodImplItem(ref mth) => {
                     let d = mk_lldecl(abi::Rust);
-                    let needs_body = setup_lldecl(d, mth.attrs[]);
+                    let needs_body = setup_lldecl(d, mth.attrs.index(&FullRange));
                     if needs_body {
                         trans_fn(ccx,
                                  mth.pe_fn_decl(),
@@ -241,7 +241,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             match *method {
                 ast::ProvidedMethod(ref mth) => {
                     let d = mk_lldecl(abi::Rust);
-                    let needs_body = setup_lldecl(d, mth.attrs[]);
+                    let needs_body = setup_lldecl(d, mth.attrs.index(&FullRange));
                     if needs_body {
                         trans_fn(ccx, mth.pe_fn_decl(), mth.pe_body(), d,
                                  psubsts, mth.id, &[]);
@@ -249,8 +249,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
                     d
                 }
                 _ => {
-                    ccx.sess().bug(format!("can't monomorphize a {}",
-                                           map_node)[])
+                    ccx.sess().bug(format!("can't monomorphize a {:?}",
+                                           map_node).index(&FullRange))
                 }
             }
         }
@@ -258,7 +258,7 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
             let d = mk_lldecl(abi::Rust);
             set_inline_hint(d);
             base::trans_tuple_struct(ccx,
-                                     struct_def.fields[],
+                                     struct_def.fields.index(&FullRange),
                                      struct_def.ctor_id.expect("ast-mapped tuple struct \
                                                                 didn't have a ctor id"),
                                      psubsts,
@@ -275,8 +275,8 @@ pub fn monomorphic_fn<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         ast_map::NodeBlock(..) |
         ast_map::NodePat(..) |
         ast_map::NodeLocal(..) => {
-            ccx.sess().bug(format!("can't monomorphize a {}",
-                                   map_node)[])
+            ccx.sess().bug(format!("can't monomorphize a {:?}",
+                                   map_node).index(&FullRange))
         }
     };
 
index 3785c2fb9bc54e5b633e3dd36099266ed2840dec..66e27ed1188f3618375dfc17cb1fce744fdedca1 100644 (file)
@@ -103,7 +103,7 @@ pub fn i8p(ccx: &CrateContext) -> Type {
     }
 
     pub fn int(ccx: &CrateContext) -> Type {
-        match ccx.tcx().sess.target.target.target_word_size[] {
+        match ccx.tcx().sess.target.target.target_word_size.index(&FullRange) {
             "32" => Type::i32(ccx),
             "64" => Type::i64(ccx),
             tws => panic!("Unsupported target word size for int: {}", tws),
@@ -112,7 +112,7 @@ pub fn int(ccx: &CrateContext) -> Type {
 
     pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
         match t {
-            ast::TyI => ccx.int_type(),
+            ast::TyIs => ccx.int_type(),
             ast::TyI8 => Type::i8(ccx),
             ast::TyI16 => Type::i16(ccx),
             ast::TyI32 => Type::i32(ccx),
@@ -122,7 +122,7 @@ pub fn int_from_ty(ccx: &CrateContext, t: ast::IntTy) -> Type {
 
     pub fn uint_from_ty(ccx: &CrateContext, t: ast::UintTy) -> Type {
         match t {
-            ast::TyU => ccx.int_type(),
+            ast::TyUs => ccx.int_type(),
             ast::TyU8 => Type::i8(ccx),
             ast::TyU16 => Type::i16(ccx),
             ast::TyU32 => Type::i32(ccx),
index 3e499ea8498fbad9355e18cf6204370fb9db8573..19d50cdd48320ab0b3c4d75967ad62bfa22d2051 100644 (file)
@@ -17,7 +17,7 @@
 use trans::common::*;
 use trans::foreign;
 use trans::machine;
-use middle::ty::{self, Ty};
+use middle::ty::{self, RegionEscape, Ty};
 use util::ppaux;
 use util::ppaux::Repr;
 
@@ -99,18 +99,21 @@ pub fn untuple_arguments_if_necessary<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
 
 pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
                                  llenvironment_type: Option<Type>,
-                                 inputs: &[Ty<'tcx>],
-                                 output: ty::FnOutput<'tcx>,
+                                 sig: &ty::Binder<ty::FnSig<'tcx>>,
                                  abi: abi::Abi)
-                                 -> Type {
+                                 -> Type
+{
+    let sig = ty::erase_late_bound_regions(cx.tcx(), sig);
+    assert!(!sig.variadic); // rust fns are never variadic
+
     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, inputs, abi);
+    let inputs = untuple_arguments_if_necessary(cx, sig.inputs.as_slice(), abi);
 
     // Arg 0: Output pointer.
     // (if the output type is non-immediate)
-    let lloutputtype = match output {
+    let lloutputtype = match sig.output {
         ty::FnConverging(output) => {
             let use_out_pointer = return_uses_outptr(cx, output);
             let lloutputtype = arg_type_of(cx, output);
@@ -137,7 +140,7 @@ pub fn type_of_rust_fn<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     let input_tys = inputs.iter().map(|&arg_ty| type_of_explicit_arg(cx, arg_ty));
     atys.extend(input_tys);
 
-    Type::func(atys[], &lloutputtype)
+    Type::func(atys.index(&FullRange), &lloutputtype)
 }
 
 // Given a function type and a count of ty params, construct an llvm type
@@ -147,11 +150,7 @@ pub fn type_of_fn_from_ty<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, fty: Ty<'tcx>)
             // FIXME(#19925) once fn item types are
             // zero-sized, we'll need to do something here
             if f.abi == abi::Rust || f.abi == abi::RustCall {
-                type_of_rust_fn(cx,
-                                None,
-                                f.sig.0.inputs.as_slice(),
-                                f.sig.0.output,
-                                f.abi)
+                type_of_rust_fn(cx, None, &f.sig, f.abi)
             } else {
                 foreign::lltype_for_foreign_fn(cx, fty)
             }
@@ -182,7 +181,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
     let llsizingty = match t.sty {
         _ if !lltype_is_sized(cx.tcx(), t) => {
             cx.sess().bug(format!("trying to take the sizing type of {}, an unsized type",
-                                  ppaux::ty_to_string(cx.tcx(), t))[])
+                                  ppaux::ty_to_string(cx.tcx(), t)).index(&FullRange))
         }
 
         ty::ty_bool => Type::bool(cx),
@@ -235,7 +234,7 @@ pub fn sizing_type_of<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Typ
 
         ty::ty_projection(..) | ty::ty_infer(..) | ty::ty_param(..) | ty::ty_err(..) => {
             cx.sess().bug(format!("fictitious type {} in sizing_type_of()",
-                                  ppaux::ty_to_string(cx.tcx(), t))[])
+                                  ppaux::ty_to_string(cx.tcx(), t)).index(&FullRange))
         }
         ty::ty_vec(_, None) | ty::ty_trait(..) | ty::ty_str => panic!("unreachable")
     };
@@ -264,7 +263,7 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
         }
 
         match unsized_part_of_type(cx.tcx(), t).sty {
-            ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyU),
+            ty::ty_str | ty::ty_vec(..) => Type::uint_from_ty(cx, ast::TyUs),
             ty::ty_trait(_) => Type::vtable_ptr(cx),
             _ => panic!("Unexpected type returned from unsized_part_of_type : {}",
                        t.repr(cx.tcx()))
@@ -277,18 +276,20 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
         None => ()
     }
 
-    debug!("type_of {} {}", t.repr(cx.tcx()), t.sty);
+    debug!("type_of {} {:?}", t.repr(cx.tcx()), t.sty);
+
+    assert!(!t.has_escaping_regions());
 
     // Replace any typedef'd types with their equivalent non-typedef
     // type. This ensures that all LLVM nominal types that contain
     // Rust types are defined as the same LLVM types.  If we don't do
     // this then, e.g. `Option<{myfield: bool}>` would be a different
     // type than `Option<myrec>`.
-    let t_norm = ty::normalize_ty(cx.tcx(), t);
+    let t_norm = normalize_ty(cx.tcx(), t);
 
     if t != t_norm {
         let llty = type_of(cx, t_norm);
-        debug!("--> normalized {} {} to {} {} llty={}",
+        debug!("--> normalized {} {:?} to {} {:?} llty={}",
                 t.repr(cx.tcx()),
                 t,
                 t_norm.repr(cx.tcx()),
@@ -312,7 +313,7 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
           let repr = adt::represent_type(cx, t);
           let tps = substs.types.get_slice(subst::TypeSpace);
           let name = llvm_type_name(cx, an_enum, did, tps);
-          adt::incomplete_type_of(cx, &*repr, name[])
+          adt::incomplete_type_of(cx, &*repr, name.index(&FullRange))
       }
       ty::ty_unboxed_closure(did, _, ref substs) => {
           // Only create the named struct, but don't fill it in. We
@@ -323,7 +324,7 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
           // contents of the VecPerParamSpace to to construct the llvm
           // name
           let name = llvm_type_name(cx, an_unboxed_closure, did, substs.types.as_slice());
-          adt::incomplete_type_of(cx, &*repr, name[])
+          adt::incomplete_type_of(cx, &*repr, name.index(&FullRange))
       }
 
       ty::ty_uniq(ty) | ty::ty_rptr(_, ty::mt{ty, ..}) | ty::ty_ptr(ty::mt{ty, ..}) => {
@@ -379,7 +380,7 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
               let repr = adt::represent_type(cx, t);
               let tps = substs.types.get_slice(subst::TypeSpace);
               let name = llvm_type_name(cx, a_struct, did, tps);
-              adt::incomplete_type_of(cx, &*repr, name[])
+              adt::incomplete_type_of(cx, &*repr, name.index(&FullRange))
           }
       }
 
@@ -398,7 +399,7 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
           }
           ty::ty_trait(..) => Type::opaque_trait(cx),
           _ => cx.sess().bug(format!("ty_open with sized type: {}",
-                                     ppaux::ty_to_string(cx.tcx(), t))[])
+                                     ppaux::ty_to_string(cx.tcx(), t)).index(&FullRange))
       },
 
       ty::ty_infer(..) => cx.sess().bug("type_of with ty_infer"),
@@ -407,7 +408,7 @@ fn type_of_unsize_info<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, t: Ty<'tcx>) -> Ty
       ty::ty_err(..) => cx.sess().bug("type_of with ty_err"),
     };
 
-    debug!("--> mapped t={} {} to llty={}",
+    debug!("--> mapped t={} {:?} to llty={}",
             t.repr(cx.tcx()),
             t,
             cx.tn().type_to_string(llty));
@@ -457,7 +458,7 @@ pub fn llvm_type_name<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
     let tstr = if strings.is_empty() {
         base
     } else {
-        format!("{}<{}>", base, strings)
+        format!("{}<{:?}>", base, strings)
     };
 
     if did.krate == 0 {
index 183b8c5c830ef0f29f71ab43c683120f755190cb..265ebe00d539fe807441720b88f748f1b030a0c1 100644 (file)
@@ -197,7 +197,7 @@ pub fn opt_ast_region_to_region<'tcx>(
                                     help_name
                                 } else {
                                     format!("one of {}'s {} elided lifetimes", help_name, n)
-                                }[]);
+                                }.index(&FullRange));
 
                                 if len == 2 && i == 0 {
                                     m.push_str(" or ");
@@ -347,7 +347,7 @@ fn create_substs_for_ast_path<'tcx>(
                                    format!("wrong number of type arguments: {} {}, found {}",
                                            expected,
                                            required_ty_param_count,
-                                           supplied_ty_param_count)[]);
+                                           supplied_ty_param_count).index(&FullRange));
     } else if supplied_ty_param_count > formal_ty_param_count {
         let expected = if required_ty_param_count < formal_ty_param_count {
             "expected at most"
@@ -358,7 +358,7 @@ fn create_substs_for_ast_path<'tcx>(
                                    format!("wrong number of type arguments: {} {}, found {}",
                                            expected,
                                            formal_ty_param_count,
-                                           supplied_ty_param_count)[]);
+                                           supplied_ty_param_count).index(&FullRange));
     }
 
     let mut substs = Substs::new_type(types, regions);
@@ -377,7 +377,7 @@ fn create_substs_for_ast_path<'tcx>(
         }
     }
 
-    for param in ty_param_defs[supplied_ty_param_count..].iter() {
+    for param in ty_param_defs.index(&(supplied_ty_param_count..)).iter() {
         match param.default {
             Some(default) => {
                 // This is a default type parameter.
@@ -556,7 +556,8 @@ pub fn instantiate_trait_ref<'tcx>(
         _ => {
             this.tcx().sess.span_fatal(
                 ast_trait_ref.path.span,
-                format!("`{}` is not a trait", ast_trait_ref.path.user_string(this.tcx()))[]);
+                format!("`{}` is not a trait",
+                        ast_trait_ref.path.user_string(this.tcx())).index(&FullRange));
         }
     }
 }
@@ -570,7 +571,7 @@ fn ast_path_to_trait_ref<'a,'tcx>(
     mut projections: Option<&mut Vec<ty::ProjectionPredicate<'tcx>>>)
     -> Rc<ty::TraitRef<'tcx>>
 {
-    debug!("ast_path_to_trait_ref {}", path);
+    debug!("ast_path_to_trait_ref {:?}", path);
     let trait_def = this.get_trait_def(trait_def_id);
 
     // the trait reference introduces a binding level here, so
@@ -825,7 +826,7 @@ pub fn ast_ty_to_builtin_ty<'tcx>(
                         .sess
                         .span_bug(ast_ty.span,
                                   format!("unbound path {}",
-                                          path.repr(this.tcx()))[])
+                                          path.repr(this.tcx())).index(&FullRange))
                 }
                 Some(&d) => d
             };
@@ -847,7 +848,7 @@ pub fn ast_ty_to_builtin_ty<'tcx>(
                             this.tcx().sess.span_bug(
                                 path.span,
                                 format!("converting `Box` to `{}`",
-                                        ty.repr(this.tcx()))[]);
+                                        ty.repr(this.tcx())).index(&FullRange));
                         }
                     }
                 }
@@ -1067,10 +1068,14 @@ pub fn ast_ty_to_ty<'tcx>(
                 ty::mk_vec(tcx, ast_ty_to_ty(this, rscope, &**ty), None)
             }
             ast::TyObjectSum(ref ty, ref bounds) => {
-                match ast_ty_to_trait_ref(this, rscope, &**ty, bounds[]) {
+                match ast_ty_to_trait_ref(this, rscope, &**ty, bounds.index(&FullRange)) {
                     Ok((trait_ref, projection_bounds)) => {
-                        trait_ref_to_object_type(this, rscope, ast_ty.span,
-                                                 trait_ref, projection_bounds, bounds[])
+                        trait_ref_to_object_type(this,
+                                                 rscope,
+                                                 ast_ty.span,
+                                                 trait_ref,
+                                                 projection_bounds,
+                                                 bounds.index(&FullRange))
                     }
                     Err(ErrorReported) => {
                         this.tcx().types.err
@@ -1105,7 +1110,7 @@ pub fn ast_ty_to_ty<'tcx>(
                 ty::mk_bare_fn(tcx, None, tcx.mk_bare_fn(bare_fn))
             }
             ast::TyPolyTraitRef(ref bounds) => {
-                conv_ty_poly_trait_ref(this, rscope, ast_ty.span, bounds[])
+                conv_ty_poly_trait_ref(this, rscope, ast_ty.span, bounds.index(&FullRange))
             }
             ast::TyPath(ref path, id) => {
                 let a_def = match tcx.def_map.borrow().get(&id) {
@@ -1113,7 +1118,7 @@ pub fn ast_ty_to_ty<'tcx>(
                         tcx.sess
                            .span_bug(ast_ty.span,
                                      format!("unbound path {}",
-                                             path.repr(tcx))[])
+                                             path.repr(tcx)).index(&FullRange))
                     }
                     Some(&d) => d
                 };
@@ -1152,7 +1157,7 @@ pub fn ast_ty_to_ty<'tcx>(
                     def::DefMod(id) => {
                         tcx.sess.span_fatal(ast_ty.span,
                             format!("found module name used as a type: {}",
-                                    tcx.map.node_to_string(id.node))[]);
+                                    tcx.map.node_to_string(id.node)).index(&FullRange));
                     }
                     def::DefPrimTy(_) => {
                         panic!("DefPrimTy arm missed in previous ast_ty_to_prim_ty call");
@@ -1171,7 +1176,7 @@ pub fn ast_ty_to_ty<'tcx>(
                                                           .last()
                                                           .unwrap()
                                                           .identifier)
-                                                  .get())[]);
+                                                  .get()).index(&FullRange));
                         this.tcx().types.err
                     }
                     def::DefAssociatedPath(provenance, assoc_ident) => {
@@ -1180,8 +1185,8 @@ pub fn ast_ty_to_ty<'tcx>(
                     _ => {
                         tcx.sess.span_fatal(ast_ty.span,
                                             format!("found value name used \
-                                                     as a type: {}",
-                                                    a_def)[]);
+                                                     as a type: {:?}",
+                                                    a_def).index(&FullRange));
                     }
                 }
             }
@@ -1209,7 +1214,7 @@ pub fn ast_ty_to_ty<'tcx>(
                             ast_ty.span,
                             format!("expected constant expr for array \
                                      length: {}",
-                                    *r)[]);
+                                    *r).index(&FullRange));
                     }
                 }
             }
@@ -1331,7 +1336,7 @@ fn ty_of_method_or_bare_fn<'a, 'tcx>(this: &AstConv<'tcx>,
     let input_params = if self_ty.is_some() {
         decl.inputs.slice_from(1)
     } else {
-        decl.inputs[]
+        decl.inputs.index(&FullRange)
     };
     let input_tys = input_params.iter().map(|a| ty_of_arg(this, &rb, a, None));
     let input_pats: Vec<String> = input_params.iter()
@@ -1546,7 +1551,7 @@ fn conv_ty_poly_trait_ref<'tcx>(
     ast_bounds: &[ast::TyParamBound])
     -> Ty<'tcx>
 {
-    let mut partitioned_bounds = partition_bounds(this.tcx(), span, ast_bounds[]);
+    let mut partitioned_bounds = partition_bounds(this.tcx(), span, ast_bounds.index(&FullRange));
 
     let mut projection_bounds = Vec::new();
     let main_trait_bound = if !partitioned_bounds.trait_bounds.is_empty() {
@@ -1596,7 +1601,7 @@ pub fn conv_existential_bounds_from_partitioned_bounds<'tcx>(
         this.tcx().sess.span_err(
             b.trait_ref.path.span,
             format!("only the builtin traits can be used \
-                     as closure or object bounds")[]);
+                     as closure or object bounds").index(&FullRange));
     }
 
     let region_bound = compute_region_bound(this,
@@ -1626,7 +1631,7 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
                                   builtin_bounds: ty::BuiltinBounds)
                                   -> Option<ty::Region>
 {
-    debug!("compute_opt_region_bound(explicit_region_bounds={}, \
+    debug!("compute_opt_region_bound(explicit_region_bounds={:?}, \
            principal_trait_ref={}, builtin_bounds={})",
            explicit_region_bounds,
            principal_trait_ref.repr(tcx),
@@ -1669,7 +1674,7 @@ fn compute_opt_region_bound<'tcx>(tcx: &ty::ctxt<'tcx>,
         tcx.sess.span_err(
             span,
             format!("ambiguous lifetime bound, \
-                     explicit lifetime bound required")[]);
+                     explicit lifetime bound required").index(&FullRange));
     }
     return Some(r);
 }
@@ -1695,7 +1700,7 @@ fn compute_region_bound<'tcx>(
                 None => {
                     this.tcx().sess.span_err(
                         span,
-                        format!("explicit lifetime bound required")[]);
+                        format!("explicit lifetime bound required").index(&FullRange));
                     ty::ReStatic
                 }
             }
index 1392592a70fbfc0f3118effca4e17293c3fff655..d9829fd14168c5fc48d82649a8e2b3217f3e13b6 100644 (file)
@@ -195,7 +195,7 @@ pub fn check_pat<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
         ast::PatRegion(ref inner, mutbl) => {
             let inner_ty = fcx.infcx().next_ty_var();
 
-            // SNAP b2085d9 remove this `if`-`else` entirely after next snapshot
+            // SNAP 340ac04 remove this `if`-`else` entirely after next snapshot
             let mutbl = if mutbl == ast::MutImmutable {
                 ty::deref(fcx.infcx().shallow_resolve(expected), true)
                    .map(|mt| mt.mutbl).unwrap_or(ast::MutImmutable)
@@ -505,9 +505,10 @@ pub fn check_pat_enum<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>, pat: &ast::Pat,
 
     let ctor_scheme = ty::lookup_item_type(tcx, enum_def);
     let path_scheme = if ty::is_fn_ty(ctor_scheme.ty) {
+        let fn_ret = ty::assert_no_late_bound_regions(tcx, &ty::ty_fn_ret(ctor_scheme.ty));
         ty::TypeScheme {
-            ty: ty::ty_fn_ret(ctor_scheme.ty).unwrap(),
-            ..ctor_scheme
+            ty: fn_ret.unwrap(),
+            generics: ctor_scheme.generics,
         }
     } else {
         ctor_scheme
@@ -603,7 +604,7 @@ pub fn check_struct_pat_fields<'a, 'tcx>(pcx: &pat_ctxt<'a, 'tcx>,
 
     // Typecheck each field.
     for &Spanned { node: ref field, span } in fields.iter() {
-        let field_type = match used_fields.entry(&field.ident.name) {
+        let field_type = match used_fields.entry(field.ident.name) {
             Occupied(occupied) => {
                 span_err!(tcx.sess, span, E0025,
                     "field `{}` bound multiple times in the pattern",
index b1dc033b567bbf659f58053bb30d68b553c33efe..dff216ac2935f99ff386fb77b2cca799adbc5385 100644 (file)
@@ -195,7 +195,7 @@ fn confirm_builtin_call<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
     let arg_exprs: Vec<_> = arg_exprs.iter().collect(); // for some weird reason we take &[&P<...>].
     check_argument_types(fcx,
                          call_expr.span,
-                         fn_sig.inputs[],
+                         fn_sig.inputs.as_slice(),
                          arg_exprs.as_slice(),
                          AutorefArgs::No,
                          fn_sig.variadic,
index 9945e264bfc2a4ae3493f4acb1d14f53c8f4d4b0..0079115756993771f4a5cb7b26f1db59b1779f23 100644 (file)
@@ -82,7 +82,7 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
                                   expected_sig: Option<ty::FnSig<'tcx>>) {
     let expr_def_id = ast_util::local_def(expr.id);
 
-    debug!("check_unboxed_closure kind={} expected_sig={}",
+    debug!("check_unboxed_closure kind={:?} expected_sig={}",
            kind,
            expected_sig.repr(fcx.tcx()));
 
@@ -134,7 +134,7 @@ fn check_unboxed_closure<'a,'tcx>(fcx: &FnCtxt<'a,'tcx>,
     // the `unboxed_closures` table.
     fn_ty.sig.0.inputs = vec![ty::mk_tup(fcx.tcx(), fn_ty.sig.0.inputs)];
 
-    debug!("unboxed_closure for {} --> sig={} kind={}",
+    debug!("unboxed_closure for {} --> sig={} kind={:?}",
            expr_def_id.repr(fcx.tcx()),
            fn_ty.sig.repr(fcx.tcx()),
            kind);
@@ -186,7 +186,7 @@ fn deduce_unboxed_closure_expectations_from_trait_ref<'a,'tcx>(
         None => { return None; }
     };
 
-    debug!("found object type {}", kind);
+    debug!("found object type {:?}", kind);
 
     let arg_param_ty = *trait_ref.substs().types.get(subst::TypeSpace, 0);
     let arg_param_ty = fcx.infcx().resolve_type_vars_if_possible(&arg_param_ty);
index 6352b3bb9e4ccea3d12646e2a68e9a17988174b6..cd27c20db45b45583bf903737cccf8d5c1e4807d 100644 (file)
@@ -200,7 +200,7 @@ fn fresh_receiver_substs(&mut self,
         match pick.kind {
             probe::InherentImplPick(impl_def_id) => {
                 assert!(ty::impl_trait_ref(self.tcx(), impl_def_id).is_none(),
-                        "impl {} is not an inherent impl", impl_def_id);
+                        "impl {:?} is not an inherent impl", impl_def_id);
                 let impl_polytype = check::impl_self_ty(self.fcx, self.span, impl_def_id);
 
                 (impl_polytype.substs, MethodStatic(pick.method_ty.def_id))
@@ -315,7 +315,7 @@ fn extract_trait_ref<R, F>(&mut self, self_ty: Ty<'tcx>, mut closure: F) -> R wh
                 self.tcx().sess.span_bug(
                     self.span,
                     format!("self-type `{}` for ObjectPick never dereferenced to an object",
-                            self_ty.repr(self.tcx()))[])
+                            self_ty.repr(self.tcx())).index(&FullRange))
             }
         }
     }
@@ -370,7 +370,7 @@ fn unify_receivers(&mut self,
                     format!(
                         "{} was a subtype of {} but now is not?",
                         self_ty.repr(self.tcx()),
-                        method_self_ty.repr(self.tcx()))[]);
+                        method_self_ty.repr(self.tcx())).index(&FullRange));
             }
         }
     }
@@ -562,6 +562,7 @@ fn fixup_derefs_on_method_receiver_if_necessary(&self,
                             self.fcx.adjust_expr_ty(
                                 &**base_expr,
                                 Some(&ty::AdjustDerefRef(base_adjustment.clone())));
+                        let index_expr_ty = self.fcx.expr_ty(&**index_expr);
 
                         let result = check::try_index_step(
                             self.fcx,
@@ -570,10 +571,10 @@ fn fixup_derefs_on_method_receiver_if_necessary(&self,
                             &**base_expr,
                             adjusted_base_ty,
                             base_adjustment,
-                            PreferMutLvalue);
+                            PreferMutLvalue,
+                            index_expr_ty);
 
                         if let Some((input_ty, return_ty)) = result {
-                            let index_expr_ty = self.fcx.expr_ty(&**index_expr);
                             demand::suptype(self.fcx, index_expr.span, input_ty, index_expr_ty);
 
                             let expr_ty = self.fcx.expr_ty(&**expr);
@@ -639,7 +640,7 @@ fn upcast(&mut self,
                     self.span,
                     format!("cannot upcast `{}` to `{}`",
                             source_trait_ref.repr(self.tcx()),
-                            target_trait_def_id.repr(self.tcx()))[]);
+                            target_trait_def_id.repr(self.tcx())).as_slice());
             }
         }
     }
index ad43dd84ef6b29180eebc31e181bc04f924764fa..87ea082b6b20b5b1a8a615977afb6edfe716c7bd 100644 (file)
@@ -231,7 +231,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
 
         Some(self_expr) => {
             debug!("lookup_in_trait_adjusted: inserting adjustment if needed \
-                   (self-id={}, base adjustment={}, explicit_self={})",
+                   (self-id={}, base adjustment={:?}, explicit_self={:?})",
                    self_expr.id, autoderefref, method_ty.explicit_self);
 
             match method_ty.explicit_self {
@@ -266,7 +266,7 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
                                 span,
                                 format!(
                                     "trait method is &self but first arg is: {}",
-                                    transformed_self_ty.repr(fcx.tcx()))[]);
+                                    transformed_self_ty.repr(fcx.tcx())).index(&FullRange));
                         }
                     }
                 }
@@ -275,8 +275,8 @@ pub fn lookup_in_trait_adjusted<'a, 'tcx>(fcx: &'a FnCtxt<'a, 'tcx>,
                     fcx.tcx().sess.span_bug(
                         span,
                         format!(
-                            "unexpected explicit self type in operator method: {}",
-                            method_ty.explicit_self)[]);
+                            "unexpected explicit self type in operator method: {:?}",
+                            method_ty.explicit_self).index(&FullRange));
                 }
             }
         }
@@ -330,7 +330,7 @@ pub fn report_error<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
             if is_field {
                 cx.sess.span_note(span,
                     format!("use `(s.{0})(...)` if you meant to call the \
-                            function stored in the `{0}` field", method_ustring)[]);
+                            function stored in the `{0}` field", method_ustring).index(&FullRange));
             }
 
             if static_sources.len() > 0 {
index 115711ae92b297f75360699e7c29198173370d81..4ba161fa83563af1d670b32f62878de083087a76 100644 (file)
@@ -267,7 +267,7 @@ fn assemble_inherent_impl_probe(&mut self, impl_def_id: ast::DefId) {
             return; // already visited
         }
 
-        debug!("assemble_inherent_impl_probe {}", impl_def_id);
+        debug!("assemble_inherent_impl_probe {:?}", impl_def_id);
 
         let method = match impl_method(self.tcx(), impl_def_id, self.method_name) {
             Some(m) => m,
@@ -576,7 +576,7 @@ fn assemble_unboxed_closure_candidates(&mut self,
                     self.tcx().sess.span_bug(
                         self.span,
                         format!("No entry for unboxed closure: {}",
-                                closure_def_id.repr(self.tcx()))[]);
+                                closure_def_id.repr(self.tcx())).index(&FullRange));
                 }
             };
 
@@ -745,7 +745,7 @@ fn pick_method(&mut self, self_ty: Ty<'tcx>) -> Option<PickResult<'tcx>> {
         debug!("pick_method(self_ty={})", self.infcx().ty_to_string(self_ty));
 
         debug!("searching inherent candidates");
-        match self.consider_candidates(self_ty, self.inherent_candidates[]) {
+        match self.consider_candidates(self_ty, self.inherent_candidates.index(&FullRange)) {
             None => {}
             Some(pick) => {
                 return Some(pick);
@@ -753,7 +753,7 @@ fn pick_method(&mut self, self_ty: Ty<'tcx>) -> Option<PickResult<'tcx>> {
         }
 
         debug!("searching extension candidates");
-        self.consider_candidates(self_ty, self.extension_candidates[])
+        self.consider_candidates(self_ty, self.extension_candidates.index(&FullRange))
     }
 
     fn consider_candidates(&self,
@@ -768,7 +768,7 @@ fn consider_candidates(&self,
         debug!("applicable_candidates: {}", applicable_candidates.repr(self.tcx()));
 
         if applicable_candidates.len() > 1 {
-            match self.collapse_candidates_to_trait_pick(applicable_candidates[]) {
+            match self.collapse_candidates_to_trait_pick(applicable_candidates.index(&FullRange)) {
                 Some(pick) => { return Some(Ok(pick)); }
                 None => { }
             }
@@ -864,7 +864,7 @@ fn collapse_candidates_to_trait_pick(&self,
             Some(data) => data,
             None => return None,
         };
-        if probes[1..].iter().any(|p| p.to_trait_data() != Some(trait_data)) {
+        if probes.index(&(1..)).iter().any(|p| p.to_trait_data() != Some(trait_data)) {
             return None;
         }
 
@@ -1024,7 +1024,7 @@ fn trait_method<'tcx>(tcx: &ty::ctxt<'tcx>,
                       -> Option<(uint, Rc<ty::Method<'tcx>>)>
 {
     let trait_items = ty::trait_items(tcx, trait_def_id);
-    debug!("trait_method; items: {}", trait_items);
+    debug!("trait_method; items: {:?}", trait_items);
     trait_items
         .iter()
         .filter(|item|
@@ -1126,7 +1126,7 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
 
 impl<'tcx> Repr<'tcx> for CandidateStep<'tcx> {
     fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
-        format!("CandidateStep({},{})",
+        format!("CandidateStep({},{:?})",
                 self.self_ty.repr(tcx),
                 self.adjustment)
     }
@@ -1134,19 +1134,19 @@ fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
 
 impl<'tcx> Repr<'tcx> for PickAdjustment {
     fn repr(&self, _tcx: &ty::ctxt) -> String {
-        format!("{}", self)
+        format!("{:?}", self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for PickKind<'tcx> {
     fn repr(&self, _tcx: &ty::ctxt) -> String {
-        format!("{}", self)
+        format!("{:?}", self)
     }
 }
 
 impl<'tcx> Repr<'tcx> for Pick<'tcx> {
     fn repr(&self, tcx: &ty::ctxt<'tcx>) -> String {
-        format!("Pick(method_ty={}, adjustment={}, kind={})",
+        format!("Pick(method_ty={}, adjustment={:?}, kind={:?})",
                 self.method_ty.repr(tcx),
                 self.adjustment,
                 self.kind)
index 1b51434a58cc130c5f20b9a73810ee4ba797b0c9..9563dd45ca23444a4ba77f3c706b4f10be2176d6 100644 (file)
@@ -593,7 +593,7 @@ fn check_fn<'a, 'tcx>(ccx: &'a CrateCtxt<'a, 'tcx>,
     let tcx = ccx.tcx;
     let err_count_on_creation = tcx.sess.err_count();
 
-    let arg_tys = fn_sig.inputs[];
+    let arg_tys = fn_sig.inputs.index(&FullRange);
     let ret_ty = fn_sig.output;
 
     debug!("check_fn(arg_tys={}, ret_ty={}, fn_id={})",
@@ -691,7 +691,7 @@ pub fn check_item(ccx: &CrateCtxt, it: &ast::Item) {
       ast::ItemEnum(ref enum_definition, _) => {
         check_enum_variants(ccx,
                             it.span,
-                            enum_definition.variants[],
+                            enum_definition.variants.index(&FullRange),
                             it.id);
       }
       ast::ItemFn(ref decl, _, _, _, ref body) => {
@@ -989,7 +989,7 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
                         but not in the trait",
                         token::get_name(trait_m.name),
                         ppaux::explicit_self_category_to_str(
-                            &impl_m.explicit_self))[]);
+                            &impl_m.explicit_self)).index(&FullRange));
             return;
         }
         (_, &ty::StaticExplicitSelfCategory) => {
@@ -999,7 +999,7 @@ fn compare_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
                         but not in the impl",
                         token::get_name(trait_m.name),
                         ppaux::explicit_self_category_to_str(
-                            &trait_m.explicit_self))[]);
+                            &trait_m.explicit_self)).index(&FullRange));
             return;
         }
         _ => {
@@ -1360,7 +1360,7 @@ fn check_region_bounds_on_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
                 span,
                 format!("lifetime parameters or bounds on method `{}` do \
                          not match the trait declaration",
-                        token::get_name(impl_m.name))[]);
+                        token::get_name(impl_m.name)).index(&FullRange));
             return false;
         }
 
@@ -1412,7 +1412,7 @@ fn check_region_bounds_on_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
                          from its counterpart `{}` \
                          declared in the trait",
                         impl_param.name.user_string(tcx),
-                        trait_param.name.user_string(tcx))[]);
+                        trait_param.name.user_string(tcx)).index(&FullRange));
                 true
             } else {
                 false
@@ -1422,14 +1422,14 @@ fn check_region_bounds_on_impl_method<'tcx>(tcx: &ty::ctxt<'tcx>,
                 tcx.sess.span_note(
                     span,
                     format!("the impl is missing the following bounds: `{}`",
-                            missing.user_string(tcx))[]);
+                            missing.user_string(tcx)).index(&FullRange));
             }
 
             if extra.len() != 0 {
                 tcx.sess.span_note(
                     span,
                     format!("the impl has the following extra bounds: `{}`",
-                            extra.user_string(tcx))[]);
+                            extra.user_string(tcx)).index(&FullRange));
             }
 
             if err {
@@ -1690,7 +1690,7 @@ fn resolve_type_vars_or_error(&self, t: &Ty<'tcx>) -> mc::McResult<Ty<'tcx>> {
     }
 
     pub fn tag(&self) -> String {
-        format!("{}", self as *const FnCtxt)
+        format!("{:?}", self as *const FnCtxt)
     }
 
     pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> Ty<'tcx> {
@@ -1700,7 +1700,7 @@ pub fn local_ty(&self, span: Span, nid: ast::NodeId) -> Ty<'tcx> {
                 self.tcx().sess.span_bug(
                     span,
                     format!("no type for local variable {}",
-                            nid)[]);
+                            nid).index(&FullRange));
             }
         }
     }
@@ -1886,7 +1886,7 @@ fn register_autoref_obligations(&self,
     fn register_unsize_obligations(&self,
                                    span: Span,
                                    unsize: &ty::UnsizeKind<'tcx>) {
-        debug!("register_unsize_obligations: unsize={}", unsize);
+        debug!("register_unsize_obligations: unsize={:?}", unsize);
 
         match *unsize {
             ty::UnsizeLength(..) => {}
@@ -2034,7 +2034,7 @@ pub fn expr_ty(&self, ex: &ast::Expr) -> Ty<'tcx> {
             Some(&t) => t,
             None => {
                 self.tcx().sess.bug(format!("no type for expr in fcx {}",
-                                            self.tag())[]);
+                                            self.tag()).index(&FullRange));
             }
         }
     }
@@ -2064,7 +2064,7 @@ pub fn node_ty(&self, id: ast::NodeId) -> Ty<'tcx> {
                 self.tcx().sess.bug(
                     format!("no type for node {}: {} in fcx {}",
                             id, self.tcx().map.node_to_string(id),
-                            self.tag())[]);
+                            self.tag()).index(&FullRange));
             }
         }
     }
@@ -2317,7 +2317,9 @@ fn make_overloaded_lvalue_return_type<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
 {
     match method {
         Some(method) => {
-            let ref_ty = ty::ty_fn_ret(method.ty);
+            let ref_ty = // invoked methods have all LB regions instantiated
+                ty::assert_no_late_bound_regions(
+                    fcx.tcx(), &ty::ty_fn_ret(method.ty));
             match method_call {
                 Some(method_call) => {
                     fcx.inh.method_map.borrow_mut().insert(method_call,
@@ -2377,90 +2379,6 @@ fn autoderef_for_index<'a, 'tcx, T, F>(fcx: &FnCtxt<'a, 'tcx>,
     }
 }
 
-/// Checks for a `Slice` (or `SliceMut`) impl at the relevant level of autoderef. If it finds one,
-/// installs method info and returns type of method (else None).
-fn try_overloaded_slice_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
-                                       method_call: MethodCall,
-                                       expr: &ast::Expr,
-                                       base_expr: &ast::Expr,
-                                       base_ty: Ty<'tcx>, // autoderef'd type
-                                       autoderefref: ty::AutoDerefRef<'tcx>,
-                                       lvalue_pref: LvaluePreference,
-                                       start_expr: &Option<P<ast::Expr>>,
-                                       end_expr: &Option<P<ast::Expr>>)
-                                       -> Option<(Ty<'tcx>, /* index type */
-                                                  Ty<'tcx>)> /* return type */
-{
-    let input_ty = fcx.infcx().next_ty_var();
-    let return_ty = fcx.infcx().next_ty_var();
-
-    let method = match lvalue_pref {
-        PreferMutLvalue => {
-            // Try `SliceMut` first, if preferred.
-            match fcx.tcx().lang_items.slice_mut_trait() {
-                Some(trait_did) => {
-                    let method_name = match (start_expr, end_expr) {
-                        (&Some(_), &Some(_)) => "slice_or_fail_mut",
-                        (&Some(_), &None) => "slice_from_or_fail_mut",
-                        (&None, &Some(_)) => "slice_to_or_fail_mut",
-                        (&None, &None) => "as_mut_slice_",
-                    };
-
-                    method::lookup_in_trait_adjusted(fcx,
-                                                     expr.span,
-                                                     Some(&*base_expr),
-                                                     token::intern(method_name),
-                                                     trait_did,
-                                                     autoderefref,
-                                                     base_ty,
-                                                     Some(vec![input_ty, return_ty]))
-                }
-                _ => None,
-            }
-        }
-        NoPreference => {
-            // Otherwise, fall back to `Slice`.
-            match fcx.tcx().lang_items.slice_trait() {
-                Some(trait_did) => {
-                    let method_name = match (start_expr, end_expr) {
-                        (&Some(_), &Some(_)) => "slice_or_fail",
-                        (&Some(_), &None) => "slice_from_or_fail",
-                        (&None, &Some(_)) => "slice_to_or_fail",
-                        (&None, &None) => "as_slice_",
-                    };
-
-                    method::lookup_in_trait_adjusted(fcx,
-                                                     expr.span,
-                                                     Some(&*base_expr),
-                                                     token::intern(method_name),
-                                                     trait_did,
-                                                     autoderefref,
-                                                     base_ty,
-                                                     Some(vec![input_ty, return_ty]))
-                }
-                _ => None,
-            }
-        }
-    };
-
-    // If some lookup succeeded, install method in table
-    method.map(|method| {
-        let method_ty = method.ty;
-        make_overloaded_lvalue_return_type(fcx, Some(method_call), Some(method));
-
-        let result_ty = ty::ty_fn_ret(method_ty);
-        let result_ty = match result_ty {
-            ty::FnConverging(result_ty) => result_ty,
-            ty::FnDiverging => {
-                fcx.tcx().sess.span_bug(expr.span,
-                "slice trait does not define a `!` return")
-            }
-        };
-
-        (input_ty, result_ty)
-    })
-}
-
 /// To type-check `base_expr[index_expr]`, we progressively autoderef (and otherwise adjust)
 /// `base_expr`, looking for a type which either supports builtin indexing or overloaded indexing.
 /// This loop implements one step in that search; the autoderef loop is implemented by
@@ -2471,29 +2389,32 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                             base_expr: &ast::Expr,
                             adjusted_ty: Ty<'tcx>,
                             adjustment: ty::AutoDerefRef<'tcx>,
-                            lvalue_pref: LvaluePreference)
+                            lvalue_pref: LvaluePreference,
+                            index_ty: Ty<'tcx>)
                             -> Option<(/*index type*/ Ty<'tcx>, /*element type*/ Ty<'tcx>)>
 {
-    debug!("try_index_step(expr={}, base_expr.id={}, adjusted_ty={}, adjustment={})",
-           expr.repr(fcx.tcx()),
-           base_expr.repr(fcx.tcx()),
-           adjusted_ty.repr(fcx.tcx()),
-           adjustment);
-
-    // Try built-in indexing first.
-    match ty::index(adjusted_ty) {
-        Some(ty) => {
+    let tcx = fcx.tcx();
+    debug!("try_index_step(expr={}, base_expr.id={}, adjusted_ty={}, adjustment={:?}, index_ty={})",
+           expr.repr(tcx),
+           base_expr.repr(tcx),
+           adjusted_ty.repr(tcx),
+           adjustment,
+           index_ty.repr(tcx));
+
+    let input_ty = fcx.infcx().next_ty_var();
+
+    // First, try built-in indexing.
+    match (ty::index(adjusted_ty), &index_ty.sty) {
+        (Some(ty), &ty::ty_uint(ast::TyUs)) | (Some(ty), &ty::ty_infer(ty::IntVar(_))) => {
+            debug!("try_index_step: success, using built-in indexing");
             fcx.write_adjustment(base_expr.id, base_expr.span, ty::AdjustDerefRef(adjustment));
-            return Some((fcx.tcx().types.uint, ty));
+            return Some((tcx.types.uint, ty));
         }
-
-        None => { }
+        _ => {}
     }
 
-    let input_ty = fcx.infcx().next_ty_var();
-
     // Try `IndexMut` first, if preferred.
-    let method = match (lvalue_pref, fcx.tcx().lang_items.index_mut_trait()) {
+    let method = match (lvalue_pref, tcx.lang_items.index_mut_trait()) {
         (PreferMutLvalue, Some(trait_did)) => {
             method::lookup_in_trait_adjusted(fcx,
                                              expr.span,
@@ -2508,14 +2429,14 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
     };
 
     // Otherwise, fall back to `Index`.
-    let method = match (method, fcx.tcx().lang_items.index_trait()) {
+    let method = match (method, tcx.lang_items.index_trait()) {
         (None, Some(trait_did)) => {
             method::lookup_in_trait_adjusted(fcx,
                                              expr.span,
                                              Some(&*base_expr),
                                              token::intern("index"),
                                              trait_did,
-                                             adjustment,
+                                             adjustment.clone(),
                                              adjusted_ty,
                                              Some(vec![input_ty]))
         }
@@ -2526,6 +2447,7 @@ fn try_index_step<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
     // type from the method signature.
     // If some lookup succeeded, install method in table
     method.and_then(|method| {
+        debug!("try_index_step: success, using overloaded indexing");
         make_overloaded_lvalue_return_type(fcx, Some(method_call), Some(method)).
             map(|ret| (input_ty, ret.ty))
     })
@@ -2544,7 +2466,7 @@ fn lookup_method_for_for_loop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
         Ok(trait_did) => trait_did,
         Err(ref err_string) => {
             fcx.tcx().sess.span_err(iterator_expr.span,
-                                    err_string[]);
+                                    err_string.index(&FullRange));
             return fcx.tcx().types.err
         }
     };
@@ -2571,7 +2493,7 @@ fn lookup_method_for_for_loop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                                         format!("`for` loop expression has type `{}` which does \
                                                 not implement the `Iterator` trait; \
                                                 maybe try .iter()",
-                                                ty_string)[]);
+                                                ty_string).index(&FullRange));
             }
             fcx.tcx().types.err
         }
@@ -2609,7 +2531,7 @@ fn lookup_method_for_for_loop<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                                             format!("`next` method of the `Iterator` \
                                                     trait has an unexpected type `{}`",
                                                     fcx.infcx().ty_to_string(return_type))
-                                            []);
+                                            .index(&FullRange));
                     fcx.tcx().types.err
                 }
             }
@@ -2636,7 +2558,7 @@ fn check_method_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
 
         check_argument_types(fcx,
                              sp,
-                             err_inputs[],
+                             err_inputs.index(&FullRange),
                              args_no_rcvr,
                              autoref_args,
                              false,
@@ -2731,7 +2653,7 @@ fn check_argument_types<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
         err_args(fcx.tcx(), supplied_arg_count)
     };
 
-    debug!("check_argument_types: formal_tys={}",
+    debug!("check_argument_types: formal_tys={:?}",
            formal_tys.iter().map(|t| fcx.infcx().ty_to_string(*t)).collect::<Vec<String>>());
 
     // Check the arguments.
@@ -3088,7 +3010,7 @@ fn check_method_call(fcx: &FnCtxt,
         };
 
         // Call the generic checker.
-        let args: Vec<_> = args[1..].iter().map(|x| x).collect();
+        let args: Vec<_> = args.index(&(1..)).iter().map(|x| x).collect();
         let ret_ty = check_method_argument_types(fcx,
                                                  method_name.span,
                                                  fn_ty,
@@ -3181,7 +3103,7 @@ fn lookup_op_method<'a, 'tcx, F>(fcx: &'a FnCtxt<'a, 'tcx>,
                     }
                 };
 
-                debug!("adjusted_ty={} adjustment={}",
+                debug!("adjusted_ty={} adjustment={:?}",
                        adj_ty.repr(fcx.tcx()),
                        adjustment);
 
@@ -3406,7 +3328,7 @@ fn check_field(fcx: &FnCtxt,
                     ty::ty_struct(base_id, substs) => {
                         debug!("struct named {}", ppaux::ty_to_string(tcx, base_t));
                         let fields = ty::lookup_struct_fields(tcx, base_id);
-                        lookup_field_ty(tcx, base_id, fields[],
+                        lookup_field_ty(tcx, base_id, fields.index(&FullRange),
                                         field.node.name, &(*substs))
                     }
                     _ => None
@@ -3469,7 +3391,7 @@ fn check_tup_field(fcx: &FnCtxt,
                         if tuple_like {
                             debug!("tuple struct named {}", ppaux::ty_to_string(tcx, base_t));
                             let fields = ty::lookup_struct_fields(tcx, base_id);
-                            lookup_tup_field_ty(tcx, base_id, fields[],
+                            lookup_tup_field_ty(tcx, base_id, fields.index(&FullRange),
                                                 idx.node, &(*substs))
                         } else {
                             None
@@ -3634,7 +3556,7 @@ fn check_struct_constructor(fcx: &FnCtxt,
                                        class_id,
                                        id,
                                        fcx.ccx.tcx.mk_substs(struct_substs),
-                                       class_fields[],
+                                       class_fields.index(&FullRange),
                                        fields,
                                        base_expr.is_none(),
                                        None);
@@ -3677,7 +3599,7 @@ fn check_struct_enum_variant(fcx: &FnCtxt,
                                        variant_id,
                                        id,
                                        fcx.ccx.tcx.mk_substs(substitutions),
-                                       variant_fields[],
+                                       variant_fields.index(&FullRange),
                                        fields,
                                        true,
                                        Some(enum_id));
@@ -4056,7 +3978,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
           callee::check_call(fcx, expr, &**callee, args.as_slice());
       }
       ast::ExprMethodCall(ident, ref tps, ref args) => {
-        check_method_call(fcx, expr, ident, args[], tps[], lvalue_pref);
+        check_method_call(fcx, expr, ident, args.as_slice(), tps.as_slice(), lvalue_pref);
         let arg_tys = args.iter().map(|a| fcx.expr_ty(&**a));
         let  args_err = arg_tys.fold(false,
              |rest_err, a| {
@@ -4144,7 +4066,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
         let expected = expected.only_has_type();
         let flds = expected.map_to_option(fcx, |ty| {
             match ty.sty {
-                ty::ty_tup(ref flds) => Some(flds[]),
+                ty::ty_tup(ref flds) => Some(flds.index(&FullRange)),
                 _ => None
             }
         });
@@ -4178,7 +4100,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
         let struct_id = match def {
             Some(def::DefVariant(enum_id, variant_id, true)) => {
                 check_struct_enum_variant(fcx, id, expr.span, enum_id,
-                                          variant_id, fields[]);
+                                          variant_id, fields.index(&FullRange));
                 enum_id
             }
             Some(def::DefTrait(def_id)) => {
@@ -4187,7 +4109,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                     pprust::path_to_string(path));
                 check_struct_fields_on_error(fcx,
                                              id,
-                                             fields[],
+                                             fields.index(&FullRange),
                                              base_expr);
                 def_id
             },
@@ -4200,7 +4122,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                                                  id,
                                                  expr.span,
                                                  struct_did,
-                                                 fields[],
+                                                 fields.index(&FullRange),
                                                  base_expr.as_ref().map(|e| &**e));
                     }
                     _ => {
@@ -4209,7 +4131,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                             pprust::path_to_string(path));
                         check_struct_fields_on_error(fcx,
                                                      id,
-                                                     fields[],
+                                                     fields.index(&FullRange),
                                                      base_expr);
                     }
                 }
@@ -4250,7 +4172,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
                                          fcx.infcx()
                                             .ty_to_string(
                                                 actual_structure_type),
-                                         type_error_description)[]);
+                                         type_error_description).index(&FullRange));
                     ty::note_and_explain_type_err(tcx, &type_error);
                 }
             }
@@ -4270,91 +4192,45 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
           if ty::type_is_error(base_t) {
               fcx.write_ty(id, base_t);
           } else {
-              match idx.node {
-                ast::ExprRange(ref start, ref end) => {
-                  // A slice, rather than an index. Special cased for now (KILLME).
+              check_expr(fcx, &**idx);
+              let idx_t = fcx.expr_ty(&**idx);
+              if ty::type_is_error(idx_t) {
+                  fcx.write_ty(id, idx_t);
+              } else {
                   let base_t = structurally_resolved_type(fcx, expr.span, base_t);
 
                   let result =
                       autoderef_for_index(fcx, &**base, base_t, lvalue_pref, |adj_ty, adj| {
-                          try_overloaded_slice_step(fcx,
-                                                    MethodCall::expr(expr.id),
-                                                    expr,
-                                                    &**base,
-                                                    adj_ty,
-                                                    adj,
-                                                    lvalue_pref,
-                                                    start,
-                                                    end)
+                          try_index_step(fcx,
+                                         MethodCall::expr(expr.id),
+                                         expr,
+                                         &**base,
+                                         adj_ty,
+                                         adj,
+                                         lvalue_pref,
+                                         idx_t)
                       });
 
-                  let mut args = vec![];
-                  start.as_ref().map(|x| args.push(x));
-                  end.as_ref().map(|x| args.push(x));
-
                   match result {
                       Some((index_ty, element_ty)) => {
-                          for a in args.iter() {
-                            check_expr_has_type(fcx, &***a, index_ty);
-                          }
-                          fcx.write_ty(idx.id, element_ty);
-                          fcx.write_ty(id, element_ty)
+                          // FIXME: we've already checked idx above, we should
+                          // probably just demand subtype or something here.
+                          check_expr_has_type(fcx, &**idx, index_ty);
+                          fcx.write_ty(id, element_ty);
                       }
                       _ => {
-                          for a in args.iter() {
-                            check_expr(fcx, &***a);
-                          }
-                          fcx.type_error_message(expr.span,
-                             |actual| {
-                                  format!("cannot take a slice of a value with type `{}`",
+                          check_expr_has_type(fcx, &**idx, fcx.tcx().types.err);
+                          fcx.type_error_message(
+                              expr.span,
+                              |actual| {
+                                  format!("cannot index a value of type `{}`",
                                           actual)
-                             },
-                             base_t,
-                             None);
-                          fcx.write_ty(idx.id, fcx.tcx().types.err);
+                              },
+                              base_t,
+                              None);
                           fcx.write_ty(id, fcx.tcx().types.err);
                       }
                   }
-                }
-                _ => {
-                  check_expr(fcx, &**idx);
-                  let idx_t = fcx.expr_ty(&**idx);
-                  if ty::type_is_error(idx_t) {
-                      fcx.write_ty(id, idx_t);
-                  } else {
-                      let base_t = structurally_resolved_type(fcx, expr.span, base_t);
-
-                      let result =
-                          autoderef_for_index(fcx, &**base, base_t, lvalue_pref, |adj_ty, adj| {
-                              try_index_step(fcx,
-                                             MethodCall::expr(expr.id),
-                                             expr,
-                                             &**base,
-                                             adj_ty,
-                                             adj,
-                                             lvalue_pref)
-                          });
-
-                      match result {
-                          Some((index_ty, element_ty)) => {
-                              check_expr_has_type(fcx, &**idx, index_ty);
-                              fcx.write_ty(id, element_ty);
-                          }
-                          _ => {
-                              check_expr_has_type(fcx, &**idx, fcx.tcx().types.err);
-                              fcx.type_error_message(
-                                  expr.span,
-                                  |actual| {
-                                      format!("cannot index a value of type `{}`",
-                                              actual)
-                                  },
-                                  base_t,
-                                  None);
-                              fcx.write_ty(id, fcx.tcx().types.err);
-                          }
-                      }
-                  }
-                }
               }
           }
        }
@@ -4387,7 +4263,7 @@ fn check_struct_fields_on_error(fcx: &FnCtxt,
           };
 
           // Note that we don't check the type of start/end satisfy any
-          // bounds because right the range structs do not have any. If we add
+          // bounds because right now the range structs do not have any. If we add
           // some bounds, then we'll need to check `t_start` against them here.
 
           let range_type = match idx_type {
@@ -4859,7 +4735,7 @@ fn uint_in_range(ccx: &CrateCtxt, ty: ast::UintTy, disr: ty::Disr) -> bool {
                 ast::TyU16 => disr as u16 as Disr == disr,
                 ast::TyU32 => disr as u32 as Disr == disr,
                 ast::TyU64 => disr as u64 as Disr == disr,
-                ast::TyU => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
+                ast::TyUs => uint_in_range(ccx, ccx.tcx.sess.target.uint_type, disr)
             }
         }
         fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
@@ -4868,7 +4744,7 @@ fn int_in_range(ccx: &CrateCtxt, ty: ast::IntTy, disr: ty::Disr) -> bool {
                 ast::TyI16 => disr as i16 as Disr == disr,
                 ast::TyI32 => disr as i32 as Disr == disr,
                 ast::TyI64 => disr as i64 as Disr == disr,
-                ast::TyI => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
+                ast::TyIs => int_in_range(ccx, ccx.tcx.sess.target.int_type, disr)
             }
         }
         match ty {
@@ -4971,7 +4847,7 @@ fn do_check<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>,
     }
 
     let hint = *ty::lookup_repr_hints(ccx.tcx, ast::DefId { krate: ast::LOCAL_CRATE, node: id })
-                    [].get(0).unwrap_or(&attr::ReprAny);
+                    .index(&FullRange).get(0).unwrap_or(&attr::ReprAny);
 
     if hint != attr::ReprAny && vs.len() <= 1 {
         if vs.len() == 1 {
@@ -5178,7 +5054,7 @@ pub fn instantiate_path<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
     }
     assert_eq!(segment_spaces.len(), path.segments.len());
 
-    debug!("segment_spaces={}", segment_spaces);
+    debug!("segment_spaces={:?}", segment_spaces);
 
     // Next, examine the definition, and determine how many type
     // parameters we expect from each space.
@@ -5402,7 +5278,7 @@ fn adjust_type_parameters<'a, 'tcx>(
                               .take_while(|d| d.default.is_none())
                               .count();
 
-        debug!("adjust_type_parameters(space={}, \
+        debug!("adjust_type_parameters(space={:?}, \
                provided_len={}, \
                desired_len={}, \
                required_len={})",
@@ -5642,7 +5518,7 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
             "get_tydesc" => {
               let tydesc_ty = match ty::get_tydesc_ty(ccx.tcx) {
                   Ok(t) => t,
-                  Err(s) => { tcx.sess.span_fatal(it.span, s[]); }
+                  Err(s) => { tcx.sess.span_fatal(it.span, s.index(&FullRange)); }
               };
               let td_ptr = ty::mk_ptr(ccx.tcx, ty::mt {
                   ty: tydesc_ty,
@@ -5658,7 +5534,7 @@ fn param<'a, 'tcx>(ccx: &CrateCtxt<'a, 'tcx>, n: u32) -> Ty<'tcx> {
                                 ty::mk_struct(ccx.tcx, did,
                                               ccx.tcx.mk_substs(subst::Substs::empty()))),
                     Err(msg) => {
-                        tcx.sess.span_fatal(it.span, msg[]);
+                        tcx.sess.span_fatal(it.span, msg.index(&FullRange));
                     }
                 }
             },
index c7df5ed8453fd3a990658694248c632f5f65dfef..11ad7bcb0915927e9697eb1dc5156a39ef1b26a9 100644 (file)
@@ -188,8 +188,8 @@ fn region_of_def(fcx: &FnCtxt, def: def::Def) -> ty::Region {
             }
         }
         _ => {
-            tcx.sess.bug(format!("unexpected def in region_of_def: {}",
-                                 def)[])
+            tcx.sess.bug(format!("unexpected def in region_of_def: {:?}",
+                                 def).index(&FullRange))
         }
     }
 }
@@ -282,13 +282,13 @@ fn visit_fn_body(&mut self,
             Some(f) => f,
             None => {
                 self.tcx().sess.bug(
-                    format!("No fn-sig entry for id={}", id)[]);
+                    format!("No fn-sig entry for id={}", id).index(&FullRange));
             }
         };
 
         let len = self.region_bound_pairs.len();
-        self.relate_free_regions(fn_sig[], body.id);
-        link_fn_args(self, CodeExtent::from_node_id(body.id), fn_decl.inputs[]);
+        self.relate_free_regions(fn_sig.index(&FullRange), body.id);
+        link_fn_args(self, CodeExtent::from_node_id(body.id), fn_decl.inputs.index(&FullRange));
         self.visit_block(body);
         self.visit_region_obligations(body.id);
         self.region_bound_pairs.truncate(len);
@@ -484,7 +484,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
 
     // Check any autoderefs or autorefs that appear.
     for &adjustment in rcx.fcx.inh.adjustments.borrow().get(&expr.id).iter() {
-        debug!("adjustment={}", adjustment);
+        debug!("adjustment={:?}", adjustment);
         match *adjustment {
             ty::AdjustDerefRef(ty::AutoDerefRef {autoderefs, autoref: ref opt_autoref}) => {
                 let expr_ty = rcx.resolve_node_type(expr.id);
@@ -582,7 +582,9 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
                 Some(method) => {
                     constrain_call(rcx, expr, Some(&**base),
                                    None::<ast::Expr>.iter(), true);
-                    ty::ty_fn_ret(method.ty).unwrap()
+                    let fn_ret = // late-bound regions in overloaded method calls are instantiated
+                        ty::assert_no_late_bound_regions(rcx.tcx(), &ty::ty_fn_ret(method.ty));
+                    fn_ret.unwrap()
                 }
                 None => rcx.resolve_node_type(base.id)
             };
@@ -627,7 +629,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) {
         }
 
         ast::ExprMatch(ref discr, ref arms, _) => {
-            link_match(rcx, &**discr, arms[]);
+            link_match(rcx, &**discr, arms.index(&FullRange));
 
             visit::walk_expr(rcx, expr);
         }
@@ -828,7 +830,7 @@ fn constrain_free_variables_in_by_ref_closure(
         debug!("constrain_free_variables({}, {})",
                region_bound.repr(tcx), expr.repr(tcx));
         for freevar in freevars.iter() {
-            debug!("freevar def is {}", freevar.def);
+            debug!("freevar def is {:?}", freevar.def);
 
             // Identify the variable being closed over and its node-id.
             let def = freevar.def;
@@ -952,7 +954,7 @@ fn constrain_autoderefs<'a, 'tcx>(rcx: &mut Rcx<'a, 'tcx>,
                     ty::ty_rptr(r, ref m) => (m.mutbl, r),
                     _ => rcx.tcx().sess.span_bug(deref_expr.span,
                             format!("bad overloaded deref type {}",
-                                    method.ty.repr(rcx.tcx()))[])
+                                    method.ty.repr(rcx.tcx())).index(&FullRange))
                 };
                 {
                     let mc = mc::MemCategorizationContext::new(rcx.fcx);
@@ -1038,7 +1040,7 @@ fn type_of_node_must_outlive<'a, 'tcx>(
                            rcx.fcx.inh.adjustments.borrow().get(&id),
                            |method_call| rcx.resolve_method_type(method_call));
     debug!("constrain_regions_in_type_of_node(\
-            ty={}, ty0={}, id={}, minimum_lifetime={})",
+            ty={}, ty0={}, id={}, minimum_lifetime={:?})",
            ty_to_string(tcx, ty), ty_to_string(tcx, ty0),
            id, minimum_lifetime);
     type_must_outlive(rcx, origin, ty, minimum_lifetime);
@@ -1090,7 +1092,7 @@ fn link_match(rcx: &Rcx, discr: &ast::Expr, arms: &[ast::Arm]) {
 /// then ensures that the lifetime of the resulting pointer is
 /// linked to the lifetime of its guarantor (if any).
 fn link_fn_args(rcx: &Rcx, body_scope: CodeExtent, args: &[ast::Arg]) {
-    debug!("regionck::link_fn_args(body_scope={})", body_scope);
+    debug!("regionck::link_fn_args(body_scope={:?})", body_scope);
     let mc = mc::MemCategorizationContext::new(rcx.fcx);
     for arg in args.iter() {
         let arg_ty = rcx.fcx.node_ty(arg.id);
@@ -1144,7 +1146,7 @@ fn link_autoref(rcx: &Rcx,
                 autoderefs: uint,
                 autoref: &ty::AutoRef) {
 
-    debug!("link_autoref(autoref={})", autoref);
+    debug!("link_autoref(autoref={:?})", autoref);
     let mc = mc::MemCategorizationContext::new(rcx.fcx);
     let expr_cmt = ignore_err!(mc.cat_expr_autoderefd(expr, autoderefs));
     debug!("expr_cmt={}", expr_cmt.repr(rcx.tcx()));
@@ -1165,7 +1167,7 @@ fn link_by_ref(rcx: &Rcx,
                expr: &ast::Expr,
                callee_scope: CodeExtent) {
     let tcx = rcx.tcx();
-    debug!("link_by_ref(expr={}, callee_scope={})",
+    debug!("link_by_ref(expr={}, callee_scope={:?})",
            expr.repr(tcx), callee_scope);
     let mc = mc::MemCategorizationContext::new(rcx.fcx);
     let expr_cmt = ignore_err!(mc.cat_expr(expr));
@@ -1318,7 +1320,7 @@ fn link_reborrowed_region<'a, 'tcx>(rcx: &Rcx<'a, 'tcx>,
                         span,
                         format!("Illegal upvar id: {}",
                                 upvar_id.repr(
-                                    rcx.tcx()))[]);
+                                    rcx.tcx())).index(&FullRange));
                 }
             }
         }
index 7ca21bdf5b83f7eaacac5c1114a9107cb9e25801..84d94b0392e9df33be97a4fab3d0c9d7e49f5e1a 100644 (file)
@@ -147,7 +147,7 @@ fn accumulate_from_ty(&mut self, ty: Ty<'tcx>) {
             ty::ty_open(_) => {
                 self.tcx.sess.bug(
                     format!("Unexpected type encountered while doing wf check: {}",
-                            ty.repr(self.tcx))[]);
+                            ty.repr(self.tcx)).index(&FullRange));
             }
         }
     }
index 92fda96595c7bab805f73eee53d20fe823e70cad..ec44d765a8e683d5de02b7072414b8781428c75a 100644 (file)
@@ -134,7 +134,7 @@ fn check_closure(&mut self,
                         let var_node_id = freevar.def.local_node_id();
                         let upvar_id = ty::UpvarId { var_id: var_node_id,
                                                      closure_expr_id: expr.id };
-                        debug!("seed upvar_id {}", upvar_id);
+                        debug!("seed upvar_id {:?}", upvar_id);
                         let origin = UpvarRegion(upvar_id, expr.span);
                         let freevar_region = self.infcx().next_region_var(origin);
                         let upvar_borrow = ty::UpvarBorrow { kind: ty::ImmBorrow,
@@ -269,7 +269,7 @@ fn adjust_upvar_borrow_kind(&self,
                                 upvar_id: ty::UpvarId,
                                 upvar_borrow: &mut ty::UpvarBorrow,
                                 kind: ty::BorrowKind) {
-        debug!("adjust_upvar_borrow_kind: id={} kind=({} -> {})",
+        debug!("adjust_upvar_borrow_kind: id={:?} kind=({:?} -> {:?})",
                upvar_id, upvar_borrow.kind, kind);
 
         match (upvar_borrow.kind, kind) {
@@ -337,7 +337,7 @@ fn borrow(&mut self,
               bk: ty::BorrowKind,
               _loan_cause: euv::LoanCause)
     {
-        debug!("borrow(borrow_id={}, cmt={}, bk={})",
+        debug!("borrow(borrow_id={}, cmt={}, bk={:?})",
                borrow_id, cmt.repr(self.tcx()), bk);
 
         match bk {
index 87ede24226bdba8d653b8452e2f30b5f8d0da6b9..e302609bf228b52160820ae0faa461914addd6fc 100644 (file)
@@ -74,7 +74,7 @@ pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                 source_expr.span,
                 format!("can only cast an boxed pointer \
                          to a boxed object, not a {}",
-                        ty::ty_sort_string(fcx.tcx(), source_ty))[]);
+                        ty::ty_sort_string(fcx.tcx(), source_ty)).index(&FullRange));
         }
 
         (_, &ty::ty_rptr(..)) => {
@@ -82,7 +82,7 @@ pub fn check_object_cast<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
                 source_expr.span,
                 format!("can only cast a &-pointer \
                          to an &-object, not a {}",
-                        ty::ty_sort_string(fcx.tcx(), source_ty))[]);
+                        ty::ty_sort_string(fcx.tcx(), source_ty)).index(&FullRange));
         }
 
         _ => {
index c38b0e8ab317071f309bcbfda2ade08d0c1660d1..898a5f9fe0c3a5539c56e810c95847eb8ff6b56f 100644 (file)
@@ -86,13 +86,14 @@ fn with_fcx<F>(&mut self, item: &ast::Item, mut f: F) where
     {
         let ccx = self.ccx;
         let item_def_id = local_def(item.id);
-        let polytype = ty::lookup_item_type(ccx.tcx, item_def_id);
+        let type_scheme = ty::lookup_item_type(ccx.tcx, item_def_id);
+        reject_non_type_param_bounds(ccx.tcx, item.span, &type_scheme.generics);
         let param_env =
             ty::construct_parameter_environment(ccx.tcx,
-                                                &polytype.generics,
+                                                &type_scheme.generics,
                                                 item.id);
         let inh = Inherited::new(ccx.tcx, param_env);
-        let fcx = blank_fn_ctxt(ccx, &inh, ty::FnConverging(polytype.ty), item.id);
+        let fcx = blank_fn_ctxt(ccx, &inh, ty::FnConverging(type_scheme.ty), item.id);
         f(self, &fcx);
         vtable::select_all_fcx_obligations_or_error(&fcx);
         regionck::regionck_item(&fcx, item);
@@ -143,10 +144,12 @@ fn check_item_type(&mut self,
                                                         item.span,
                                                         region::CodeExtent::from_node_id(item.id),
                                                         Some(&mut this.cache));
+
             let type_scheme = ty::lookup_item_type(fcx.tcx(), local_def(item.id));
             let item_ty = fcx.instantiate_type_scheme(item.span,
                                                       &fcx.inh.param_env.free_substs,
                                                       &type_scheme.ty);
+
             bounds_checker.check_traits_in_ty(item_ty);
         });
     }
@@ -178,6 +181,7 @@ fn check_impl(&mut self,
                 None => { return; }
                 Some(t) => { t }
             };
+
             let trait_ref = fcx.instantiate_type_scheme(item.span,
                                                         &fcx.inh.param_env.free_substs,
                                                         &trait_ref);
@@ -229,6 +233,35 @@ fn check_impl(&mut self,
     }
 }
 
+// Reject any predicates that do not involve a type parameter.
+fn reject_non_type_param_bounds<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                      span: Span,
+                                      generics: &ty::Generics<'tcx>) {
+    for predicate in generics.predicates.iter() {
+        match predicate {
+            &ty::Predicate::Trait(ty::Binder(ref tr)) => {
+                let self_ty = tr.self_ty();
+                if !self_ty.walk().any(|t| is_ty_param(t)) {
+                    tcx.sess.span_err(
+                        span,
+                        format!("cannot bound type `{}`, where clause \
+                                 bounds may only be attached to types involving \
+                                 type parameters",
+                                 self_ty.repr(tcx)).as_slice())
+                }
+            }
+            _ => {}
+        }
+    }
+
+    fn is_ty_param(ty: ty::Ty) -> bool {
+        match &ty.sty {
+            &ty::sty::ty_param(_) => true,
+            _ => false
+        }
+    }
+}
+
 impl<'ccx, 'tcx, 'v> Visitor<'v> for CheckTypeWellFormedVisitor<'ccx, 'tcx> {
     fn visit_item(&mut self, i: &ast::Item) {
         self.check_item_well_formed(i);
@@ -416,7 +449,13 @@ fn enum_variants<'a, 'tcx>(fcx: &FnCtxt<'a, 'tcx>,
             match variant.node.kind {
                 ast::TupleVariantKind(ref args) if args.len() > 0 => {
                     let ctor_ty = ty::node_id_to_type(fcx.tcx(), variant.node.id);
-                    let arg_tys = ty::ty_fn_args(ctor_ty);
+
+                    // the regions in the argument types come from the
+                    // enum def'n, and hence will all be early bound
+                    let arg_tys =
+                        ty::assert_no_late_bound_regions(
+                            fcx.tcx(), &ty::ty_fn_args(ctor_ty));
+
                     AdtVariant {
                         fields: args.iter().enumerate().map(|(index, arg)| {
                             let arg_ty = arg_tys[index];
index 70644b6e7de5d5386b9822c655205263188547aa..82da22eab98373c137a107e4881c89193f02b56b 100644 (file)
@@ -287,7 +287,7 @@ fn visit_adjustments(&self, reason: ResolveReason, id: ast::NodeId) {
                         })
                     }
                 };
-                debug!("Adjustments for node {}: {}", id, resolved_adjustment);
+                debug!("Adjustments for node {}: {:?}", id, resolved_adjustment);
                 self.tcx().adjustments.borrow_mut().insert(
                     id, resolved_adjustment);
             }
@@ -300,7 +300,7 @@ fn visit_method_map_entry(&self,
         // Resolve any method map entry
         match self.fcx.inh.method_map.borrow_mut().remove(&method_call) {
             Some(method) => {
-                debug!("writeback::resolve_method_map_entry(call={}, entry={})",
+                debug!("writeback::resolve_method_map_entry(call={:?}, entry={})",
                        method_call,
                        method.repr(self.tcx()));
                 let new_method = MethodCallee {
index 09ab98745bd6a59a1d1573ca603a6a1508badabd..a0f30788bbddcc72cba8f5129641a427fa4db5ef 100644 (file)
@@ -81,7 +81,7 @@ fn get_base_type_def_id<'a, 'tcx>(inference_context: &InferCtxt<'a, 'tcx>,
             inference_context.tcx.sess.span_bug(
                 span,
                 format!("coherence encountered unexpected type searching for base type: {}",
-                        ty.repr(inference_context.tcx))[]);
+                        ty.repr(inference_context.tcx)).index(&FullRange));
         }
     }
 }
@@ -204,7 +204,7 @@ fn instantiate_default_methods(
             trait_ref: &ty::TraitRef<'tcx>,
             all_impl_items: &mut Vec<ImplOrTraitItemId>) {
         let tcx = self.crate_context.tcx;
-        debug!("instantiate_default_methods(impl_id={}, trait_ref={})",
+        debug!("instantiate_default_methods(impl_id={:?}, trait_ref={})",
                impl_id, trait_ref.repr(tcx));
 
         let impl_type_scheme = ty::lookup_item_type(tcx, impl_id);
@@ -215,7 +215,7 @@ fn instantiate_default_methods(
             let new_id = tcx.sess.next_node_id();
             let new_did = local_def(new_id);
 
-            debug!("new_did={} trait_method={}", new_did, trait_method.repr(tcx));
+            debug!("new_did={:?} trait_method={}", new_did, trait_method.repr(tcx));
 
             // Create substitutions for the various trait parameters.
             let new_method_ty =
@@ -268,7 +268,7 @@ fn add_inherent_impl(&self, base_def_id: DefId, impl_def_id: DefId) {
     }
 
     fn add_trait_impl(&self, base_def_id: DefId, impl_def_id: DefId) {
-        debug!("add_trait_impl: base_def_id={} impl_def_id={}",
+        debug!("add_trait_impl: base_def_id={:?} impl_def_id={:?}",
                base_def_id, impl_def_id);
         ty::record_trait_implementation(self.crate_context.tcx,
                                         base_def_id,
@@ -490,7 +490,7 @@ fn check_implementations_of_copy(&self) {
                                  format!("the trait `Copy` may not be \
                                           implemented for this type; field \
                                           `{}` does not implement `Copy`",
-                                         token::get_name(name))[])
+                                         token::get_name(name)).index(&FullRange))
                 }
                 Err(ty::VariantDoesNotImplementCopy(name)) => {
                     tcx.sess
@@ -498,7 +498,7 @@ fn check_implementations_of_copy(&self) {
                                  format!("the trait `Copy` may not be \
                                           implemented for this type; variant \
                                           `{}` does not implement `Copy`",
-                                         token::get_name(name))[])
+                                         token::get_name(name)).index(&FullRange))
                 }
                 Err(ty::TypeIsStructural) => {
                     tcx.sess
index bbafcdae1bba104b27a4ad05f95b2f03834fd224..79e98f15a2d43daf7a4a609886f632debf61542e 100644 (file)
@@ -35,7 +35,7 @@
 use middle::region;
 use middle::resolve_lifetime;
 use middle::subst;
-use middle::subst::{Substs};
+use middle::subst::{Substs, TypeSpace};
 use middle::ty::{AsPredicate, ImplContainer, ImplOrTraitItemContainer, TraitContainer};
 use middle::ty::{self, RegionEscape, Ty, TypeScheme};
 use middle::ty_fold::{self, TypeFolder, TypeFoldable};
@@ -47,6 +47,7 @@
 use util::ppaux::{Repr,UserString};
 use write_ty_to_tcx;
 
+use std::collections::HashSet;
 use std::rc::Rc;
 
 use syntax::abi;
@@ -169,7 +170,7 @@ fn get_item_type_scheme(&self, id: ast::DefId) -> ty::TypeScheme<'tcx> {
             }
             x => {
                 self.tcx.sess.bug(format!("unexpected sort of node \
-                                           in get_item_type_scheme(): {}",
+                                           in get_item_type_scheme(): {:?}",
                                           x).as_slice());
             }
         }
@@ -211,7 +212,7 @@ fn get_enum_variant_types<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
             ast::TupleVariantKind(ref args) if args.len() > 0 => {
                 let rs = ExplicitRscope;
                 let input_tys: Vec<_> = args.iter().map(|va| ccx.to_ty(&rs, &*va.ty)).collect();
-                ty::mk_ctor_fn(tcx, variant_def_id, input_tys[], enum_ty)
+                ty::mk_ctor_fn(tcx, variant_def_id, input_tys.index(&FullRange), enum_ty)
             }
 
             ast::TupleVariantKind(_) => {
@@ -258,7 +259,7 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
                                     ccx,
                                     trait_id,
                                     &trait_def.generics,
-                                    trait_items[],
+                                    trait_items.index(&FullRange),
                                     &m.id,
                                     &m.ident.name,
                                     &m.explicit_self,
@@ -272,7 +273,7 @@ fn collect_trait_methods<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
                                     ccx,
                                     trait_id,
                                     &trait_def.generics,
-                                    trait_items[],
+                                    trait_items.index(&FullRange),
                                     &m.id,
                                     &m.pe_ident().name,
                                     m.pe_explicit_self(),
@@ -475,7 +476,7 @@ fn convert_methods<'a,'tcx,'i,I>(ccx: &CollectCtxt<'a, 'tcx>,
 
         write_ty_to_tcx(tcx, m.id, fty);
 
-        debug!("writing method type: def_id={} mty={}",
+        debug!("writing method type: def_id={:?} mty={}",
                mty.def_id, mty.repr(ccx.tcx));
 
         tcx.impl_or_trait_items
@@ -644,6 +645,10 @@ fn convert(ccx: &CollectCtxt, it: &ast::Item) {
                                                Some(selfty),
                                                None);
             }
+
+            enforce_impl_ty_params_are_constrained(ccx.tcx,
+                                                   generics,
+                                                   local_def(it.id));
         },
         ast::ItemTrait(_, _, _, ref trait_methods) => {
             let trait_def = trait_def_of_item(ccx, it);
@@ -774,7 +779,7 @@ fn convert_struct<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
                             local_def(field.node.id)].ty).collect();
                 let ctor_fn_ty = ty::mk_ctor_fn(tcx,
                                                 local_def(ctor_id),
-                                                inputs[],
+                                                inputs.index(&FullRange),
                                                 selfty);
                 write_ty_to_tcx(tcx, ctor_id, ctor_fn_ty);
                 tcx.tcache.borrow_mut().insert(local_def(ctor_id),
@@ -815,7 +820,7 @@ fn get_trait_def<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
         ast_map::NodeItem(item) => trait_def_of_item(ccx, &*item),
         _ => {
             ccx.tcx.sess.bug(format!("get_trait_def({}): not an item",
-                                     trait_id.node)[])
+                                     trait_id.node).index(&FullRange))
         }
     }
 }
@@ -840,7 +845,7 @@ fn trait_def_of_item<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
         ref s => {
             tcx.sess.span_bug(
                 it.span,
-                format!("trait_def_of_item invoked on {}", s)[]);
+                format!("trait_def_of_item invoked on {:?}", s).index(&FullRange));
         }
     };
 
@@ -1025,8 +1030,8 @@ fn ty_generics_for_type_or_impl<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
                                           -> ty::Generics<'tcx> {
     ty_generics(ccx,
                 subst::TypeSpace,
-                generics.lifetimes[],
-                generics.ty_params[],
+                generics.lifetimes.index(&FullRange),
+                generics.ty_params.index(&FullRange),
                 ty::Generics::empty(),
                 &generics.where_clause)
 }
@@ -1044,8 +1049,8 @@ fn ty_generics_for_trait<'a, 'tcx>(ccx: &CollectCtxt<'a, 'tcx>,
     let mut generics =
         ty_generics(ccx,
                     subst::TypeSpace,
-                    ast_generics.lifetimes[],
-                    ast_generics.ty_params[],
+                    ast_generics.lifetimes.index(&FullRange),
+                    ast_generics.ty_params.index(&FullRange),
                     ty::Generics::empty(),
                     &ast_generics.where_clause);
 
@@ -1130,8 +1135,8 @@ fn ty_generics_for_fn_or_method<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
     let early_lifetimes = resolve_lifetime::early_bound_lifetimes(generics);
     ty_generics(ccx,
                 subst::FnSpace,
-                early_lifetimes[],
-                generics.ty_params[],
+                early_lifetimes.index(&FullRange),
+                generics.ty_params.index(&FullRange),
                 base_generics,
                 &generics.where_clause)
 }
@@ -1201,7 +1206,7 @@ fn ty_generics<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
                                            index: i as u32,
                                            def_id: local_def(l.lifetime.id),
                                            bounds: bounds };
-        debug!("ty_generics: def for region param: {}", def);
+        debug!("ty_generics: def for region param: {:?}", def);
         result.regions.push(space, def);
     }
 
@@ -1213,7 +1218,7 @@ fn ty_generics<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
                                                    space,
                                                    param,
                                                    i as u32);
-        debug!("ty_generics: def for type param: {}, {}",
+        debug!("ty_generics: def for type param: {}, {:?}",
                def.repr(ccx.tcx),
                space);
         result.types.push(space, def);
@@ -1318,7 +1323,7 @@ fn get_or_create_type_parameter_def<'a,'tcx>(ccx: &CollectCtxt<'a,'tcx>,
     let param_ty = ty::ParamTy::new(space, index, param.ident.name);
     let bounds = compute_bounds(ccx,
                                 param_ty.to_ty(ccx.tcx),
-                                param.bounds[],
+                                param.bounds.index(&FullRange),
                                 SizedByDefault::Yes,
                                 param.span);
     let default = match param.default {
@@ -1399,7 +1404,7 @@ fn check_bounds_compatible<'tcx>(tcx: &ty::ctxt<'tcx>,
     if !param_bounds.builtin_bounds.contains(&ty::BoundSized) {
         ty::each_bound_trait_and_supertraits(
             tcx,
-            param_bounds.trait_bounds[],
+            param_bounds.trait_bounds.index(&FullRange),
             |trait_ref| {
                 let trait_def = ty::lookup_trait_def(tcx, trait_ref.def_id());
                 if trait_def.bounds.builtin_bounds.contains(&ty::BoundSized) {
@@ -1605,3 +1610,96 @@ fn liberate_early_bound_regions<'tcx,T>(
         })
     }
 }
+
+/// Checks that all the type parameters on an impl
+fn enforce_impl_ty_params_are_constrained<'tcx>(tcx: &ty::ctxt<'tcx>,
+                                                ast_generics: &ast::Generics,
+                                                impl_def_id: ast::DefId)
+{
+    let impl_scheme = ty::lookup_item_type(tcx, impl_def_id);
+    let impl_trait_ref = ty::impl_trait_ref(tcx, impl_def_id);
+
+    // The trait reference is an input, so find all type parameters
+    // reachable from there, to start (if this is an inherent impl,
+    // then just examine the self type).
+    let mut input_parameters: HashSet<_> =
+        impl_trait_ref.iter()
+                      .flat_map(|t| t.input_types().iter()) // Types in trait ref, if any
+                      .chain(Some(impl_scheme.ty).iter())  // Self type, always
+                      .flat_map(|t| t.walk())
+                      .filter_map(to_opt_param_ty)
+                      .collect();
+
+    loop {
+        let num_inputs = input_parameters.len();
+
+        let mut projection_predicates =
+            impl_scheme.generics.predicates
+            .iter()
+            .filter_map(|predicate| {
+                match *predicate {
+                    // Ignore higher-ranked binders. For the purposes
+                    // of this check, they don't matter because they
+                    // only affect named regions, and we're just
+                    // concerned about type parameters here.
+                    ty::Predicate::Projection(ref data) => Some(data.0.clone()),
+                    _ => None,
+                }
+            });
+
+        for projection in projection_predicates {
+            // Special case: watch out for some kind of sneaky attempt
+            // to project out an associated type defined by this very trait.
+            if Some(projection.projection_ty.trait_ref.clone()) == impl_trait_ref {
+                continue;
+            }
+
+            let relies_only_on_inputs =
+                projection.projection_ty.trait_ref.input_types().iter()
+                .flat_map(|t| t.walk())
+                .filter_map(to_opt_param_ty)
+                .all(|t| input_parameters.contains(&t));
+
+            if relies_only_on_inputs {
+                input_parameters.extend(
+                    projection.ty.walk().filter_map(to_opt_param_ty));
+            }
+        }
+
+        if input_parameters.len() == num_inputs {
+            break;
+        }
+    }
+
+    for (index, ty_param) in ast_generics.ty_params.iter().enumerate() {
+        let param_ty = ty::ParamTy { space: TypeSpace,
+                                     idx: index as u32,
+                                     name: ty_param.ident.name };
+        if !input_parameters.contains(&param_ty) {
+            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());
+            } else {
+                tcx.sess.span_err(
+                    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());
+                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());
+            }
+        }
+    }
+
+    fn to_opt_param_ty<'tcx>(ty: Ty<'tcx>) -> Option<ty::ParamTy> {
+        match ty.sty {
+            ty::ty_param(ref d) => Some(d.clone()),
+            _ => None,
+        }
+    }
+}
index dc434f1401585af1fa782235e983011bb418430e..ae8731dfa476b1e4e20ab0c101f6826906d25b97 100644 (file)
       html_favicon_url = "http://www.rust-lang.org/favicon.ico",
       html_root_url = "http://doc.rust-lang.org/nightly/")]
 
-#![feature(default_type_params, globs, macro_rules, phase, quote)]
+#![feature(quote)]
 #![feature(slicing_syntax, unsafe_destructor)]
 #![feature(rustc_diagnostic_macros)]
-#![feature(unboxed_closures)]
 #![allow(non_camel_case_types)]
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate syntax;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate syntax;
+#[macro_use] extern crate log;
+#[macro_use] extern crate syntax;
 
 extern crate arena;
 extern crate rustc;
@@ -207,7 +193,7 @@ fn require_same_types<'a, 'tcx, M>(tcx: &ty::ctxt<'tcx>,
                               format!("{}: {}",
                                       msg(),
                                       ty::type_err_to_str(tcx,
-                                                          terr))[]);
+                                                          terr)).index(&FullRange));
             ty::note_and_explain_type_err(tcx, terr);
             false
         }
@@ -256,7 +242,7 @@ fn check_main_fn_ty(ccx: &CrateCtxt,
                               format!("main has a non-function type: found \
                                        `{}`",
                                       ppaux::ty_to_string(tcx,
-                                                       main_t))[]);
+                                                       main_t)).index(&FullRange));
         }
     }
 }
@@ -307,7 +293,7 @@ fn check_start_fn_ty(ccx: &CrateCtxt,
             tcx.sess.span_bug(start_span,
                               format!("start has a non-function type: found \
                                        `{}`",
-                                      ppaux::ty_to_string(tcx, start_t))[]);
+                                      ppaux::ty_to_string(tcx, start_t)).index(&FullRange));
         }
     }
 }
index e58c2275fcd96448c9836330cfe2bad49df4120f..393ba19ba182ab2ae54f0f048dd11a6a5f11b06b 100644 (file)
@@ -243,8 +243,8 @@ enum VarianceTerm<'a> {
 impl<'a> fmt::Show for VarianceTerm<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
-            ConstantTerm(c1) => write!(f, "{}", c1),
-            TransformTerm(v1, v2) => write!(f, "({} \u{00D7} {})", v1, v2),
+            ConstantTerm(c1) => write!(f, "{:?}", c1),
+            TransformTerm(v1, v2) => write!(f, "({:?} \u{00D7} {:?})", v1, v2),
             InferredTerm(id) => write!(f, "[{}]", { let InferredIndex(i) = id; i })
         }
     }
@@ -323,10 +323,10 @@ fn add_inferred(&mut self,
         assert!(newly_added);
 
         debug!("add_inferred(item_id={}, \
-                kind={}, \
+                kind={:?}, \
                 index={}, \
                 param_id={},
-                inf_index={})",
+                inf_index={:?})",
                 item_id, kind, index, param_id, inf_index);
     }
 
@@ -402,8 +402,8 @@ fn visit_item(&mut self, item: &ast::Item) {
 struct ConstraintContext<'a, 'tcx: 'a> {
     terms_cx: TermsContext<'a, 'tcx>,
 
-    // These are the def-id of the std::kinds::marker::InvariantType,
-    // std::kinds::marker::InvariantLifetime, and so on. The arrays
+    // These are the def-id of the std::marker::InvariantType,
+    // std::marker::InvariantLifetime, and so on. The arrays
     // are indexed by the `ParamKind` (type, lifetime, self). Note
     // that there are no marker types for self, so the entries for
     // self are always None.
@@ -564,7 +564,7 @@ fn inferred_index(&self, param_id: ast::NodeId) -> InferredIndex {
             None => {
                 self.tcx().sess.bug(format!(
                         "no inferred index entry for {}",
-                        self.tcx().map.node_to_string(param_id))[]);
+                        self.tcx().map.node_to_string(param_id)).index(&FullRange));
             }
         }
     }
@@ -673,8 +673,8 @@ fn declared_variance(&self,
     fn add_constraint(&mut self,
                       InferredIndex(index): InferredIndex,
                       variance: VarianceTermPtr<'a>) {
-        debug!("add_constraint(index={}, variance={})",
-                index, variance.to_string());
+        debug!("add_constraint(index={}, variance={:?})",
+                index, variance);
         self.constraints.push(Constraint { inferred: InferredIndex(index),
                                            variance: variance });
     }
@@ -839,7 +839,7 @@ fn add_constraints_from_ty(&mut self,
                 self.tcx().sess.bug(
                     format!("unexpected type encountered in \
                             variance inference: {}",
-                            ty.repr(self.tcx()))[]);
+                            ty.repr(self.tcx())).index(&FullRange));
             }
         }
     }
@@ -854,7 +854,7 @@ fn add_constraints_from_substs(&mut self,
                                    region_param_defs: &[ty::RegionParameterDef],
                                    substs: &subst::Substs<'tcx>,
                                    variance: VarianceTermPtr<'a>) {
-        debug!("add_constraints_from_substs(def_id={})", def_id);
+        debug!("add_constraints_from_substs(def_id={:?})", def_id);
 
         for p in type_param_defs.iter() {
             let variance_decl =
@@ -919,7 +919,7 @@ fn add_constraints_from_region(&mut self,
                     .sess
                     .bug(format!("unexpected region encountered in variance \
                                   inference: {}",
-                                 region.repr(self.tcx()))[]);
+                                 region.repr(self.tcx())).index(&FullRange));
             }
         }
     }
@@ -988,14 +988,14 @@ fn solve(&mut self) {
                 let new_value = glb(variance, old_value);
                 if old_value != new_value {
                     debug!("Updating inferred {} (node {}) \
-                            from {} to {} due to {}",
+                            from {:?} to {:?} due to {:?}",
                             inferred,
                             self.terms_cx
                                 .inferred_infos[inferred]
                                 .param_id,
                             old_value,
                             new_value,
-                            term.to_string());
+                            term);
 
                     self.solutions[inferred] = new_value;
                     changed = true;
@@ -1028,7 +1028,7 @@ fn write(&self) {
                   inferred_infos[index].item_id == item_id {
                 let info = &inferred_infos[index];
                 let variance = solutions[index];
-                debug!("Index {} Info {} / {} / {} Variance {}",
+                debug!("Index {} Info {} / {:?} / {:?} Variance {:?}",
                        index, info.index, info.kind, info.space, variance);
                 match info.kind {
                     TypeParam => {
@@ -1055,7 +1055,7 @@ fn write(&self) {
             // attribute and report an error with various results if found.
             if ty::has_attr(tcx, item_def_id, "rustc_variance") {
                 let found = item_variances.repr(tcx);
-                tcx.sess.span_err(tcx.map.span(item_id), found[]);
+                tcx.sess.span_err(tcx.map.span(item_id), found.index(&FullRange));
             }
 
             let newly_added = tcx.item_variance_map.borrow_mut()
index 3eda39f54a997e8a036a280d024bf73c92bed2bf..3e2474468adb696c8edc83717f67794a538c0973 100644 (file)
@@ -397,9 +397,9 @@ fn build_const(cx: &DocContext, tcx: &ty::ctxt,
     use syntax::print::pprust;
 
     let expr = const_eval::lookup_const_by_id(tcx, did).unwrap_or_else(|| {
-        panic!("expected lookup_const_by_id to succeed for {}", did);
+        panic!("expected lookup_const_by_id to succeed for {:?}", did);
     });
-    debug!("converting constant expr {} to snippet", expr);
+    debug!("converting constant expr {:?} to snippet", expr);
     let sn = pprust::expr_to_string(expr);
     debug!("got snippet {}", sn);
 
index bb9a9ac430340642d193d21293af34296674a4a0..bf2664bba6ad3b973442ccb637bf4b905c5506da 100644 (file)
@@ -397,7 +397,7 @@ fn clean(&self, cx: &DocContext) -> Item {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub enum Attribute {
     Word(String),
     List(String, Vec<Attribute> ),
@@ -450,7 +450,7 @@ fn value_str(&self) -> Option<InternedString> { (**self).value_str() }
     fn meta_item_list(&self) -> Option<&[P<ast::MetaItem>]> { None }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct TyParam {
     pub name: String,
     pub did: ast::DefId,
@@ -483,7 +483,7 @@ fn clean(&self, cx: &DocContext) -> TyParam {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub enum TyParamBound {
     RegionBound(Lifetime),
     TraitBound(PolyTrait, ast::TraitBoundModifier)
@@ -621,7 +621,7 @@ fn clean(&self, cx: &DocContext) -> TyParamBound {
         cx.external_paths.borrow_mut().as_mut().unwrap().insert(self.def_id,
                                                             (fqn, TypeTrait));
 
-        debug!("ty::TraitRef\n  substs.types(TypeSpace): {}\n",
+        debug!("ty::TraitRef\n  substs.types(TypeSpace): {:?}\n",
                self.substs.types.get_slice(ParamSpace::TypeSpace));
 
         // collect any late bound regions
@@ -632,7 +632,7 @@ fn clean(&self, cx: &DocContext) -> TyParamBound {
                 for &ty_s in ts.iter() {
                     if let sty::ty_rptr(ref reg, _) = ty_s.sty {
                         if let &Region::ReLateBound(_, _) = *reg {
-                            debug!("  hit an ReLateBound {}", reg);
+                            debug!("  hit an ReLateBound {:?}", reg);
                             if let Some(lt) = reg.clean(cx) {
                                 late_bounds.push(lt)
                             }
@@ -674,7 +674,7 @@ fn clean(&self, cx: &DocContext) -> Option<Vec<TyParamBound>> {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct Lifetime(String);
 
 impl Lifetime {
@@ -724,7 +724,7 @@ fn clean(&self, cx: &DocContext) -> Option<Lifetime> {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub enum WherePredicate {
     BoundPredicate { ty: Type, bounds: Vec<TyParamBound> },
     RegionPredicate { lifetime: Lifetime, bounds: Vec<Lifetime>},
@@ -757,7 +757,7 @@ fn clean(&self, cx: &DocContext) -> WherePredicate {
 }
 
 // maybe use a Generic enum and use ~[Generic]?
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct Generics {
     pub lifetimes: Vec<Lifetime>,
     pub type_params: Vec<TyParam>,
@@ -798,7 +798,7 @@ 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(),
-            _ => all_inputs[1..]
+            _ => all_inputs.index(&(1..))
         };
         let decl = FnDecl {
             inputs: Arguments {
@@ -836,7 +836,7 @@ 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(),
-            _ => self.decl.inputs[1..]
+            _ => self.decl.inputs.index(&(1..))
         };
         let decl = FnDecl {
             inputs: Arguments {
@@ -908,7 +908,7 @@ fn clean(&self, cx: &DocContext) -> Item {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct ClosureDecl {
     pub lifetimes: Vec<Lifetime>,
     pub decl: FnDecl,
@@ -929,14 +929,14 @@ fn clean(&self, cx: &DocContext) -> ClosureDecl {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct FnDecl {
     pub inputs: Arguments,
     pub output: FunctionRetTy,
     pub attrs: Vec<Attribute>,
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct Arguments {
     pub values: Vec<Argument>,
 }
@@ -989,7 +989,7 @@ fn clean(&self, cx: &DocContext) -> FnDecl {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct Argument {
     pub type_: Type,
     pub name: String,
@@ -1006,7 +1006,7 @@ fn clean(&self, cx: &DocContext) -> Argument {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub enum FunctionRetTy {
     Return(Type),
     NoReturn
@@ -1132,7 +1132,7 @@ fn clean(&self, cx: &DocContext) -> Item {
                                                self.fty.sig.clone()),
             s => {
                 let sig = ty::Binder(ty::FnSig {
-                    inputs: self.fty.sig.0.inputs[1..].to_vec(),
+                    inputs: self.fty.sig.0.inputs.index(&(1..)).to_vec(),
                     ..self.fty.sig.0.clone()
                 });
                 let s = match s {
@@ -1181,7 +1181,7 @@ fn clean(&self, cx: &DocContext) -> Item {
 }
 
 /// A trait reference, which may have higher ranked lifetimes.
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct PolyTrait {
     pub trait_: Type,
     pub lifetimes: Vec<Lifetime>
@@ -1190,7 +1190,7 @@ pub struct PolyTrait {
 /// A representation of a Type suitable for hyperlinking purposes. Ideally one can get the original
 /// type out of the AST/ty::ctxt given one of these, if more information is needed. Most importantly
 /// it does not preserve mutability or boxes.
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub enum Type {
     /// structs/enums/traits (anything that'd be an ast::TyPath)
     ResolvedPath {
@@ -1236,10 +1236,10 @@ pub enum Type {
     PolyTraitRef(Vec<TyParamBound>),
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Copy)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Eq, Hash, Copy, Show)]
 pub enum PrimitiveType {
-    Int, I8, I16, I32, I64,
-    Uint, U8, U16, U32, U64,
+    Isize, I8, I16, I32, I64,
+    Usize, U8, U16, U32, U64,
     F32, F64,
     Char,
     Bool,
@@ -1264,12 +1264,12 @@ pub enum TypeKind {
 impl PrimitiveType {
     fn from_str(s: &str) -> Option<PrimitiveType> {
         match s.as_slice() {
-            "int" => Some(Int),
+            "isize" | "int" => Some(Isize),
             "i8" => Some(I8),
             "i16" => Some(I16),
             "i32" => Some(I32),
             "i64" => Some(I64),
-            "uint" => Some(Uint),
+            "usize" | "uint" => Some(Usize),
             "u8" => Some(U8),
             "u16" => Some(U16),
             "u32" => Some(U32),
@@ -1308,12 +1308,12 @@ fn find(attrs: &[Attribute]) -> Option<PrimitiveType> {
 
     pub fn to_string(&self) -> &'static str {
         match *self {
-            Int => "int",
+            Isize => "isize",
             I8 => "i8",
             I16 => "i16",
             I32 => "i32",
             I64 => "i64",
-            Uint => "uint",
+            Usize => "usize",
             U8 => "u8",
             U16 => "u16",
             U32 => "u32",
@@ -1376,7 +1376,7 @@ fn clean(&self, cx: &DocContext) -> Type {
                 Infer
             },
             TyTypeof(..) => {
-                panic!("Unimplemented type {}", self.node)
+                panic!("Unimplemented type {:?}", self.node)
             },
         }
     }
@@ -1387,12 +1387,12 @@ fn clean(&self, cx: &DocContext) -> Type {
         match self.sty {
             ty::ty_bool => Primitive(Bool),
             ty::ty_char => Primitive(Char),
-            ty::ty_int(ast::TyI) => Primitive(Int),
+            ty::ty_int(ast::TyIs) => Primitive(Isize),
             ty::ty_int(ast::TyI8) => Primitive(I8),
             ty::ty_int(ast::TyI16) => Primitive(I16),
             ty::ty_int(ast::TyI32) => Primitive(I32),
             ty::ty_int(ast::TyI64) => Primitive(I64),
-            ty::ty_uint(ast::TyU) => Primitive(Uint),
+            ty::ty_uint(ast::TyUs) => Primitive(Usize),
             ty::ty_uint(ast::TyU8) => Primitive(U8),
             ty::ty_uint(ast::TyU16) => Primitive(U16),
             ty::ty_uint(ast::TyU32) => Primitive(U32),
@@ -1746,7 +1746,7 @@ fn clean(&self, cx: &DocContext) -> Span {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct Path {
     pub global: bool,
     pub segments: Vec<PathSegment>,
@@ -1761,7 +1761,7 @@ fn clean(&self, cx: &DocContext) -> Path {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub enum PathParameters {
     AngleBracketed {
         lifetimes: Vec<Lifetime>,
@@ -1793,7 +1793,7 @@ fn clean(&self, cx: &DocContext) -> PathParameters {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct PathSegment {
     pub name: String,
     pub params: PathParameters
@@ -1857,7 +1857,7 @@ fn clean(&self, cx: &DocContext) -> Item {
     }
 }
 
-#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq)]
+#[derive(Clone, RustcEncodable, RustcDecodable, PartialEq, Show)]
 pub struct BareFunctionDecl {
     pub unsafety: ast::Unsafety,
     pub generics: Generics,
@@ -1892,7 +1892,7 @@ pub struct Static {
 
 impl Clean<Item> for doctree::Static {
     fn clean(&self, cx: &DocContext) -> Item {
-        debug!("claning static {}: {}", self.name.clean(cx), self);
+        debug!("cleaning static {}: {:?}", self.name.clean(cx), self);
         Item {
             name: Some(self.name.clean(cx)),
             attrs: self.attrs.clean(cx),
@@ -2170,7 +2170,7 @@ trait ToSource {
 
 impl ToSource for syntax::codemap::Span {
     fn to_src(&self, cx: &DocContext) -> String {
-        debug!("converting span {} to snippet", self.clean(cx));
+        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()
@@ -2183,7 +2183,7 @@ fn to_src(&self, cx: &DocContext) -> String {
 fn lit_to_string(lit: &ast::Lit) -> String {
     match lit.node {
         ast::LitStr(ref st, _) => st.get().to_string(),
-        ast::LitBinary(ref data) => format!("{}", data),
+        ast::LitBinary(ref data) => format!("{:?}", data),
         ast::LitByte(b) => {
             let mut res = String::from_str("b'");
             for c in (b as char).escape_default() {
@@ -2202,7 +2202,7 @@ fn lit_to_string(lit: &ast::Lit) -> String {
 
 fn name_from_pat(p: &ast::Pat) -> String {
     use syntax::ast::*;
-    debug!("Trying to get a name from pattern: {}", p);
+    debug!("Trying to get a name from pattern: {:?}", p);
 
     match p.node {
         PatWild(PatWildSingle) => "_".to_string(),
@@ -2265,12 +2265,12 @@ fn resolve_type(cx: &DocContext,
             ast::TyStr => return Primitive(Str),
             ast::TyBool => return Primitive(Bool),
             ast::TyChar => return Primitive(Char),
-            ast::TyInt(ast::TyI) => return Primitive(Int),
+            ast::TyInt(ast::TyIs) => return Primitive(Isize),
             ast::TyInt(ast::TyI8) => return Primitive(I8),
             ast::TyInt(ast::TyI16) => return Primitive(I16),
             ast::TyInt(ast::TyI32) => return Primitive(I32),
             ast::TyInt(ast::TyI64) => return Primitive(I64),
-            ast::TyUint(ast::TyU) => return Primitive(Uint),
+            ast::TyUint(ast::TyUs) => return Primitive(Usize),
             ast::TyUint(ast::TyU8) => return Primitive(U8),
             ast::TyUint(ast::TyU16) => return Primitive(U16),
             ast::TyUint(ast::TyU32) => return Primitive(U32),
index a69437f7a669ca6b4526a3647c4d3992bfdb3667..46c212a9f2dbcc4dab77ec64754ce8abf4d07925 100644 (file)
@@ -136,7 +136,7 @@ pub fn run_core(search_paths: SearchPaths, cfgs: Vec<String>, externs: Externs,
         inlined: RefCell::new(Some(HashSet::new())),
         populated_crate_impls: RefCell::new(HashSet::new()),
     };
-    debug!("crate: {}", ctxt.krate);
+    debug!("crate: {:?}", ctxt.krate);
 
     let analysis = CrateAnalysis {
         exported_items: exported_items,
index b4afb67170bbdb9df8854a2f6981bf2da1e6ace8..99cd467cdfccca508e9921b68c35d7a8828f66ba 100644 (file)
 /// string when passed to a format string.
 pub struct Escape<'a>(pub &'a str);
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Escape<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Escape<'a> {
     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
index 9004d11b5bccfb2ffe910a633cbb099fbe332735..b24e7a7a4cf81a06d6fb25572293a787c1c56b5f 100644 (file)
@@ -10,7 +10,7 @@
 
 //! HTML formatting module
 //!
-//! This module contains a large number of `fmt::Show` implementations for
+//! This module contains a large number of `fmt::String` implementations for
 //! various types in `rustdoc::clean`. These implementations all currently
 //! assume that HTML output is desired, although it may be possible to redesign
 //! them in the future to instead emit any format desired.
@@ -64,7 +64,15 @@ pub fn get(&self) -> ast::Unsafety {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for TyParamBounds<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for TyParamBounds<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let &TyParamBounds(bounds) = self;
         for (i, bound) in bounds.iter().enumerate() {
@@ -77,7 +85,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-impl fmt::Show for clean::Generics {
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
+impl fmt::Show for clean::Generic {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::Generics {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         if self.lifetimes.len() == 0 && self.type_params.len() == 0 { return Ok(()) }
         try!(f.write_str("&lt;"));
@@ -97,7 +113,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
                 if i > 0 {
                     try!(f.write_str(", "))
                 }
-                try!(f.write_str(tp.name[]));
+                try!(f.write_str(tp.name.as_slice()));
 
                 if tp.bounds.len() > 0 {
                     try!(write!(f, ": {}", TyParamBounds(tp.bounds.as_slice())));
@@ -114,7 +130,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for WhereClause<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for WhereClause<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let &WhereClause(gens) = self;
         if gens.where_predicates.len() == 0 {
@@ -151,14 +175,30 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::Lifetime {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::Lifetime {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         try!(f.write_str(self.get_ref()));
         Ok(())
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::PolyTrait {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::PolyTrait {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         if self.lifetimes.len() > 0 {
             try!(f.write_str("for&lt;"));
@@ -174,7 +214,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::TyParamBound {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::TyParamBound {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::RegionBound(ref lt) => {
@@ -191,7 +239,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::PathParameters {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::PathParameters {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::PathParameters::AngleBracketed { ref lifetimes, ref types } => {
@@ -236,14 +292,30 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::PathSegment {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::PathSegment {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         try!(f.write_str(self.name.as_slice()));
         write!(f, "{}", self.params)
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::Path {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::Path {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         if self.global {
             try!(f.write_str("::"))
@@ -311,7 +383,7 @@ fn path<F, G>(w: &mut fmt::Formatter,
         match rel_root {
             Some(root) => {
                 let mut root = String::from_str(root.as_slice());
-                for seg in path.segments[..amt].iter() {
+                for seg in path.segments.index(&(0..amt)).iter() {
                     if "super" == seg.name ||
                             "self" == seg.name {
                         try!(write!(w, "{}::", seg.name));
@@ -326,7 +398,7 @@ fn path<F, G>(w: &mut fmt::Formatter,
                 }
             }
             None => {
-                for seg in path.segments[..amt].iter() {
+                for seg in path.segments.index(&(0..amt)).iter() {
                     try!(write!(w, "{}::", seg.name));
                 }
             }
@@ -337,7 +409,7 @@ fn path<F, G>(w: &mut fmt::Formatter,
         // 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 to_link = fqp[..fqp.len() - 1];
+            let to_link = &fqp[..(fqp.len() - 1)];
             for component in to_link.iter() {
                 url.push_str(component.as_slice());
                 url.push_str("/");
@@ -429,11 +501,19 @@ fn tybounds(w: &mut fmt::Formatter,
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::Type {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String 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)][])
+                f.write_str(cache().typarams[ast_util::local_def(id)].as_slice())
             }
             clean::Generic(ref name) => {
                 f.write_str(name.as_slice())
@@ -570,7 +650,16 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::Arguments {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+
+impl fmt::String for clean::Arguments {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         for (i, input) in self.values.iter().enumerate() {
             if i > 0 { try!(write!(f, ", ")); }
@@ -583,7 +672,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::FunctionRetTy {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::FunctionRetTy {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::Return(clean::Tuple(ref tys)) if tys.is_empty() => Ok(()),
@@ -593,13 +690,29 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::FnDecl {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::FnDecl {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "({args}){arrow}", args = self.inputs, arrow = self.output)
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Method<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Method<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Method(selfty, d) = *self;
         let mut args = String::new();
@@ -629,7 +742,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for VisSpace {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for VisSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
             Some(ast::Public) => write!(f, "pub "),
@@ -638,7 +759,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for UnsafetySpace {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for UnsafetySpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.get() {
             ast::Unsafety::Unsafe => write!(f, "unsafe "),
@@ -647,7 +776,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::ViewPath {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::ViewPath {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             clean::SimpleImport(ref name, ref src) => {
@@ -674,7 +811,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::ImportSource {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::ImportSource {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.did {
             Some(did) => resolved_path(f, did, &self.path, true),
@@ -691,7 +836,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for clean::ViewListIdent {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for clean::ViewListIdent {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.source {
             Some(did) => {
@@ -712,7 +865,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for MutableSpace {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for MutableSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             MutableSpace(clean::Immutable) => Ok(()),
@@ -721,7 +882,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for RawMutableSpace {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for RawMutableSpace {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             RawMutableSpace(clean::Immutable) => write!(f, "const "),
@@ -730,13 +899,21 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Stability<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Stability<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Stability(stab) = *self;
         match *stab {
             Some(ref stability) => {
                 write!(f, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
-                       lvl = stability.level.to_string(),
+                       lvl = stability.level,
                        reason = stability.text)
             }
             None => Ok(())
@@ -744,13 +921,21 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for ConciseStability<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for ConciseStability<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let ConciseStability(stab) = *self;
         match *stab {
             Some(ref stability) => {
                 write!(f, "<a class='stability {lvl}' title='{lvl}{colon}{reason}'></a>",
-                       lvl = stability.level.to_string(),
+                       lvl = stability.level,
                        colon = if stability.text.len() > 0 { ": " } else { "" },
                        reason = stability.text)
             }
@@ -761,7 +946,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for ModuleSummary {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for ModuleSummary {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         fn fmt_inner<'a>(f: &mut fmt::Formatter,
                          context: &mut Vec<&'a str>,
index 30b9d6c63c5bb127db68bb38141011e850ed0f3c..3d2c5e2cbb5fb4d933455b5744c1636362518e33 100644 (file)
@@ -34,7 +34,7 @@ pub fn highlight(src: &str, class: Option<&str>, id: Option<&str>) -> String {
          class,
          id,
          &mut out).unwrap();
-    String::from_utf8_lossy(out[]).into_owned()
+    String::from_utf8_lossy(out.index(&FullRange)).into_owned()
 }
 
 /// Exhausts the `lexer` writing the output into `out`.
index 3efaf5d491442525a5a9a6fc43b744528dbb6345..13a06f842a2767111f6882327797a4a4b3180736 100644 (file)
@@ -103,7 +103,15 @@ pub fn to_static_str(&self) -> &'static str {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl fmt::Show for ItemType {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for ItemType {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         self.to_static_str().fmt(f)
     }
index d47c6010be0baa666042a89cc8f1161b2351e375..f75ab3f431c2a23455f6a471fa2f814e3711b506 100644 (file)
@@ -30,7 +30,7 @@ pub struct Page<'a> {
     pub keywords: &'a str
 }
 
-pub fn render<T: fmt::Show, S: fmt::Show>(
+pub fn render<T: fmt::String, S: fmt::String>(
     dst: &mut io::Writer, layout: &Layout, page: &Page, sidebar: &S, t: &T)
     -> io::IoResult<()>
 {
index 3b9265cf569765a39822fea60f54c567ddc9a46a..f4660a81be496e315ce4fd92b44873091f21094e 100644 (file)
@@ -14,7 +14,7 @@
 //! (bundled into the rust runtime). This module self-contains the C bindings
 //! and necessary legwork to render markdown, and exposes all of the
 //! functionality through a unit-struct, `Markdown`, which has an implementation
-//! of `fmt::Show`. Example usage:
+//! of `fmt::String`. Example usage:
 //!
 //! ```rust,ignore
 //! use rustdoc::html::markdown::Markdown;
@@ -41,7 +41,7 @@
 use html::escape::Escape;
 use test;
 
-/// A unit struct which has the `fmt::Show` trait implemented. When
+/// A unit struct which has the `fmt::String` trait implemented. When
 /// formatted, this struct will emit the HTML corresponding to the rendered
 /// version of the contained markdown string.
 pub struct Markdown<'a>(pub &'a str);
@@ -172,7 +172,7 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
             let text = slice::from_raw_buf(&(*orig_text).data,
                                            (*orig_text).size as uint);
             let origtext = str::from_utf8(text).unwrap();
-            debug!("docblock: ==============\n{}\n=======", text);
+            debug!("docblock: ==============\n{:?}\n=======", text);
             let rendered = if lang.is_null() {
                 false
             } else {
@@ -435,7 +435,15 @@ pub fn reset_headers() {
     TEST_IDX.with(|s| s.set(0));
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Markdown<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Markdown<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let Markdown(md) = *self;
         // This is actually common enough to special-case
@@ -444,7 +452,15 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for MarkdownWithToc<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for MarkdownWithToc<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let MarkdownWithToc(md) = *self;
         render(fmt, md.as_slice(), true)
index ddb14d6944b9d8f358aed8347577e7bf06d57887..08abdc2af18dc24c435e58f76b29f44be90cae57 100644 (file)
@@ -404,7 +404,7 @@ fn build_index(krate: &clean::Crate, cache: &mut Cache) -> io::IoResult<String>
                     search_index.push(IndexItem {
                         ty: shortty(item),
                         name: item.name.clone().unwrap(),
-                        path: fqp[..fqp.len() - 1].connect("::"),
+                        path: fqp[..(fqp.len() - 1)].connect("::"),
                         desc: shorter(item.doc_value()).to_string(),
                         parent: Some(did),
                     });
@@ -559,7 +559,7 @@ fn collect(path: &Path, krate: &str,
         };
 
         let mut mydst = dst.clone();
-        for part in remote_path[..remote_path.len() - 1].iter() {
+        for part in remote_path[..(remote_path.len() - 1)].iter() {
             mydst.push(part.as_slice());
             try!(mkdir(&mydst));
         }
@@ -821,7 +821,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
         if let clean::ImplItem(ref i) = item.inner {
             match i.trait_ {
                 Some(clean::ResolvedPath{ did, .. }) => {
-                    let v = self.implementors.entry(&did).get().unwrap_or_else(
+                    let v = self.implementors.entry(did).get().unwrap_or_else(
                         |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
                     v.push(Implementor {
                         def_id: item.def_id,
@@ -842,7 +842,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                 clean::StructFieldItem(..) |
                 clean::VariantItem(..) => {
                     ((Some(*self.parent_stack.last().unwrap()),
-                      Some(self.stack[..self.stack.len() - 1])),
+                      Some(&self.stack[..(self.stack.len() - 1)])),
                      false)
                 }
                 clean::MethodItem(..) => {
@@ -853,13 +853,13 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                         let did = *last;
                         let path = match self.paths.get(&did) {
                             Some(&(_, ItemType::Trait)) =>
-                                Some(self.stack[..self.stack.len() - 1]),
+                                Some(&self.stack[..(self.stack.len() - 1)]),
                             // The current stack not necessarily has correlation for
                             // where the type was defined. On the other hand,
                             // `paths` always has the right information if present.
                             Some(&(ref fqp, ItemType::Struct)) |
                             Some(&(ref fqp, ItemType::Enum)) =>
-                                Some(fqp[..fqp.len() - 1]),
+                                Some(&fqp[..(fqp.len() - 1)]),
                             Some(..) => Some(self.stack.as_slice()),
                             None => None
                         };
@@ -1011,7 +1011,7 @@ fn fold_item(&mut self, item: clean::Item) -> Option<clean::Item> {
                         };
 
                         if let Some(did) = did {
-                            let v = self.impls.entry(&did).get().unwrap_or_else(
+                            let v = self.impls.entry(did).get().unwrap_or_else(
                                 |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
                             v.push(Impl {
                                 impl_: i,
@@ -1051,7 +1051,7 @@ fn recurse<T, F>(&mut self, s: String, f: F) -> T where
         F: FnOnce(&mut Context) -> T,
     {
         if s.len() == 0 {
-            panic!("Unexpected empty destination: {}", self.current);
+            panic!("Unexpected empty destination: {:?}", self.current);
         }
         let prev = self.dst.clone();
         self.dst.push(s.as_slice());
@@ -1185,7 +1185,7 @@ fn render(w: io::File, cx: &Context, it: &clean::Item,
                                            .collect::<String>();
                 match cache().paths.get(&it.def_id) {
                     Some(&(ref names, _)) => {
-                        for name in names[..names.len() - 1].iter() {
+                        for name in (&names[..(names.len() - 1)]).iter() {
                             url.push_str(name.as_slice());
                             url.push_str("/");
                         }
@@ -1260,7 +1260,7 @@ fn build_sidebar(&self, m: &clean::Module) -> HashMap<String, Vec<String>> {
                 Some(ref s) => s.to_string(),
             };
             let short = short.to_string();
-            let v = map.entry(&short).get().unwrap_or_else(
+            let v = map.entry(short).get().unwrap_or_else(
                 |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
             v.push(myname);
         }
@@ -1351,8 +1351,15 @@ fn href(&self, cx: &Context) -> Option<String> {
 }
 
 
-
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Item<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Item<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         // Write the breadcrumb trail header for the top
         try!(write!(fmt, "\n<h1 class='fqn'><span class='in-band'>"));
@@ -1542,7 +1549,7 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering {
 
     indices.sort_by(|&i1, &i2| cmp(&items[i1], &items[i2], i1, i2));
 
-    debug!("{}", indices);
+    debug!("{:?}", indices);
     let mut curty = None;
     for &idx in indices.iter() {
         let myitem = &items[idx];
@@ -1626,7 +1633,16 @@ fn cmp(i1: &clean::Item, i2: &clean::Item, idx1: uint, idx2: uint) -> Ordering {
 }
 
 struct Initializer<'a>(&'a str);
+
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Initializer<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Initializer<'a> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Initializer(s) = *self;
         if s.len() == 0 { return Ok(()); }
@@ -2127,7 +2143,7 @@ fn doctraititem(w: &mut fmt::Formatter, item: &clean::Item, dox: bool)
                 try!(assoc_type(w, item, typaram));
                 try!(write!(w, "</code></h4>\n"));
             }
-            _ => panic!("can't make docs for trait item with name {}", item.name)
+            _ => panic!("can't make docs for trait item with name {:?}", item.name)
         }
         match item.doc_value() {
             Some(s) if dox => {
@@ -2188,7 +2204,15 @@ fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item,
     document(w, it)
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Sidebar<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Sidebar<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let cx = self.cx;
         let it = self.item;
@@ -2243,7 +2267,15 @@ fn block(w: &mut fmt::Formatter, short: &str, longty: &str,
     }
 }
 
+//NOTE(stage0): remove impl after snapshot
+#[cfg(stage0)]
 impl<'a> fmt::Show for Source<'a> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a> fmt::String for Source<'a> {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         let Source(s) = *self;
         let lines = s.lines().count();
@@ -2267,7 +2299,7 @@ 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(),
                                           Some("macro"),
-                                          None)[]));
+                                          None).as_slice()));
     document(w, it)
 }
 
index 71313ea90b8ae4a42021483072e0bd315bc31e62..8d94e1857c41713af3559a01fb71f27693c4b8b1 100644 (file)
@@ -177,6 +177,12 @@ pub fn push<'a>(&'a mut self, level: u32, name: String, id: String) -> &'a str {
 }
 
 impl fmt::Show for Toc {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for Toc {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         try!(write!(fmt, "<ul>"));
         for entry in self.entries.iter() {
index 6e42c50f974c51f2a4748db95d47c78a2ddf9fbe..ee65ef0662305a7bf99a4a3cbd145400d8eea2f4 100644 (file)
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
-
-#![allow(unknown_features)]
-#![feature(globs, macro_rules, phase, slicing_syntax)]
-#![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
-#![feature(associated_types)]
+#![feature(slicing_syntax)]
 
 extern crate arena;
 extern crate getopts;
 extern crate serialize;
 extern crate syntax;
 extern crate "test" as testing;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
+#[macro_use] extern crate log;
 
 extern crate "serialize" as rustc_serialize; // used by deriving
 
@@ -56,8 +44,7 @@
 // reexported from `clean` so it can be easily updated with the mod itself
 pub use clean::SCHEMA_VERSION;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod externalfiles;
 
 pub mod clean;
@@ -116,7 +103,7 @@ struct Output {
 
 pub fn main() {
     static STACK_SIZE: uint = 32000000; // 32MB
-    let res = std::thread::Builder::new().stack_size(STACK_SIZE).spawn(move || {
+    let res = std::thread::Builder::new().stack_size(STACK_SIZE).scoped(move || {
         main_args(std::os::args().as_slice())
     }).join();
     std::os::set_exit_status(res.map_err(|_| ()).unwrap());
@@ -330,7 +317,7 @@ fn parse_externs(matches: &getopts::Matches) -> Result<core::Externs, String> {
             }
         };
         let name = name.to_string();
-        let locs = externs.entry(&name).get().unwrap_or_else(
+        let locs = externs.entry(name).get().unwrap_or_else(
             |vacant_entry| vacant_entry.insert(Vec::with_capacity(1)));
         locs.push(location.to_string());
     }
@@ -358,7 +345,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::spawn(move |:| {
+    let (mut krate, analysis) = std::thread::Thread::scoped(move |:| {
         let cr = cr;
         core::run_core(paths, cfgs, externs, &cr, triple)
     }).join().map_err(|_| "rustc failed").unwrap();
@@ -445,7 +432,7 @@ fn json_input(input: &str) -> Result<Output, String> {
         }
     };
     match json::from_reader(&mut input) {
-        Err(s) => Err(s.to_string()),
+        Err(s) => Err(format!("{:?}", s)),
         Ok(Json::Object(obj)) => {
             let mut obj = obj;
             // Make sure the schema is what we expect
@@ -505,7 +492,7 @@ fn json_output(krate: clean::Crate, res: Vec<plugins::PluginJson> ,
     let crate_json_str = format!("{}", json::as_json(&krate));
     let crate_json = match json::from_str(crate_json_str.as_slice()) {
         Ok(j) => j,
-        Err(e) => panic!("Rust generated JSON is invalid: {}", e)
+        Err(e) => panic!("Rust generated JSON is invalid: {:?}", e)
     };
 
     json.insert("crate".to_string(), crate_json);
index bded371e5002d2858f15a1a7431f92a4bd436fc2..bbe35eb0e9ccc53e8b6c7fe1673ee088323941ec 100644 (file)
@@ -157,7 +157,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
             None => box io::stderr() as Box<Writer>,
         };
         io::util::copy(&mut p, &mut err).unwrap();
-    }).detach();
+    });
     let emitter = diagnostic::EmitterWriter::new(box w2, None);
 
     // Compile the code
@@ -201,7 +201,7 @@ fn runtest(test: &str, cratename: &str, libs: SearchPaths,
             if should_fail && out.status.success() {
                 panic!("test executable succeeded when it should have failed");
             } else if !should_fail && !out.status.success() {
-                panic!("test executable failed:\n{}",
+                panic!("test executable failed:\n{:?}",
                       str::from_utf8(out.error.as_slice()));
             }
         }
index ad67672ea6ea741a35dc916fe31c990ee0f183f2..428b4e92a681f18dbb77154424347809b319a03b 100644 (file)
@@ -265,7 +265,7 @@ fn resolve_id(&mut self, id: ast::NodeId, renamed: Option<ast::Ident>,
 
     pub fn visit_item(&mut self, item: &ast::Item,
                       renamed: Option<ast::Ident>, om: &mut Module) {
-        debug!("Visiting item {}", item);
+        debug!("Visiting item {:?}", item);
         let name = renamed.unwrap_or(item.ident);
         match item.node {
             ast::ItemMod(ref m) => {
index 11a49cd712f2557f155bdb09a81d219119faef06..d13d110320e1754302d4c2664d3a20a3acffb860 100644 (file)
@@ -204,7 +204,7 @@ fn description(&self) -> &str {
     }
 
     fn detail(&self) -> Option<String> {
-        Some(self.to_string())
+        Some(format!("{:?}", self))
     }
 }
 
index 7ba329c518e91074cd0f5bddab7b1d96139c2e21..d89a4754d2efe0af8ccb921ed5a523e5795910c1 100644 (file)
@@ -156,6 +156,7 @@ fn decode<D: Decoder>(d: &mut D) -> Result<EnumSet<T>, D::Error> {
     }
 }
 
+#[old_impl_check]
 impl<
     K: Encodable + Hash<X> + Eq,
     V: Encodable,
@@ -175,6 +176,7 @@ fn encode<S: Encoder>(&self, e: &mut S) -> Result<(), S::Error> {
     }
 }
 
+#[old_impl_check]
 impl<
     K: Decodable + Hash<S> + Eq,
     V: Decodable,
@@ -195,6 +197,7 @@ fn decode<D: Decoder>(d: &mut D) -> Result<HashMap<K, V, H>, D::Error> {
     }
 }
 
+#[old_impl_check]
 impl<
     T: Encodable + Hash<X> + Eq,
     X,
@@ -212,6 +215,7 @@ fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
     }
 }
 
+#[old_impl_check]
 impl<
     T: Decodable + Hash<S> + Eq,
     S,
diff --git a/src/libserialize/collection_impls_stage0.rs b/src/libserialize/collection_impls_stage0.rs
deleted file mode 100644 (file)
index f2d79b1..0000000
+++ /dev/null
@@ -1,289 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// 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.
-
-//! Implementations of serialization for structures found in libcollections
-
-use std::uint;
-use std::default::Default;
-use std::hash::{Hash, Hasher};
-
-use {Decodable, Encodable, Decoder, Encoder};
-use std::collections::{DList, RingBuf, BTreeMap, BTreeSet, HashMap, HashSet, VecMap};
-use collections::enum_set::{EnumSet, CLike};
-
-impl<
-    E,
-    S: Encoder<E>,
-    T: Encodable<S, E>
-> Encodable<S, E> for DList<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_seq(self.len(), |s| {
-            for (i, e) in self.iter().enumerate() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)));
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for DList<T> {
-    fn decode(d: &mut D) -> Result<DList<T>, E> {
-        d.read_seq(|d, len| {
-            let mut list = DList::new();
-            for i in range(0u, len) {
-                list.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
-            }
-            Ok(list)
-        })
-    }
-}
-
-impl<
-    E,
-    S: Encoder<E>,
-    T: Encodable<S, E>
-> Encodable<S, E> for RingBuf<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_seq(self.len(), |s| {
-            for (i, e) in self.iter().enumerate() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)));
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for RingBuf<T> {
-    fn decode(d: &mut D) -> Result<RingBuf<T>, E> {
-        d.read_seq(|d, len| {
-            let mut deque: RingBuf<T> = RingBuf::new();
-            for i in range(0u, len) {
-                deque.push_back(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
-            }
-            Ok(deque)
-        })
-    }
-}
-
-impl<
-    E,
-    S: Encoder<E>,
-    K: Encodable<S, E> + PartialEq + Ord,
-    V: Encodable<S, E> + PartialEq
-> Encodable<S, E> for BTreeMap<K, V> {
-    fn encode(&self, e: &mut S) -> Result<(), E> {
-        e.emit_map(self.len(), |e| {
-            let mut i = 0;
-            for (key, val) in self.iter() {
-                try!(e.emit_map_elt_key(i, |e| key.encode(e)));
-                try!(e.emit_map_elt_val(i, |e| val.encode(e)));
-                i += 1;
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<
-    E,
-    D: Decoder<E>,
-    K: Decodable<D, E> + PartialEq + Ord,
-    V: Decodable<D, E> + PartialEq
-> Decodable<D, E> for BTreeMap<K, V> {
-    fn decode(d: &mut D) -> Result<BTreeMap<K, V>, E> {
-        d.read_map(|d, len| {
-            let mut map = BTreeMap::new();
-            for i in range(0u, len) {
-                let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
-                let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
-                map.insert(key, val);
-            }
-            Ok(map)
-        })
-    }
-}
-
-impl<
-    E,
-    S: Encoder<E>,
-    T: Encodable<S, E> + PartialEq + Ord
-> Encodable<S, E> for BTreeSet<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_seq(self.len(), |s| {
-            let mut i = 0;
-            for e in self.iter() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)));
-                i += 1;
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<
-    E,
-    D: Decoder<E>,
-    T: Decodable<D, E> + PartialEq + Ord
-> Decodable<D, E> for BTreeSet<T> {
-    fn decode(d: &mut D) -> Result<BTreeSet<T>, E> {
-        d.read_seq(|d, len| {
-            let mut set = BTreeSet::new();
-            for i in range(0u, len) {
-                set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
-            }
-            Ok(set)
-        })
-    }
-}
-
-impl<
-    E,
-    S: Encoder<E>,
-    T: Encodable<S, E> + CLike
-> Encodable<S, E> for EnumSet<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        let mut bits = 0;
-        for item in self.iter() {
-            bits |= item.to_uint();
-        }
-        s.emit_uint(bits)
-    }
-}
-
-impl<
-    E,
-    D: Decoder<E>,
-    T: Decodable<D, E> + CLike
-> Decodable<D, E> for EnumSet<T> {
-    fn decode(d: &mut D) -> Result<EnumSet<T>, E> {
-        let bits = try!(d.read_uint());
-        let mut set = EnumSet::new();
-        for bit in range(0, uint::BITS) {
-            if bits & (1 << bit) != 0 {
-                set.insert(CLike::from_uint(1 << bit));
-            }
-        }
-        Ok(set)
-    }
-}
-
-impl<
-    E,
-    S: Encoder<E>,
-    K: Encodable<S, E> + Hash<X> + Eq,
-    V: Encodable<S, E>,
-    X,
-    H: Hasher<X>
-> Encodable<S, E> for HashMap<K, V, H> {
-    fn encode(&self, e: &mut S) -> Result<(), E> {
-        e.emit_map(self.len(), |e| {
-            let mut i = 0;
-            for (key, val) in self.iter() {
-                try!(e.emit_map_elt_key(i, |e| key.encode(e)));
-                try!(e.emit_map_elt_val(i, |e| val.encode(e)));
-                i += 1;
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<
-    E,
-    D: Decoder<E>,
-    K: Decodable<D, E> + Hash<S> + Eq,
-    V: Decodable<D, E>,
-    S,
-    H: Hasher<S> + Default
-> Decodable<D, E> for HashMap<K, V, H> {
-    fn decode(d: &mut D) -> Result<HashMap<K, V, H>, E> {
-        d.read_map(|d, len| {
-            let hasher = Default::default();
-            let mut map = HashMap::with_capacity_and_hasher(len, hasher);
-            for i in range(0u, len) {
-                let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
-                let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
-                map.insert(key, val);
-            }
-            Ok(map)
-        })
-    }
-}
-
-impl<
-    E,
-    S: Encoder<E>,
-    T: Encodable<S, E> + Hash<X> + Eq,
-    X,
-    H: Hasher<X>
-> Encodable<S, E> for HashSet<T, H> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_seq(self.len(), |s| {
-            let mut i = 0;
-            for e in self.iter() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)));
-                i += 1;
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<
-    E,
-    D: Decoder<E>,
-    T: Decodable<D, E> + Hash<S> + Eq,
-    S,
-    H: Hasher<S> + Default
-> Decodable<D, E> for HashSet<T, H> {
-    fn decode(d: &mut D) -> Result<HashSet<T, H>, E> {
-        d.read_seq(|d, len| {
-            let mut set = HashSet::with_capacity_and_hasher(len, Default::default());
-            for i in range(0u, len) {
-                set.insert(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
-            }
-            Ok(set)
-        })
-    }
-}
-
-impl<
-    E,
-    S: Encoder<E>,
-    V: Encodable<S, E>
-> Encodable<S, E> for VecMap<V> {
-    fn encode(&self, e: &mut S) -> Result<(), E> {
-        e.emit_map(self.len(), |e| {
-                for (i, (key, val)) in self.iter().enumerate() {
-                    try!(e.emit_map_elt_key(i, |e| key.encode(e)));
-                    try!(e.emit_map_elt_val(i, |e| val.encode(e)));
-                }
-                Ok(())
-            })
-    }
-}
-
-impl<
-    E,
-    D: Decoder<E>,
-    V: Decodable<D, E>
-> Decodable<D, E> for VecMap<V> {
-    fn decode(d: &mut D) -> Result<VecMap<V>, E> {
-        d.read_map(|d, len| {
-            let mut map = VecMap::new();
-            for i in range(0u, len) {
-                let key = try!(d.read_map_elt_key(i, |d| Decodable::decode(d)));
-                let val = try!(d.read_map_elt_val(i, |d| Decodable::decode(d)));
-                map.insert(key, val);
-            }
-            Ok(map)
-        })
-    }
-}
index 542d0678526b980367b48e41cd8f6ab0545c4a1c..a11eb3f789875563904e24a1c57fb491f3dcce3a 100644 (file)
@@ -88,7 +88,7 @@ fn description(&self) -> &str {
     }
 
     fn detail(&self) -> Option<String> {
-        Some(self.to_string())
+        Some(format!("{:?}", self))
     }
 }
 
@@ -112,7 +112,7 @@ impl FromHex for str {
     ///     let hello_str = "Hello, World".as_bytes().to_hex();
     ///     println!("{}", hello_str);
     ///     let bytes = hello_str.as_slice().from_hex().unwrap();
-    ///     println!("{}", bytes);
+    ///     println!("{:?}", bytes);
     ///     let result_str = String::from_utf8(bytes).unwrap();
     ///     println!("{}", result_str);
     /// }
index 8b0fb75b438fec3096545be149f17bb760aaa673..b7bf40a6ec52dc685494b03137a7382e00e31e77 100644 (file)
 //! ```
 
 use self::JsonEvent::*;
-use self::StackElement::*;
 use self::ErrorCode::*;
 use self::ParserError::*;
 use self::DecoderError::*;
 use std::num::FpCategory as Fp;
 use std::str::FromStr;
 use std::string;
-use std::ops;
+use std::ops::Index;
 use unicode::str as unicode_str;
 use unicode::str::Utf16Item;
 
 use Encodable;
 
 /// Represents a json value
-#[derive(Clone, PartialEq, PartialOrd)]
+#[derive(Clone, PartialEq, PartialOrd, Show)]
 pub enum Json {
     I64(i64),
     U64(u64),
@@ -332,7 +331,7 @@ fn io_error_to_error(io: io::IoError) -> ParserError {
 
 impl std::error::Error for DecoderError {
     fn description(&self) -> &str { "decoder error" }
-    fn detail(&self) -> Option<std::string::String> { Some(self.to_string()) }
+    fn detail(&self) -> Option<std::string::String> { Some(format!("{:?}", self)) }
 }
 
 pub type EncodeResult = fmt::Result;
@@ -384,7 +383,7 @@ fn escape_str(wr: &mut fmt::Writer, v: &str) -> fmt::Result {
         };
 
         if start < i {
-            try!(wr.write_str(v[start..i]));
+            try!(wr.write_str(v.index(&(start..i))));
         }
 
         try!(wr.write_str(escaped));
@@ -393,7 +392,7 @@ fn escape_str(wr: &mut fmt::Writer, v: &str) -> fmt::Result {
     }
 
     if start != v.len() {
-        try!(wr.write_str(v[start..]));
+        try!(wr.write_str(v.index(&(start..))));
     }
 
     wr.write_str("\"")
@@ -402,7 +401,7 @@ fn escape_str(wr: &mut fmt::Writer, v: &str) -> fmt::Result {
 fn escape_char(writer: &mut fmt::Writer, v: char) -> fmt::Result {
     let mut buf = [0; 4];
     let n = v.encode_utf8(&mut buf).unwrap();
-    let buf = unsafe { str::from_utf8_unchecked(buf[0..n]) };
+    let buf = unsafe { str::from_utf8_unchecked(buf.index(&(0..n))) };
     escape_str(writer, buf)
 }
 
@@ -415,7 +414,7 @@ fn spaces(wr: &mut fmt::Writer, mut n: uint) -> fmt::Result {
     }
 
     if n > 0 {
-        wr.write_str(BUF[..n])
+        wr.write_str(BUF.index(&(0..n)))
     } else {
         Ok(())
     }
@@ -624,7 +623,7 @@ fn emit_map_elt_key<F>(&mut self, idx: uint, mut f: F) -> EncodeResult where
             let mut check_encoder = Encoder::new(&mut buf);
             try!(f(transmute(&mut check_encoder)));
         }
-        let out = str::from_utf8(buf[]).unwrap();
+        let out = str::from_utf8(buf.index(&FullRange)).unwrap();
         let needs_wrapping = out.char_at(0) != '"' && out.char_at_reverse(out.len()) != '"';
         if needs_wrapping { try!(write!(self.writer, "\"")); }
         try!(f(self));
@@ -895,7 +894,7 @@ fn emit_map_elt_key<F>(&mut self, idx: uint, mut f: F) -> EncodeResult where
             let mut check_encoder = PrettyEncoder::new(&mut buf);
             try!(f(transmute(&mut check_encoder)));
         }
-        let out = str::from_utf8(buf[]).unwrap();
+        let out = str::from_utf8(buf.index(&FullRange)).unwrap();
         let needs_wrapping = out.char_at(0) != '"' && out.char_at_reverse(out.len()) != '"';
         if needs_wrapping { try!(write!(self.writer, "\"")); }
         try!(f(self));
@@ -1028,7 +1027,7 @@ pub fn is_string<'a>(&'a self) -> bool {
     /// Returns None otherwise.
     pub fn as_string<'a>(&'a self) -> Option<&'a str> {
         match *self {
-            Json::String(ref s) => Some(s[]),
+            Json::String(ref s) => Some(s.index(&FullRange)),
             _ => None
         }
     }
@@ -1125,7 +1124,7 @@ pub fn as_null(&self) -> Option<()> {
     }
 }
 
-impl<'a> ops::Index<&'a str>  for Json {
+impl<'a> Index<&'a str>  for Json {
     type Output = Json;
 
     fn index(&self, idx: & &str) -> &Json {
@@ -1133,7 +1132,7 @@ fn index(&self, idx: & &str) -> &Json {
     }
 }
 
-impl ops::Index<uint> for Json {
+impl Index<uint> for Json {
     type Output = Json;
 
     fn index<'a>(&'a self, idx: &uint) -> &'a Json {
@@ -1187,7 +1186,8 @@ pub struct Stack {
 }
 
 /// StackElements compose a Stack.
-/// For example, Key("foo"), Key("bar"), Index(3) and Key("x") are the
+/// For example, StackElement::Key("foo"), StackElement::Key("bar"),
+/// StackElement::Index(3) and StackElement::Key("x") are the
 /// StackElements compositing the stack that represents foo.bar[3].x
 #[derive(PartialEq, Clone, Show)]
 pub enum StackElement<'l> {
@@ -1219,10 +1219,11 @@ pub fn is_empty(&self) -> bool { self.stack.is_empty() }
     /// at the top.
     pub fn get<'l>(&'l self, idx: uint) -> StackElement<'l> {
         match self.stack[idx] {
-            InternalIndex(i) => Index(i),
+            InternalIndex(i) => StackElement::Index(i),
             InternalKey(start, size) => {
-                Key(str::from_utf8(
-                    self.str_buffer[start as uint .. start as uint + size as uint]).unwrap())
+                StackElement::Key(str::from_utf8(
+                    self.str_buffer.index(&((start as uint) .. (start as uint + size as uint))))
+                        .unwrap())
             }
         }
     }
@@ -1261,16 +1262,16 @@ pub fn ends_with(&self, rhs: &[StackElement]) -> bool {
     pub fn top<'l>(&'l self) -> Option<StackElement<'l>> {
         return match self.stack.last() {
             None => None,
-            Some(&InternalIndex(i)) => Some(Index(i)),
+            Some(&InternalIndex(i)) => Some(StackElement::Index(i)),
             Some(&InternalKey(start, size)) => {
-                Some(Key(str::from_utf8(
-                    self.str_buffer[start as uint .. (start+size) as uint]
+                Some(StackElement::Key(str::from_utf8(
+                    self.str_buffer.index(&((start as uint) .. (start+size) as uint))
                 ).unwrap()))
             }
         }
     }
 
-    // Used by Parser to insert Key elements at the top of the stack.
+    // Used by Parser to insert StackElement::Key elements at the top of the stack.
     fn push_key(&mut self, key: string::String) {
         self.stack.push(InternalKey(self.str_buffer.len() as u16, key.len() as u16));
         for c in key.as_bytes().iter() {
@@ -1278,7 +1279,7 @@ fn push_key(&mut self, key: string::String) {
         }
     }
 
-    // Used by Parser to insert Index elements at the top of the stack.
+    // Used by Parser to insert StackElement::Index elements at the top of the stack.
     fn push_index(&mut self, index: u32) {
         self.stack.push(InternalIndex(index));
     }
@@ -1889,7 +1890,7 @@ pub fn build(&mut self) -> Result<Json, BuilderError> {
         match self.token {
             None => {}
             Some(Error(e)) => { return Err(e); }
-            ref tok => { panic!("unexpected token {}", tok.clone()); }
+            ref tok => { panic!("unexpected token {:?}", tok.clone()); }
         }
         result
     }
@@ -1948,7 +1949,7 @@ fn build_object(&mut self) -> Result<Json, BuilderError> {
                 _ => {}
             }
             let key = match self.parser.stack().top() {
-                Some(Key(k)) => { k.to_string() }
+                Some(StackElement::Key(k)) => { k.to_string() }
                 _ => { panic!("invalid state"); }
             };
             match self.build_value() {
@@ -2143,7 +2144,7 @@ fn read_enum_variant<T, F>(&mut self, names: &[&str],
                 return Err(ExpectedError("String or Object".to_string(), format!("{}", json)))
             }
         };
-        let idx = match names.iter().position(|n| *n == name[]) {
+        let idx = match names.iter().position(|n| *n == name.index(&FullRange)) {
             Some(idx) => idx,
             None => return Err(UnknownVariantError(name))
         };
@@ -2439,7 +2440,7 @@ fn write_str(&mut self, s: &str) -> fmt::Result {
     }
 }
 
-impl fmt::Show for Json {
+impl fmt::String for Json {
     /// Encodes a json value into a string
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let mut shim = FormatShim { inner: f };
@@ -2448,7 +2449,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-impl<'a> fmt::Show for PrettyJson<'a> {
+impl<'a> fmt::String for PrettyJson<'a> {
     /// Encodes a json value into a string
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let mut shim = FormatShim { inner: f };
@@ -2457,7 +2458,15 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+#[cfg(stage0)]
+//NOTE(stage0): remove impl after snapshot
 impl<'a, T: Encodable> fmt::Show for AsJson<'a, T> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a, T: Encodable> fmt::String for AsJson<'a, T> {
     /// Encodes a json value into a string
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let mut shim = FormatShim { inner: f };
@@ -2474,7 +2483,7 @@ pub fn indent(mut self, indent: uint) -> AsPrettyJson<'a, T> {
     }
 }
 
-impl<'a, T: Encodable> fmt::Show for AsPrettyJson<'a, T> {
+impl<'a, T: Encodable> fmt::String for AsPrettyJson<'a, T> {
     /// Encodes a json value into a string
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let mut shim = FormatShim { inner: f };
@@ -2505,12 +2514,12 @@ mod tests {
     use super::ParserError::*;
     use super::DecoderError::*;
     use super::JsonEvent::*;
-    use super::StackElement::*;
     use super::{Json, from_str, DecodeResult, DecoderError, JsonEvent, Parser,
                 StackElement, Stack, Decoder};
-    use std::{i64, u64, f32, f64};
+    use std::{i64, u64, f32, f64, io};
     use std::collections::BTreeMap;
     use std::num::Float;
+    use std::ops::Index;
     use std::string;
 
     #[derive(RustcDecodable, Eq, PartialEq, Show)]
@@ -2902,7 +2911,8 @@ fn test_decode_numbers() {
         assert_eq!(v, i64::MAX);
 
         let res: DecodeResult<i64> = super::decode("765.25252");
-        assert_eq!(res, Err(ExpectedError("Integer".to_string(), "765.25252".to_string())));
+        assert_eq!(res, Err(ExpectedError("Integer".to_string(),
+                                          "765.25252".to_string())));
     }
 
     #[test]
@@ -3140,9 +3150,9 @@ fn check_err<T: Decodable>(to_parse: &'static str, expected: DecoderError) {
             Ok(json) => Decodable::decode(&mut Decoder::new(json))
         };
         match res {
-            Ok(_) => panic!("`{}` parsed & decoded ok, expecting error `{}`",
+            Ok(_) => panic!("`{:?}` parsed & decoded ok, expecting error `{:?}`",
                               to_parse, expected),
-            Err(ParseError(e)) => panic!("`{}` is not valid json: {}",
+            Err(ParseError(e)) => panic!("`{:?}` is not valid json: {:?}",
                                            to_parse, e),
             Err(e) => {
                 assert_eq!(e, expected);
@@ -3351,9 +3361,9 @@ fn test_encode_hashmap_with_numeric_key() {
         hm.insert(1, true);
         let mut mem_buf = Vec::new();
         write!(&mut mem_buf, "{}", super::as_pretty_json(&hm)).unwrap();
-        let json_str = from_utf8(mem_buf[]).unwrap();
+        let json_str = from_utf8(mem_buf.index(&FullRange)).unwrap();
         match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
+            Err(_) => panic!("Unable to parse json_str: {:?}", json_str),
             _ => {} // it parsed and we are good to go
         }
     }
@@ -3367,9 +3377,9 @@ fn test_prettyencode_hashmap_with_numeric_key() {
         hm.insert(1, true);
         let mut mem_buf = Vec::new();
         write!(&mut mem_buf, "{}", super::as_pretty_json(&hm)).unwrap();
-        let json_str = from_utf8(mem_buf[]).unwrap();
+        let json_str = from_utf8(mem_buf.index(&FullRange)).unwrap();
         match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
+            Err(_) => panic!("Unable to parse json_str: {:?}", json_str),
             _ => {} // it parsed and we are good to go
         }
     }
@@ -3407,7 +3417,7 @@ fn indents(source: &str) -> uint {
             write!(&mut writer, "{}",
                    super::as_pretty_json(&json).indent(i)).unwrap();
 
-            let printed = from_utf8(writer[]).unwrap();
+            let printed = from_utf8(writer.index(&FullRange)).unwrap();
 
             // Check for indents at each line
             let lines: Vec<&str> = printed.lines().collect();
@@ -3432,7 +3442,7 @@ fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() {
         use Decodable;
         let json_str = "{\"1\":true}";
         let json_obj = match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
+            Err(_) => panic!("Unable to parse json_str: {:?}", json_str),
             Ok(o) => o
         };
         let mut decoder = Decoder::new(json_obj);
@@ -3445,7 +3455,7 @@ fn test_hashmap_with_numeric_key_will_error_with_string_keys() {
         use Decodable;
         let json_str = "{\"a\":true}";
         let json_obj = match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
+            Err(_) => panic!("Unable to parse json_str: {:?}", json_str),
             Ok(o) => o
         };
         let mut decoder = Decoder::new(json_obj);
@@ -3464,7 +3474,7 @@ fn assert_stream_equal(src: &str,
             };
             let (ref expected_evt, ref expected_stack) = expected[i];
             if !parser.stack().is_equal_to(expected_stack.as_slice()) {
-                panic!("Parser stack is not equal to {}", expected_stack);
+                panic!("Parser stack is not equal to {:?}", expected_stack);
             }
             assert_eq!(&evt, expected_evt);
             i+=1;
@@ -3477,20 +3487,23 @@ fn test_streaming_parser() {
             r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#,
             vec![
                 (ObjectStart,             vec![]),
-                  (StringValue("bar".to_string()),   vec![Key("foo")]),
-                  (ArrayStart,            vec![Key("array")]),
-                    (U64Value(0),         vec![Key("array"), Index(0)]),
-                    (U64Value(1),         vec![Key("array"), Index(1)]),
-                    (U64Value(2),         vec![Key("array"), Index(2)]),
-                    (U64Value(3),         vec![Key("array"), Index(3)]),
-                    (U64Value(4),         vec![Key("array"), Index(4)]),
-                    (U64Value(5),         vec![Key("array"), Index(5)]),
-                  (ArrayEnd,              vec![Key("array")]),
-                  (ArrayStart,            vec![Key("idents")]),
-                    (NullValue,           vec![Key("idents"), Index(0)]),
-                    (BooleanValue(true),  vec![Key("idents"), Index(1)]),
-                    (BooleanValue(false), vec![Key("idents"), Index(2)]),
-                  (ArrayEnd,              vec![Key("idents")]),
+                  (StringValue("bar".to_string()),   vec![StackElement::Key("foo")]),
+                  (ArrayStart,            vec![StackElement::Key("array")]),
+                    (U64Value(0),         vec![StackElement::Key("array"), StackElement::Index(0)]),
+                    (U64Value(1),         vec![StackElement::Key("array"), StackElement::Index(1)]),
+                    (U64Value(2),         vec![StackElement::Key("array"), StackElement::Index(2)]),
+                    (U64Value(3),         vec![StackElement::Key("array"), StackElement::Index(3)]),
+                    (U64Value(4),         vec![StackElement::Key("array"), StackElement::Index(4)]),
+                    (U64Value(5),         vec![StackElement::Key("array"), StackElement::Index(5)]),
+                  (ArrayEnd,              vec![StackElement::Key("array")]),
+                  (ArrayStart,            vec![StackElement::Key("idents")]),
+                    (NullValue,           vec![StackElement::Key("idents"),
+                                               StackElement::Index(0)]),
+                    (BooleanValue(true),  vec![StackElement::Key("idents"),
+                                               StackElement::Index(1)]),
+                    (BooleanValue(false), vec![StackElement::Key("idents"),
+                                               StackElement::Index(2)]),
+                  (ArrayEnd,              vec![StackElement::Key("idents")]),
                 (ObjectEnd,               vec![]),
             ]
         );
@@ -3530,7 +3543,7 @@ fn test_read_object_streaming() {
             "{\"a\": 3}",
             vec![
                 (ObjectStart,        vec![]),
-                  (U64Value(3),      vec![Key("a")]),
+                  (U64Value(3),      vec![StackElement::Key("a")]),
                 (ObjectEnd,          vec![]),
             ]
         );
@@ -3538,8 +3551,8 @@ fn test_read_object_streaming() {
             "{ \"a\": null, \"b\" : true }",
             vec![
                 (ObjectStart,           vec![]),
-                  (NullValue,           vec![Key("a")]),
-                  (BooleanValue(true),  vec![Key("b")]),
+                  (NullValue,           vec![StackElement::Key("a")]),
+                  (BooleanValue(true),  vec![StackElement::Key("b")]),
                 (ObjectEnd,             vec![]),
             ]
         );
@@ -3547,10 +3560,10 @@ fn test_read_object_streaming() {
             "{\"a\" : 1.0 ,\"b\": [ true ]}",
             vec![
                 (ObjectStart,           vec![]),
-                  (F64Value(1.0),       vec![Key("a")]),
-                  (ArrayStart,          vec![Key("b")]),
-                    (BooleanValue(true),vec![Key("b"), Index(0)]),
-                  (ArrayEnd,            vec![Key("b")]),
+                  (F64Value(1.0),       vec![StackElement::Key("a")]),
+                  (ArrayStart,          vec![StackElement::Key("b")]),
+                    (BooleanValue(true),vec![StackElement::Key("b"), StackElement::Index(0)]),
+                  (ArrayEnd,            vec![StackElement::Key("b")]),
                 (ObjectEnd,             vec![]),
             ]
         );
@@ -3565,16 +3578,27 @@ fn test_read_object_streaming() {
             }"#,
             vec![
                 (ObjectStart,                   vec![]),
-                  (F64Value(1.0),               vec![Key("a")]),
-                  (ArrayStart,                  vec![Key("b")]),
-                    (BooleanValue(true),        vec![Key("b"), Index(0)]),
-                    (StringValue("foo\nbar".to_string()),  vec![Key("b"), Index(1)]),
-                    (ObjectStart,               vec![Key("b"), Index(2)]),
-                      (ObjectStart,             vec![Key("b"), Index(2), Key("c")]),
-                        (NullValue,             vec![Key("b"), Index(2), Key("c"), Key("d")]),
-                      (ObjectEnd,               vec![Key("b"), Index(2), Key("c")]),
-                    (ObjectEnd,                 vec![Key("b"), Index(2)]),
-                  (ArrayEnd,                    vec![Key("b")]),
+                  (F64Value(1.0),               vec![StackElement::Key("a")]),
+                  (ArrayStart,                  vec![StackElement::Key("b")]),
+                    (BooleanValue(true),        vec![StackElement::Key("b"),
+                                                     StackElement::Index(0)]),
+                    (StringValue("foo\nbar".to_string()),  vec![StackElement::Key("b"),
+                                                                StackElement::Index(1)]),
+                    (ObjectStart,               vec![StackElement::Key("b"),
+                                                     StackElement::Index(2)]),
+                      (ObjectStart,             vec![StackElement::Key("b"),
+                                                     StackElement::Index(2),
+                                                     StackElement::Key("c")]),
+                        (NullValue,             vec![StackElement::Key("b"),
+                                                     StackElement::Index(2),
+                                                     StackElement::Key("c"),
+                                                     StackElement::Key("d")]),
+                      (ObjectEnd,               vec![StackElement::Key("b"),
+                                                     StackElement::Index(2),
+                                                     StackElement::Key("c")]),
+                    (ObjectEnd,                 vec![StackElement::Key("b"),
+                                                     StackElement::Index(2)]),
+                  (ArrayEnd,                    vec![StackElement::Key("b")]),
                 (ObjectEnd,                     vec![]),
             ]
         );
@@ -3600,7 +3624,7 @@ fn test_read_array_streaming() {
             "[true]",
             vec![
                 (ArrayStart,             vec![]),
-                    (BooleanValue(true), vec![Index(0)]),
+                    (BooleanValue(true), vec![StackElement::Index(0)]),
                 (ArrayEnd,               vec![]),
             ]
         );
@@ -3608,7 +3632,7 @@ fn test_read_array_streaming() {
             "[ false ]",
             vec![
                 (ArrayStart,              vec![]),
-                    (BooleanValue(false), vec![Index(0)]),
+                    (BooleanValue(false), vec![StackElement::Index(0)]),
                 (ArrayEnd,                vec![]),
             ]
         );
@@ -3616,7 +3640,7 @@ fn test_read_array_streaming() {
             "[null]",
             vec![
                 (ArrayStart,    vec![]),
-                    (NullValue, vec![Index(0)]),
+                    (NullValue, vec![StackElement::Index(0)]),
                 (ArrayEnd,      vec![]),
             ]
         );
@@ -3624,8 +3648,8 @@ fn test_read_array_streaming() {
             "[3, 1]",
             vec![
                 (ArrayStart,      vec![]),
-                    (U64Value(3), vec![Index(0)]),
-                    (U64Value(1), vec![Index(1)]),
+                    (U64Value(3), vec![StackElement::Index(0)]),
+                    (U64Value(1), vec![StackElement::Index(1)]),
                 (ArrayEnd,        vec![]),
             ]
         );
@@ -3633,8 +3657,8 @@ fn test_read_array_streaming() {
             "\n[3, 2]\n",
             vec![
                 (ArrayStart,      vec![]),
-                    (U64Value(3), vec![Index(0)]),
-                    (U64Value(2), vec![Index(1)]),
+                    (U64Value(3), vec![StackElement::Index(0)]),
+                    (U64Value(2), vec![StackElement::Index(1)]),
                 (ArrayEnd,        vec![]),
             ]
         );
@@ -3642,11 +3666,11 @@ fn test_read_array_streaming() {
             "[2, [4, 1]]",
             vec![
                 (ArrayStart,           vec![]),
-                    (U64Value(2),      vec![Index(0)]),
-                    (ArrayStart,       vec![Index(1)]),
-                        (U64Value(4),  vec![Index(1), Index(0)]),
-                        (U64Value(1),  vec![Index(1), Index(1)]),
-                    (ArrayEnd,         vec![Index(1)]),
+                    (U64Value(2),      vec![StackElement::Index(0)]),
+                    (ArrayStart,       vec![StackElement::Index(1)]),
+                        (U64Value(4),  vec![StackElement::Index(1), StackElement::Index(0)]),
+                        (U64Value(1),  vec![StackElement::Index(1), StackElement::Index(1)]),
+                    (ArrayEnd,         vec![StackElement::Index(1)]),
                 (ArrayEnd,             vec![]),
             ]
         );
@@ -3695,50 +3719,56 @@ fn test_stack() {
         stack.bump_index();
 
         assert!(stack.len() == 1);
-        assert!(stack.is_equal_to(&[Index(1)]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.ends_with(&[Index(1)]));
+        assert!(stack.is_equal_to(&[StackElement::Index(1)]));
+        assert!(stack.starts_with(&[StackElement::Index(1)]));
+        assert!(stack.ends_with(&[StackElement::Index(1)]));
         assert!(stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
+        assert!(stack.get(0) == StackElement::Index(1));
 
         stack.push_key("foo".to_string());
 
         assert!(stack.len() == 2);
-        assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.ends_with(&[Index(1), Key("foo")]));
-        assert!(stack.ends_with(&[Key("foo")]));
+        assert!(stack.is_equal_to(&[StackElement::Index(1), StackElement::Key("foo")]));
+        assert!(stack.starts_with(&[StackElement::Index(1), StackElement::Key("foo")]));
+        assert!(stack.starts_with(&[StackElement::Index(1)]));
+        assert!(stack.ends_with(&[StackElement::Index(1), StackElement::Key("foo")]));
+        assert!(stack.ends_with(&[StackElement::Key("foo")]));
         assert!(!stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
-        assert!(stack.get(1) == Key("foo"));
+        assert!(stack.get(0) == StackElement::Index(1));
+        assert!(stack.get(1) == StackElement::Key("foo"));
 
         stack.push_key("bar".to_string());
 
         assert!(stack.len() == 3);
-        assert!(stack.is_equal_to(&[Index(1), Key("foo"), Key("bar")]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.starts_with(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1), Key("foo"), Key("bar")]));
-        assert!(stack.ends_with(&[Key("bar")]));
-        assert!(stack.ends_with(&[Key("foo"), Key("bar")]));
-        assert!(stack.ends_with(&[Index(1), Key("foo"), Key("bar")]));
+        assert!(stack.is_equal_to(&[StackElement::Index(1),
+                                    StackElement::Key("foo"),
+                                    StackElement::Key("bar")]));
+        assert!(stack.starts_with(&[StackElement::Index(1)]));
+        assert!(stack.starts_with(&[StackElement::Index(1), StackElement::Key("foo")]));
+        assert!(stack.starts_with(&[StackElement::Index(1),
+                                    StackElement::Key("foo"),
+                                    StackElement::Key("bar")]));
+        assert!(stack.ends_with(&[StackElement::Key("bar")]));
+        assert!(stack.ends_with(&[StackElement::Key("foo"), StackElement::Key("bar")]));
+        assert!(stack.ends_with(&[StackElement::Index(1),
+                                  StackElement::Key("foo"),
+                                  StackElement::Key("bar")]));
         assert!(!stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
-        assert!(stack.get(1) == Key("foo"));
-        assert!(stack.get(2) == Key("bar"));
+        assert!(stack.get(0) == StackElement::Index(1));
+        assert!(stack.get(1) == StackElement::Key("foo"));
+        assert!(stack.get(2) == StackElement::Key("bar"));
 
         stack.pop();
 
         assert!(stack.len() == 2);
-        assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.ends_with(&[Index(1), Key("foo")]));
-        assert!(stack.ends_with(&[Key("foo")]));
+        assert!(stack.is_equal_to(&[StackElement::Index(1), StackElement::Key("foo")]));
+        assert!(stack.starts_with(&[StackElement::Index(1), StackElement::Key("foo")]));
+        assert!(stack.starts_with(&[StackElement::Index(1)]));
+        assert!(stack.ends_with(&[StackElement::Index(1), StackElement::Key("foo")]));
+        assert!(stack.ends_with(&[StackElement::Key("foo")]));
         assert!(!stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
-        assert!(stack.get(1) == Key("foo"));
+        assert!(stack.get(0) == StackElement::Index(1));
+        assert!(stack.get(1) == StackElement::Key("foo"));
     }
 
     #[test]
diff --git a/src/libserialize/json_stage0.rs b/src/libserialize/json_stage0.rs
deleted file mode 100644 (file)
index a157d91..0000000
+++ /dev/null
@@ -1,3862 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// Rust JSON serialization library
-// Copyright (c) 2011 Google Inc.
-
-#![forbid(non_camel_case_types)]
-#![allow(missing_docs)]
-
-//! JSON parsing and serialization
-//!
-//! # What is JSON?
-//!
-//! JSON (JavaScript Object Notation) is a way to write data in Javascript.
-//! Like XML, it allows to encode structured data in a text format that can be easily read by humans
-//! Its simple syntax and native compatibility with JavaScript have made it a widely used format.
-//!
-//! Data types that can be encoded are JavaScript types (see the `Json` enum for more details):
-//!
-//! * `Boolean`: equivalent to rust's `bool`
-//! * `Number`: equivalent to rust's `f64`
-//! * `String`: equivalent to rust's `String`
-//! * `Array`: equivalent to rust's `Vec<T>`, but also allowing objects of different types in the
-//!   same array
-//! * `Object`: equivalent to rust's `BTreeMap<String, json::Json>`
-//! * `Null`
-//!
-//! An object is a series of string keys mapping to values, in `"key": value` format.
-//! Arrays are enclosed in square brackets ([ ... ]) and objects in curly brackets ({ ... }).
-//! A simple JSON document encoding a person, his/her age, address and phone numbers could look like
-//!
-//! ```ignore
-//! {
-//!     "FirstName": "John",
-//!     "LastName": "Doe",
-//!     "Age": 43,
-//!     "Address": {
-//!         "Street": "Downing Street 10",
-//!         "City": "London",
-//!         "Country": "Great Britain"
-//!     },
-//!     "PhoneNumbers": [
-//!         "+44 1234567",
-//!         "+44 2345678"
-//!     ]
-//! }
-//! ```
-//!
-//! # Rust Type-based Encoding and Decoding
-//!
-//! Rust provides a mechanism for low boilerplate encoding & decoding of values to and from JSON via
-//! the serialization API.
-//! To be able to encode a piece of data, it must implement the `serialize::RustcEncodable` trait.
-//! To be able to decode a piece of data, it must implement the `serialize::RustcDecodable` trait.
-//! The Rust compiler provides an annotation to automatically generate the code for these traits:
-//! `#[derive(RustcDecodable, RustcEncodable)]`
-//!
-//! The JSON API provides an enum `json::Json` and a trait `ToJson` to encode objects.
-//! The `ToJson` trait provides a `to_json` method to convert an object into a `json::Json` value.
-//! A `json::Json` value can be encoded as a string or buffer using the functions described above.
-//! You can also use the `json::Encoder` object, which implements the `Encoder` trait.
-//!
-//! When using `ToJson` the `RustcEncodable` trait implementation is not mandatory.
-//!
-//! # Examples of use
-//!
-//! ## Using Autoserialization
-//!
-//! Create a struct called `TestStruct` and serialize and deserialize it to and from JSON using the
-//! serialization API, using the derived serialization code.
-//!
-//! ```notrust
-//! // FIXME(#19470): this cannot be ```rust``` because it fails orphan checking at the moment
-//! extern crate serialize;
-//! use serialize::json;
-//!
-//! // Automatically generate `Decodable` and `Encodable` trait implementations
-//! #[derive(RustcDecodable, RustcEncodable)]
-//! pub struct TestStruct  {
-//!     data_int: u8,
-//!     data_str: String,
-//!     data_vector: Vec<u8>,
-//! }
-//!
-//! fn main() {
-//!     let object = TestStruct {
-//!         data_int: 1,
-//!         data_str: "homura".to_string(),
-//!         data_vector: vec![2,3,4,5],
-//!     };
-//!
-//!     // Serialize using `json::encode`
-//!     let encoded = json::encode(&object);
-//!
-//!     // Deserialize using `json::decode`
-//!     let decoded: TestStruct = json::decode(encoded.as_slice()).unwrap();
-//! }
-//! ```
-//!
-//! ## Using the `ToJson` trait
-//!
-//! The examples above use the `ToJson` trait to generate the JSON string, which is required
-//! for custom mappings.
-//!
-//! ### Simple example of `ToJson` usage
-//!
-//! ```notrust
-//! // FIXME(#19470): this cannot be ```rust``` because it fails orphan checking at the moment
-//! extern crate serialize;
-//! use serialize::json::{mod, ToJson, Json};
-//!
-//! // A custom data structure
-//! struct ComplexNum {
-//!     a: f64,
-//!     b: f64,
-//! }
-//!
-//! // JSON value representation
-//! impl ToJson for ComplexNum {
-//!     fn to_json(&self) -> Json {
-//!         Json::String(format!("{}+{}i", self.a, self.b))
-//!     }
-//! }
-//!
-//! // Only generate `RustcEncodable` trait implementation
-//! #[derive(Encodable)]
-//! pub struct ComplexNumRecord {
-//!     uid: u8,
-//!     dsc: String,
-//!     val: Json,
-//! }
-//!
-//! fn main() {
-//!     let num = ComplexNum { a: 0.0001, b: 12.539 };
-//!     let data: String = json::encode(&ComplexNumRecord{
-//!         uid: 1,
-//!         dsc: "test".to_string(),
-//!         val: num.to_json(),
-//!     });
-//!     println!("data: {}", data);
-//!     // data: {"uid":1,"dsc":"test","val":"0.0001+12.539j"};
-//! }
-//! ```
-//!
-//! ### Verbose example of `ToJson` usage
-//!
-//! ```notrust
-//! // FIXME(#19470): this cannot be ```rust``` because it fails orphan checking at the moment
-//! extern crate serialize;
-//! use std::collections::BTreeMap;
-//! use serialize::json::{mod, Json, ToJson};
-//!
-//! // Only generate `Decodable` trait implementation
-//! #[derive(Decodable)]
-//! pub struct TestStruct {
-//!     data_int: u8,
-//!     data_str: String,
-//!     data_vector: Vec<u8>,
-//! }
-//!
-//! // Specify encoding method manually
-//! impl ToJson for TestStruct {
-//!     fn to_json(&self) -> Json {
-//!         let mut d = BTreeMap::new();
-//!         // All standard types implement `to_json()`, so use it
-//!         d.insert("data_int".to_string(), self.data_int.to_json());
-//!         d.insert("data_str".to_string(), self.data_str.to_json());
-//!         d.insert("data_vector".to_string(), self.data_vector.to_json());
-//!         Json::Object(d)
-//!     }
-//! }
-//!
-//! fn main() {
-//!     // Serialize using `ToJson`
-//!     let input_data = TestStruct {
-//!         data_int: 1,
-//!         data_str: "madoka".to_string(),
-//!         data_vector: vec![2,3,4,5],
-//!     };
-//!     let json_obj: Json = input_data.to_json();
-//!     let json_str: String = json_obj.to_string();
-//!
-//!     // Deserialize like before
-//!     let decoded: TestStruct = json::decode(json_str.as_slice()).unwrap();
-//! }
-//! ```
-
-use self::JsonEvent::*;
-use self::StackElement::*;
-use self::ErrorCode::*;
-use self::ParserError::*;
-use self::DecoderError::*;
-use self::ParserState::*;
-use self::InternalStackElement::*;
-
-use std;
-use std::collections::{HashMap, BTreeMap};
-use std::{char, f64, fmt, io, num, str};
-use std::mem::{swap, transmute};
-use std::num::{Float, Int};
-use std::num::FpCategory as Fp;
-use std::str::FromStr;
-use std::string;
-use std::ops;
-use unicode::str as unicode_str;
-use unicode::str::Utf16Item;
-
-use Encodable;
-
-/// Represents a json value
-#[derive(Clone, PartialEq, PartialOrd)]
-pub enum Json {
-    I64(i64),
-    U64(u64),
-    F64(f64),
-    String(string::String),
-    Boolean(bool),
-    Array(self::Array),
-    Object(self::Object),
-    Null,
-}
-
-pub type Array = Vec<Json>;
-pub type Object = BTreeMap<string::String, Json>;
-
-pub struct PrettyJson<'a> { inner: &'a Json }
-
-pub struct AsJson<'a, T: 'a> { inner: &'a T }
-pub struct AsPrettyJson<'a, T: 'a> { inner: &'a T, indent: Option<uint> }
-
-/// The errors that can arise while parsing a JSON stream.
-#[derive(Clone, Copy, PartialEq)]
-pub enum ErrorCode {
-    InvalidSyntax,
-    InvalidNumber,
-    EOFWhileParsingObject,
-    EOFWhileParsingArray,
-    EOFWhileParsingValue,
-    EOFWhileParsingString,
-    KeyMustBeAString,
-    ExpectedColon,
-    TrailingCharacters,
-    TrailingComma,
-    InvalidEscape,
-    InvalidUnicodeCodePoint,
-    LoneLeadingSurrogateInHexEscape,
-    UnexpectedEndOfHexEscape,
-    UnrecognizedHex,
-    NotFourDigit,
-    NotUtf8,
-}
-
-#[derive(Clone, Copy, PartialEq, Show)]
-pub enum ParserError {
-    /// msg, line, col
-    SyntaxError(ErrorCode, uint, uint),
-    IoError(io::IoErrorKind, &'static str),
-}
-
-// Builder and Parser have the same errors.
-pub type BuilderError = ParserError;
-
-#[derive(Clone, PartialEq, Show)]
-pub enum DecoderError {
-    ParseError(ParserError),
-    ExpectedError(string::String, string::String),
-    MissingFieldError(string::String),
-    UnknownVariantError(string::String),
-    ApplicationError(string::String)
-}
-
-/// Returns a readable error string for a given error code.
-pub fn error_str(error: ErrorCode) -> &'static str {
-    match error {
-        InvalidSyntax => "invalid syntax",
-        InvalidNumber => "invalid number",
-        EOFWhileParsingObject => "EOF While parsing object",
-        EOFWhileParsingArray => "EOF While parsing array",
-        EOFWhileParsingValue => "EOF While parsing value",
-        EOFWhileParsingString => "EOF While parsing string",
-        KeyMustBeAString => "key must be a string",
-        ExpectedColon => "expected `:`",
-        TrailingCharacters => "trailing characters",
-        TrailingComma => "trailing comma",
-        InvalidEscape => "invalid escape",
-        UnrecognizedHex => "invalid \\u{ esc}ape (unrecognized hex)",
-        NotFourDigit => "invalid \\u{ esc}ape (not four digits)",
-        NotUtf8 => "contents not utf-8",
-        InvalidUnicodeCodePoint => "invalid Unicode code point",
-        LoneLeadingSurrogateInHexEscape => "lone leading surrogate in hex escape",
-        UnexpectedEndOfHexEscape => "unexpected end of hex escape",
-    }
-}
-
-/// Shortcut function to decode a JSON `&str` into an object
-pub fn decode<T: ::Decodable<Decoder, DecoderError>>(s: &str) -> DecodeResult<T> {
-    let json = match from_str(s) {
-        Ok(x) => x,
-        Err(e) => return Err(ParseError(e))
-    };
-
-    let mut decoder = Decoder::new(json);
-    ::Decodable::decode(&mut decoder)
-}
-
-/// Shortcut function to encode a `T` into a JSON `String`
-pub fn encode<T>(object: &T) -> string::String
-                 where T: for<'a> Encodable<Encoder<'a>, fmt::Error>
-{
-    let mut s = String::new();
-    {
-        let mut encoder = Encoder::new(&mut s);
-        let _ = object.encode(&mut encoder);
-    }
-    s
-}
-
-impl fmt::Show for ErrorCode {
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        error_str(*self).fmt(f)
-    }
-}
-
-fn io_error_to_error(io: io::IoError) -> ParserError {
-    IoError(io.kind, io.desc)
-}
-
-impl std::error::Error for DecoderError {
-    fn description(&self) -> &str { "decoder error" }
-    fn detail(&self) -> Option<std::string::String> { Some(self.to_string()) }
-}
-
-pub type EncodeResult = fmt::Result;
-pub type DecodeResult<T> = Result<T, DecoderError>;
-
-fn escape_str(wr: &mut fmt::Writer, v: &str) -> fmt::Result {
-    try!(wr.write_str("\""));
-
-    let mut start = 0;
-
-    for (i, byte) in v.bytes().enumerate() {
-        let escaped = match byte {
-            b'"' => "\\\"",
-            b'\\' => "\\\\",
-            b'\x00' => "\\u0000",
-            b'\x01' => "\\u0001",
-            b'\x02' => "\\u0002",
-            b'\x03' => "\\u0003",
-            b'\x04' => "\\u0004",
-            b'\x05' => "\\u0005",
-            b'\x06' => "\\u0006",
-            b'\x07' => "\\u0007",
-            b'\x08' => "\\b",
-            b'\t' => "\\t",
-            b'\n' => "\\n",
-            b'\x0b' => "\\u000b",
-            b'\x0c' => "\\f",
-            b'\r' => "\\r",
-            b'\x0e' => "\\u000e",
-            b'\x0f' => "\\u000f",
-            b'\x10' => "\\u0010",
-            b'\x11' => "\\u0011",
-            b'\x12' => "\\u0012",
-            b'\x13' => "\\u0013",
-            b'\x14' => "\\u0014",
-            b'\x15' => "\\u0015",
-            b'\x16' => "\\u0016",
-            b'\x17' => "\\u0017",
-            b'\x18' => "\\u0018",
-            b'\x19' => "\\u0019",
-            b'\x1a' => "\\u001a",
-            b'\x1b' => "\\u001b",
-            b'\x1c' => "\\u001c",
-            b'\x1d' => "\\u001d",
-            b'\x1e' => "\\u001e",
-            b'\x1f' => "\\u001f",
-            b'\x7f' => "\\u007f",
-            _ => { continue; }
-        };
-
-        if start < i {
-            try!(wr.write_str(v[start..i]));
-        }
-
-        try!(wr.write_str(escaped));
-
-        start = i + 1;
-    }
-
-    if start != v.len() {
-        try!(wr.write_str(v[start..]));
-    }
-
-    wr.write_str("\"")
-}
-
-fn escape_char(writer: &mut fmt::Writer, v: char) -> fmt::Result {
-    let mut buf = [0; 4];
-    let n = v.encode_utf8(&mut buf).unwrap();
-    let buf = unsafe { str::from_utf8_unchecked(buf[0..n]) };
-    escape_str(writer, buf)
-}
-
-fn spaces(wr: &mut fmt::Writer, mut n: uint) -> fmt::Result {
-    const BUF: &'static str = "                ";
-
-    while n >= BUF.len() {
-        try!(wr.write_str(BUF));
-        n -= BUF.len();
-    }
-
-    if n > 0 {
-        wr.write_str(BUF[..n])
-    } else {
-        Ok(())
-    }
-}
-
-fn fmt_number_or_null(v: f64) -> string::String {
-    match v.classify() {
-        Fp::Nan | Fp::Infinite => string::String::from_str("null"),
-        _ if v.fract() != 0f64 => f64::to_str_digits(v, 6u),
-        _ => f64::to_str_digits(v, 6u) + ".0",
-    }
-}
-
-/// A structure for implementing serialization to JSON.
-pub struct Encoder<'a> {
-    writer: &'a mut (fmt::Writer+'a),
-}
-
-impl<'a> Encoder<'a> {
-    /// Creates a new JSON encoder whose output will be written to the writer
-    /// specified.
-    pub fn new(writer: &'a mut fmt::Writer) -> Encoder<'a> {
-        Encoder { writer: writer }
-    }
-}
-
-impl<'a> ::Encoder<fmt::Error> for Encoder<'a> {
-    fn emit_nil(&mut self) -> EncodeResult { write!(self.writer, "null") }
-
-    fn emit_uint(&mut self, v: uint) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u64(&mut self, v: u64) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u32(&mut self, v: u32) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u16(&mut self, v: u16) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u8(&mut self, v: u8) -> EncodeResult { write!(self.writer, "{}", v) }
-
-    fn emit_int(&mut self, v: int) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i64(&mut self, v: i64) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i32(&mut self, v: i32) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i16(&mut self, v: i16) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i8(&mut self, v: i8) -> EncodeResult { write!(self.writer, "{}", v) }
-
-    fn emit_bool(&mut self, v: bool) -> EncodeResult {
-        if v {
-            write!(self.writer, "true")
-        } else {
-            write!(self.writer, "false")
-        }
-    }
-
-    fn emit_f64(&mut self, v: f64) -> EncodeResult {
-        write!(self.writer, "{}", fmt_number_or_null(v))
-    }
-    fn emit_f32(&mut self, v: f32) -> EncodeResult {
-        self.emit_f64(v as f64)
-    }
-
-    fn emit_char(&mut self, v: char) -> EncodeResult {
-        escape_char(self.writer, v)
-    }
-    fn emit_str(&mut self, v: &str) -> EncodeResult {
-        escape_str(self.writer, v)
-    }
-
-    fn emit_enum<F>(&mut self, _name: &str, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        f(self)
-    }
-
-    fn emit_enum_variant<F>(&mut self,
-                            name: &str,
-                            _id: uint,
-                            cnt: uint,
-                            f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        // enums are encoded as strings or objects
-        // Bunny => "Bunny"
-        // Kangaroo(34,"William") => {"variant": "Kangaroo", "fields": [34,"William"]}
-        if cnt == 0 {
-            escape_str(self.writer, name)
-        } else {
-            try!(write!(self.writer, "{{\"variant\":"));
-            try!(escape_str(self.writer, name));
-            try!(write!(self.writer, ",\"fields\":["));
-            try!(f(self));
-            write!(self.writer, "]}}")
-        }
-    }
-
-    fn emit_enum_variant_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        if idx != 0 {
-            try!(write!(self.writer, ","));
-        }
-        f(self)
-    }
-
-    fn emit_enum_struct_variant<F>(&mut self,
-                                   name: &str,
-                                   id: uint,
-                                   cnt: uint,
-                                   f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        self.emit_enum_variant(name, id, cnt, f)
-    }
-
-    fn emit_enum_struct_variant_field<F>(&mut self,
-                                         _: &str,
-                                         idx: uint,
-                                         f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        self.emit_enum_variant_arg(idx, f)
-    }
-
-    fn emit_struct<F>(&mut self, _: &str, _: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        try!(write!(self.writer, "{{"));
-        try!(f(self));
-        write!(self.writer, "}}")
-    }
-
-    fn emit_struct_field<F>(&mut self, name: &str, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        if idx != 0 { try!(write!(self.writer, ",")); }
-        try!(escape_str(self.writer, name));
-        try!(write!(self.writer, ":"));
-        f(self)
-    }
-
-    fn emit_tuple<F>(&mut self, len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq(len, f)
-    }
-    fn emit_tuple_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq_elt(idx, f)
-    }
-
-    fn emit_tuple_struct<F>(&mut self, _name: &str, len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq(len, f)
-    }
-    fn emit_tuple_struct_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq_elt(idx, f)
-    }
-
-    fn emit_option<F>(&mut self, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        f(self)
-    }
-    fn emit_option_none(&mut self) -> EncodeResult { self.emit_nil() }
-    fn emit_option_some<F>(&mut self, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        f(self)
-    }
-
-    fn emit_seq<F>(&mut self, _len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        try!(write!(self.writer, "["));
-        try!(f(self));
-        write!(self.writer, "]")
-    }
-
-    fn emit_seq_elt<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        if idx != 0 {
-            try!(write!(self.writer, ","));
-        }
-        f(self)
-    }
-
-    fn emit_map<F>(&mut self, _len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        try!(write!(self.writer, "{{"));
-        try!(f(self));
-        write!(self.writer, "}}")
-    }
-
-    fn emit_map_elt_key<F>(&mut self, idx: uint, mut f: F) -> EncodeResult where
-        F: FnMut(&mut Encoder<'a>) -> EncodeResult,
-    {
-        if idx != 0 { try!(write!(self.writer, ",")) }
-        // ref #12967, make sure to wrap a key in double quotes,
-        // in the event that its of a type that omits them (eg numbers)
-        let mut buf = Vec::new();
-        // FIXME(14302) remove the transmute and unsafe block.
-        unsafe {
-            let mut check_encoder = Encoder::new(&mut buf);
-            try!(f(transmute(&mut check_encoder)));
-        }
-        let out = str::from_utf8(buf[]).unwrap();
-        let needs_wrapping = out.char_at(0) != '"' && out.char_at_reverse(out.len()) != '"';
-        if needs_wrapping { try!(write!(self.writer, "\"")); }
-        try!(f(self));
-        if needs_wrapping { try!(write!(self.writer, "\"")); }
-        Ok(())
-    }
-
-    fn emit_map_elt_val<F>(&mut self, _idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut Encoder<'a>) -> EncodeResult,
-    {
-        try!(write!(self.writer, ":"));
-        f(self)
-    }
-}
-
-/// Another encoder for JSON, but prints out human-readable JSON instead of
-/// compact data
-pub struct PrettyEncoder<'a> {
-    writer: &'a mut (fmt::Writer+'a),
-    curr_indent: uint,
-    indent: uint,
-}
-
-impl<'a> PrettyEncoder<'a> {
-    /// Creates a new encoder whose output will be written to the specified writer
-    pub fn new(writer: &'a mut fmt::Writer) -> PrettyEncoder<'a> {
-        PrettyEncoder { writer: writer, curr_indent: 0, indent: 2, }
-    }
-
-    /// Set the number of spaces to indent for each level.
-    /// This is safe to set during encoding.
-    pub fn set_indent(&mut self, indent: uint) {
-        // self.indent very well could be 0 so we need to use checked division.
-        let level = self.curr_indent.checked_div(self.indent).unwrap_or(0);
-        self.indent = indent;
-        self.curr_indent = level * self.indent;
-    }
-}
-
-impl<'a> ::Encoder<fmt::Error> for PrettyEncoder<'a> {
-    fn emit_nil(&mut self) -> EncodeResult { write!(self.writer, "null") }
-
-    fn emit_uint(&mut self, v: uint) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u64(&mut self, v: u64) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u32(&mut self, v: u32) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u16(&mut self, v: u16) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_u8(&mut self, v: u8) -> EncodeResult { write!(self.writer, "{}", v) }
-
-    fn emit_int(&mut self, v: int) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i64(&mut self, v: i64) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i32(&mut self, v: i32) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i16(&mut self, v: i16) -> EncodeResult { write!(self.writer, "{}", v) }
-    fn emit_i8(&mut self, v: i8) -> EncodeResult { write!(self.writer, "{}", v) }
-
-    fn emit_bool(&mut self, v: bool) -> EncodeResult {
-        if v {
-            write!(self.writer, "true")
-        } else {
-            write!(self.writer, "false")
-        }
-    }
-
-    fn emit_f64(&mut self, v: f64) -> EncodeResult {
-        write!(self.writer, "{}", fmt_number_or_null(v))
-    }
-    fn emit_f32(&mut self, v: f32) -> EncodeResult {
-        self.emit_f64(v as f64)
-    }
-
-    fn emit_char(&mut self, v: char) -> EncodeResult {
-        escape_char(self.writer, v)
-    }
-    fn emit_str(&mut self, v: &str) -> EncodeResult {
-        escape_str(self.writer, v)
-    }
-
-    fn emit_enum<F>(&mut self, _name: &str, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        f(self)
-    }
-
-    fn emit_enum_variant<F>(&mut self,
-                            name: &str,
-                            _id: uint,
-                            cnt: uint,
-                            f: F)
-                            -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if cnt == 0 {
-            escape_str(self.writer, name)
-        } else {
-            try!(write!(self.writer, "{{\n"));
-            self.curr_indent += self.indent;
-            try!(spaces(self.writer, self.curr_indent));
-            try!(write!(self.writer, "\"variant\": "));
-            try!(escape_str(self.writer, name));
-            try!(write!(self.writer, ",\n"));
-            try!(spaces(self.writer, self.curr_indent));
-            try!(write!(self.writer, "\"fields\": [\n"));
-            self.curr_indent += self.indent;
-            try!(f(self));
-            self.curr_indent -= self.indent;
-            try!(write!(self.writer, "\n"));
-            try!(spaces(self.writer, self.curr_indent));
-            self.curr_indent -= self.indent;
-            try!(write!(self.writer, "]\n"));
-            try!(spaces(self.writer, self.curr_indent));
-            write!(self.writer, "}}")
-        }
-    }
-
-    fn emit_enum_variant_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if idx != 0 {
-            try!(write!(self.writer, ",\n"));
-        }
-        try!(spaces(self.writer, self.curr_indent));
-        f(self)
-    }
-
-    fn emit_enum_struct_variant<F>(&mut self,
-                                   name: &str,
-                                   id: uint,
-                                   cnt: uint,
-                                   f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        self.emit_enum_variant(name, id, cnt, f)
-    }
-
-    fn emit_enum_struct_variant_field<F>(&mut self,
-                                         _: &str,
-                                         idx: uint,
-                                         f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        self.emit_enum_variant_arg(idx, f)
-    }
-
-
-    fn emit_struct<F>(&mut self, _: &str, len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if len == 0 {
-            write!(self.writer, "{{}}")
-        } else {
-            try!(write!(self.writer, "{{"));
-            self.curr_indent += self.indent;
-            try!(f(self));
-            self.curr_indent -= self.indent;
-            try!(write!(self.writer, "\n"));
-            try!(spaces(self.writer, self.curr_indent));
-            write!(self.writer, "}}")
-        }
-    }
-
-    fn emit_struct_field<F>(&mut self, name: &str, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if idx == 0 {
-            try!(write!(self.writer, "\n"));
-        } else {
-            try!(write!(self.writer, ",\n"));
-        }
-        try!(spaces(self.writer, self.curr_indent));
-        try!(escape_str(self.writer, name));
-        try!(write!(self.writer, ": "));
-        f(self)
-    }
-
-    fn emit_tuple<F>(&mut self, len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq(len, f)
-    }
-    fn emit_tuple_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq_elt(idx, f)
-    }
-
-    fn emit_tuple_struct<F>(&mut self, _: &str, len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq(len, f)
-    }
-    fn emit_tuple_struct_arg<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        self.emit_seq_elt(idx, f)
-    }
-
-    fn emit_option<F>(&mut self, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        f(self)
-    }
-    fn emit_option_none(&mut self) -> EncodeResult { self.emit_nil() }
-    fn emit_option_some<F>(&mut self, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        f(self)
-    }
-
-    fn emit_seq<F>(&mut self, len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if len == 0 {
-            write!(self.writer, "[]")
-        } else {
-            try!(write!(self.writer, "["));
-            self.curr_indent += self.indent;
-            try!(f(self));
-            self.curr_indent -= self.indent;
-            try!(write!(self.writer, "\n"));
-            try!(spaces(self.writer, self.curr_indent));
-            write!(self.writer, "]")
-        }
-    }
-
-    fn emit_seq_elt<F>(&mut self, idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if idx == 0 {
-            try!(write!(self.writer, "\n"));
-        } else {
-            try!(write!(self.writer, ",\n"));
-        }
-        try!(spaces(self.writer, self.curr_indent));
-        f(self)
-    }
-
-    fn emit_map<F>(&mut self, len: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if len == 0 {
-            write!(self.writer, "{{}}")
-        } else {
-            try!(write!(self.writer, "{{"));
-            self.curr_indent += self.indent;
-            try!(f(self));
-            self.curr_indent -= self.indent;
-            try!(write!(self.writer, "\n"));
-            try!(spaces(self.writer, self.curr_indent));
-            write!(self.writer, "}}")
-        }
-    }
-
-    fn emit_map_elt_key<F>(&mut self, idx: uint, mut f: F) -> EncodeResult where
-        F: FnMut(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        if idx == 0 {
-            try!(write!(self.writer, "\n"));
-        } else {
-            try!(write!(self.writer, ",\n"));
-        }
-        try!(spaces(self.writer, self.curr_indent));
-        // ref #12967, make sure to wrap a key in double quotes,
-        // in the event that its of a type that omits them (eg numbers)
-        let mut buf = Vec::new();
-        // FIXME(14302) remove the transmute and unsafe block.
-        unsafe {
-            let mut check_encoder = PrettyEncoder::new(&mut buf);
-            try!(f(transmute(&mut check_encoder)));
-        }
-        let out = str::from_utf8(buf[]).unwrap();
-        let needs_wrapping = out.char_at(0) != '"' && out.char_at_reverse(out.len()) != '"';
-        if needs_wrapping { try!(write!(self.writer, "\"")); }
-        try!(f(self));
-        if needs_wrapping { try!(write!(self.writer, "\"")); }
-        Ok(())
-    }
-
-    fn emit_map_elt_val<F>(&mut self, _idx: uint, f: F) -> EncodeResult where
-        F: FnOnce(&mut PrettyEncoder<'a>) -> EncodeResult,
-    {
-        try!(write!(self.writer, ": "));
-        f(self)
-    }
-}
-
-impl<E: ::Encoder<S>, S> Encodable<E, S> for Json {
-    fn encode(&self, e: &mut E) -> Result<(), S> {
-        match *self {
-            Json::I64(v) => v.encode(e),
-            Json::U64(v) => v.encode(e),
-            Json::F64(v) => v.encode(e),
-            Json::String(ref v) => v.encode(e),
-            Json::Boolean(v) => v.encode(e),
-            Json::Array(ref v) => v.encode(e),
-            Json::Object(ref v) => v.encode(e),
-            Json::Null => e.emit_nil(),
-        }
-    }
-}
-
-/// Create an `AsJson` wrapper which can be used to print a value as JSON
-/// on-the-fly via `write!`
-pub fn as_json<T>(t: &T) -> AsJson<T> {
-    AsJson { inner: t }
-}
-
-/// Create an `AsPrettyJson` wrapper which can be used to print a value as JSON
-/// on-the-fly via `write!`
-pub fn as_pretty_json<T>(t: &T) -> AsPrettyJson<T> {
-    AsPrettyJson { inner: t, indent: None }
-}
-
-impl Json {
-    /// Borrow this json object as a pretty object to generate a pretty
-    /// representation for it via `Show`.
-    pub fn pretty(&self) -> PrettyJson {
-        PrettyJson { inner: self }
-    }
-
-     /// If the Json value is an Object, returns the value associated with the provided key.
-    /// Otherwise, returns None.
-    pub fn find<'a>(&'a self, key: &str) -> Option<&'a Json>{
-        match self {
-            &Json::Object(ref map) => map.get(key),
-            _ => None
-        }
-    }
-
-    /// Attempts to get a nested Json Object for each key in `keys`.
-    /// If any key is found not to exist, find_path will return None.
-    /// Otherwise, it will return the Json value associated with the final key.
-    pub fn find_path<'a>(&'a self, keys: &[&str]) -> Option<&'a Json>{
-        let mut target = self;
-        for key in keys.iter() {
-            match target.find(*key) {
-                Some(t) => { target = t; },
-                None => return None
-            }
-        }
-        Some(target)
-    }
-
-    /// If the Json value is an Object, performs a depth-first search until
-    /// a value associated with the provided key is found. If no value is found
-    /// or the Json value is not an Object, returns None.
-    pub fn search<'a>(&'a self, key: &str) -> Option<&'a Json> {
-        match self {
-            &Json::Object(ref map) => {
-                match map.get(key) {
-                    Some(json_value) => Some(json_value),
-                    None => {
-                        for (_, v) in map.iter() {
-                            match v.search(key) {
-                                x if x.is_some() => return x,
-                                _ => ()
-                            }
-                        }
-                        None
-                    }
-                }
-            },
-            _ => None
-        }
-    }
-
-    /// Returns true if the Json value is an Object. Returns false otherwise.
-    pub fn is_object<'a>(&'a self) -> bool {
-        self.as_object().is_some()
-    }
-
-    /// If the Json value is an Object, returns the associated BTreeMap.
-    /// Returns None otherwise.
-    pub fn as_object<'a>(&'a self) -> Option<&'a Object> {
-        match self {
-            &Json::Object(ref map) => Some(map),
-            _ => None
-        }
-    }
-
-    /// Returns true if the Json value is an Array. Returns false otherwise.
-    pub fn is_array<'a>(&'a self) -> bool {
-        self.as_array().is_some()
-    }
-
-    /// If the Json value is an Array, returns the associated vector.
-    /// Returns None otherwise.
-    pub fn as_array<'a>(&'a self) -> Option<&'a Array> {
-        match self {
-            &Json::Array(ref array) => Some(&*array),
-            _ => None
-        }
-    }
-
-    /// Returns true if the Json value is a String. Returns false otherwise.
-    pub fn is_string<'a>(&'a self) -> bool {
-        self.as_string().is_some()
-    }
-
-    /// If the Json value is a String, returns the associated str.
-    /// Returns None otherwise.
-    pub fn as_string<'a>(&'a self) -> Option<&'a str> {
-        match *self {
-            Json::String(ref s) => Some(s[]),
-            _ => None
-        }
-    }
-
-    /// Returns true if the Json value is a Number. Returns false otherwise.
-    pub fn is_number(&self) -> bool {
-        match *self {
-            Json::I64(_) | Json::U64(_) | Json::F64(_) => true,
-            _ => false,
-        }
-    }
-
-    /// Returns true if the Json value is a i64. Returns false otherwise.
-    pub fn is_i64(&self) -> bool {
-        match *self {
-            Json::I64(_) => true,
-            _ => false,
-        }
-    }
-
-    /// Returns true if the Json value is a u64. Returns false otherwise.
-    pub fn is_u64(&self) -> bool {
-        match *self {
-            Json::U64(_) => true,
-            _ => false,
-        }
-    }
-
-    /// Returns true if the Json value is a f64. Returns false otherwise.
-    pub fn is_f64(&self) -> bool {
-        match *self {
-            Json::F64(_) => true,
-            _ => false,
-        }
-    }
-
-    /// If the Json value is a number, return or cast it to a i64.
-    /// Returns None otherwise.
-    pub fn as_i64(&self) -> Option<i64> {
-        match *self {
-            Json::I64(n) => Some(n),
-            Json::U64(n) => num::cast(n),
-            _ => None
-        }
-    }
-
-    /// If the Json value is a number, return or cast it to a u64.
-    /// Returns None otherwise.
-    pub fn as_u64(&self) -> Option<u64> {
-        match *self {
-            Json::I64(n) => num::cast(n),
-            Json::U64(n) => Some(n),
-            _ => None
-        }
-    }
-
-    /// If the Json value is a number, return or cast it to a f64.
-    /// Returns None otherwise.
-    pub fn as_f64(&self) -> Option<f64> {
-        match *self {
-            Json::I64(n) => num::cast(n),
-            Json::U64(n) => num::cast(n),
-            Json::F64(n) => Some(n),
-            _ => None
-        }
-    }
-
-    /// Returns true if the Json value is a Boolean. Returns false otherwise.
-    pub fn is_boolean(&self) -> bool {
-        self.as_boolean().is_some()
-    }
-
-    /// If the Json value is a Boolean, returns the associated bool.
-    /// Returns None otherwise.
-    pub fn as_boolean(&self) -> Option<bool> {
-        match self {
-            &Json::Boolean(b) => Some(b),
-            _ => None
-        }
-    }
-
-    /// Returns true if the Json value is a Null. Returns false otherwise.
-    pub fn is_null(&self) -> bool {
-        self.as_null().is_some()
-    }
-
-    /// If the Json value is a Null, returns ().
-    /// Returns None otherwise.
-    pub fn as_null(&self) -> Option<()> {
-        match self {
-            &Json::Null => Some(()),
-            _ => None
-        }
-    }
-}
-
-impl<'a> ops::Index<&'a str>  for Json {
-    type Output = Json;
-
-    fn index(&self, idx: & &str) -> &Json {
-        self.find(*idx).unwrap()
-    }
-}
-
-impl ops::Index<uint> for Json {
-    type Output = Json;
-
-    fn index<'a>(&'a self, idx: &uint) -> &'a Json {
-        match self {
-            &Json::Array(ref v) => v.index(idx),
-            _ => panic!("can only index Json with uint if it is an array")
-        }
-    }
-}
-
-/// The output of the streaming parser.
-#[derive(PartialEq, Clone, Show)]
-pub enum JsonEvent {
-    ObjectStart,
-    ObjectEnd,
-    ArrayStart,
-    ArrayEnd,
-    BooleanValue(bool),
-    I64Value(i64),
-    U64Value(u64),
-    F64Value(f64),
-    StringValue(string::String),
-    NullValue,
-    Error(ParserError),
-}
-
-#[derive(PartialEq, Show)]
-enum ParserState {
-    // Parse a value in an array, true means first element.
-    ParseArray(bool),
-    // Parse ',' or ']' after an element in an array.
-    ParseArrayComma,
-    // Parse a key:value in an object, true means first element.
-    ParseObject(bool),
-    // Parse ',' or ']' after an element in an object.
-    ParseObjectComma,
-    // Initial state.
-    ParseStart,
-    // Expecting the stream to end.
-    ParseBeforeFinish,
-    // Parsing can't continue.
-    ParseFinished,
-}
-
-/// A Stack represents the current position of the parser in the logical
-/// structure of the JSON stream.
-/// For example foo.bar[3].x
-pub struct Stack {
-    stack: Vec<InternalStackElement>,
-    str_buffer: Vec<u8>,
-}
-
-/// StackElements compose a Stack.
-/// For example, Key("foo"), Key("bar"), Index(3) and Key("x") are the
-/// StackElements compositing the stack that represents foo.bar[3].x
-#[derive(PartialEq, Clone, Show)]
-pub enum StackElement<'l> {
-    Index(u32),
-    Key(&'l str),
-}
-
-// Internally, Key elements are stored as indices in a buffer to avoid
-// allocating a string for every member of an object.
-#[derive(PartialEq, Clone, Show)]
-enum InternalStackElement {
-    InternalIndex(u32),
-    InternalKey(u16, u16), // start, size
-}
-
-impl Stack {
-    pub fn new() -> Stack {
-        Stack { stack: Vec::new(), str_buffer: Vec::new() }
-    }
-
-    /// Returns The number of elements in the Stack.
-    pub fn len(&self) -> uint { self.stack.len() }
-
-    /// Returns true if the stack is empty.
-    pub fn is_empty(&self) -> bool { self.stack.is_empty() }
-
-    /// Provides access to the StackElement at a given index.
-    /// lower indices are at the bottom of the stack while higher indices are
-    /// at the top.
-    pub fn get<'l>(&'l self, idx: uint) -> StackElement<'l> {
-        match self.stack[idx] {
-            InternalIndex(i) => Index(i),
-            InternalKey(start, size) => {
-                Key(str::from_utf8(
-                    self.str_buffer[start as uint .. start as uint + size as uint]).unwrap())
-            }
-        }
-    }
-
-    /// Compares this stack with an array of StackElements.
-    pub fn is_equal_to(&self, rhs: &[StackElement]) -> bool {
-        if self.stack.len() != rhs.len() { return false; }
-        for i in range(0, rhs.len()) {
-            if self.get(i) != rhs[i] { return false; }
-        }
-        return true;
-    }
-
-    /// Returns true if the bottom-most elements of this stack are the same as
-    /// the ones passed as parameter.
-    pub fn starts_with(&self, rhs: &[StackElement]) -> bool {
-        if self.stack.len() < rhs.len() { return false; }
-        for i in range(0, rhs.len()) {
-            if self.get(i) != rhs[i] { return false; }
-        }
-        return true;
-    }
-
-    /// Returns true if the top-most elements of this stack are the same as
-    /// the ones passed as parameter.
-    pub fn ends_with(&self, rhs: &[StackElement]) -> bool {
-        if self.stack.len() < rhs.len() { return false; }
-        let offset = self.stack.len() - rhs.len();
-        for i in range(0, rhs.len()) {
-            if self.get(i + offset) != rhs[i] { return false; }
-        }
-        return true;
-    }
-
-    /// Returns the top-most element (if any).
-    pub fn top<'l>(&'l self) -> Option<StackElement<'l>> {
-        return match self.stack.last() {
-            None => None,
-            Some(&InternalIndex(i)) => Some(Index(i)),
-            Some(&InternalKey(start, size)) => {
-                Some(Key(str::from_utf8(
-                    self.str_buffer[start as uint .. (start+size) as uint]
-                ).unwrap()))
-            }
-        }
-    }
-
-    // Used by Parser to insert Key elements at the top of the stack.
-    fn push_key(&mut self, key: string::String) {
-        self.stack.push(InternalKey(self.str_buffer.len() as u16, key.len() as u16));
-        for c in key.as_bytes().iter() {
-            self.str_buffer.push(*c);
-        }
-    }
-
-    // Used by Parser to insert Index elements at the top of the stack.
-    fn push_index(&mut self, index: u32) {
-        self.stack.push(InternalIndex(index));
-    }
-
-    // Used by Parser to remove the top-most element of the stack.
-    fn pop(&mut self) {
-        assert!(!self.is_empty());
-        match *self.stack.last().unwrap() {
-            InternalKey(_, sz) => {
-                let new_size = self.str_buffer.len() - sz as uint;
-                self.str_buffer.truncate(new_size);
-            }
-            InternalIndex(_) => {}
-        }
-        self.stack.pop();
-    }
-
-    // Used by Parser to test whether the top-most element is an index.
-    fn last_is_index(&self) -> bool {
-        if self.is_empty() { return false; }
-        return match *self.stack.last().unwrap() {
-            InternalIndex(_) => true,
-            _ => false,
-        }
-    }
-
-    // Used by Parser to increment the index of the top-most element.
-    fn bump_index(&mut self) {
-        let len = self.stack.len();
-        let idx = match *self.stack.last().unwrap() {
-            InternalIndex(i) => { i + 1 }
-            _ => { panic!(); }
-        };
-        self.stack[len - 1] = InternalIndex(idx);
-    }
-}
-
-/// A streaming JSON parser implemented as an iterator of JsonEvent, consuming
-/// an iterator of char.
-pub struct Parser<T> {
-    rdr: T,
-    ch: Option<char>,
-    line: uint,
-    col: uint,
-    // We maintain a stack representing where we are in the logical structure
-    // of the JSON stream.
-    stack: Stack,
-    // A state machine is kept to make it possible to interrupt and resume parsing.
-    state: ParserState,
-}
-
-impl<T: Iterator<Item=char>> Iterator for Parser<T> {
-    type Item = JsonEvent;
-
-    fn next(&mut self) -> Option<JsonEvent> {
-        if self.state == ParseFinished {
-            return None;
-        }
-
-        if self.state == ParseBeforeFinish {
-            self.parse_whitespace();
-            // Make sure there is no trailing characters.
-            if self.eof() {
-                self.state = ParseFinished;
-                return None;
-            } else {
-                return Some(self.error_event(TrailingCharacters));
-            }
-        }
-
-        return Some(self.parse());
-    }
-}
-
-impl<T: Iterator<Item=char>> Parser<T> {
-    /// Creates the JSON parser.
-    pub fn new(rdr: T) -> Parser<T> {
-        let mut p = Parser {
-            rdr: rdr,
-            ch: Some('\x00'),
-            line: 1,
-            col: 0,
-            stack: Stack::new(),
-            state: ParseStart,
-        };
-        p.bump();
-        return p;
-    }
-
-    /// Provides access to the current position in the logical structure of the
-    /// JSON stream.
-    pub fn stack<'l>(&'l self) -> &'l Stack {
-        return &self.stack;
-    }
-
-    fn eof(&self) -> bool { self.ch.is_none() }
-    fn ch_or_null(&self) -> char { self.ch.unwrap_or('\x00') }
-    fn bump(&mut self) {
-        self.ch = self.rdr.next();
-
-        if self.ch_is('\n') {
-            self.line += 1u;
-            self.col = 1u;
-        } else {
-            self.col += 1u;
-        }
-    }
-
-    fn next_char(&mut self) -> Option<char> {
-        self.bump();
-        self.ch
-    }
-    fn ch_is(&self, c: char) -> bool {
-        self.ch == Some(c)
-    }
-
-    fn error<T>(&self, reason: ErrorCode) -> Result<T, ParserError> {
-        Err(SyntaxError(reason, self.line, self.col))
-    }
-
-    fn parse_whitespace(&mut self) {
-        while self.ch_is(' ') ||
-              self.ch_is('\n') ||
-              self.ch_is('\t') ||
-              self.ch_is('\r') { self.bump(); }
-    }
-
-    fn parse_number(&mut self) -> JsonEvent {
-        let mut neg = false;
-
-        if self.ch_is('-') {
-            self.bump();
-            neg = true;
-        }
-
-        let res = match self.parse_u64() {
-            Ok(res) => res,
-            Err(e) => { return Error(e); }
-        };
-
-        if self.ch_is('.') || self.ch_is('e') || self.ch_is('E') {
-            let mut res = res as f64;
-
-            if self.ch_is('.') {
-                res = match self.parse_decimal(res) {
-                    Ok(res) => res,
-                    Err(e) => { return Error(e); }
-                };
-            }
-
-            if self.ch_is('e') || self.ch_is('E') {
-                res = match self.parse_exponent(res) {
-                    Ok(res) => res,
-                    Err(e) => { return Error(e); }
-                };
-            }
-
-            if neg {
-                res *= -1.0;
-            }
-
-            F64Value(res)
-        } else {
-            if neg {
-                let res = -(res as i64);
-
-                // Make sure we didn't underflow.
-                if res > 0 {
-                    Error(SyntaxError(InvalidNumber, self.line, self.col))
-                } else {
-                    I64Value(res)
-                }
-            } else {
-                U64Value(res)
-            }
-        }
-    }
-
-    fn parse_u64(&mut self) -> Result<u64, ParserError> {
-        let mut accum = 0;
-        let last_accum = 0; // necessary to detect overflow.
-
-        match self.ch_or_null() {
-            '0' => {
-                self.bump();
-
-                // A leading '0' must be the only digit before the decimal point.
-                match self.ch_or_null() {
-                    '0' ... '9' => return self.error(InvalidNumber),
-                    _ => ()
-                }
-            },
-            '1' ... '9' => {
-                while !self.eof() {
-                    match self.ch_or_null() {
-                        c @ '0' ... '9' => {
-                            accum *= 10;
-                            accum += (c as u64) - ('0' as u64);
-
-                            // Detect overflow by comparing to the last value.
-                            if accum <= last_accum { return self.error(InvalidNumber); }
-
-                            self.bump();
-                        }
-                        _ => break,
-                    }
-                }
-            }
-            _ => return self.error(InvalidNumber),
-        }
-
-        Ok(accum)
-    }
-
-    fn parse_decimal(&mut self, mut res: f64) -> Result<f64, ParserError> {
-        self.bump();
-
-        // Make sure a digit follows the decimal place.
-        match self.ch_or_null() {
-            '0' ... '9' => (),
-             _ => return self.error(InvalidNumber)
-        }
-
-        let mut dec = 1.0;
-        while !self.eof() {
-            match self.ch_or_null() {
-                c @ '0' ... '9' => {
-                    dec /= 10.0;
-                    res += (((c as int) - ('0' as int)) as f64) * dec;
-                    self.bump();
-                }
-                _ => break,
-            }
-        }
-
-        Ok(res)
-    }
-
-    fn parse_exponent(&mut self, mut res: f64) -> Result<f64, ParserError> {
-        self.bump();
-
-        let mut exp = 0u;
-        let mut neg_exp = false;
-
-        if self.ch_is('+') {
-            self.bump();
-        } else if self.ch_is('-') {
-            self.bump();
-            neg_exp = true;
-        }
-
-        // Make sure a digit follows the exponent place.
-        match self.ch_or_null() {
-            '0' ... '9' => (),
-            _ => return self.error(InvalidNumber)
-        }
-        while !self.eof() {
-            match self.ch_or_null() {
-                c @ '0' ... '9' => {
-                    exp *= 10;
-                    exp += (c as uint) - ('0' as uint);
-
-                    self.bump();
-                }
-                _ => break
-            }
-        }
-
-        let exp = 10_f64.powi(exp as i32);
-        if neg_exp {
-            res /= exp;
-        } else {
-            res *= exp;
-        }
-
-        Ok(res)
-    }
-
-    fn decode_hex_escape(&mut self) -> Result<u16, ParserError> {
-        let mut i = 0u;
-        let mut n = 0u16;
-        while i < 4 && !self.eof() {
-            self.bump();
-            n = match self.ch_or_null() {
-                c @ '0' ... '9' => n * 16 + ((c as u16) - ('0' as u16)),
-                'a' | 'A' => n * 16 + 10,
-                'b' | 'B' => n * 16 + 11,
-                'c' | 'C' => n * 16 + 12,
-                'd' | 'D' => n * 16 + 13,
-                'e' | 'E' => n * 16 + 14,
-                'f' | 'F' => n * 16 + 15,
-                _ => return self.error(InvalidEscape)
-            };
-
-            i += 1u;
-        }
-
-        // Error out if we didn't parse 4 digits.
-        if i != 4 {
-            return self.error(InvalidEscape);
-        }
-
-        Ok(n)
-    }
-
-    fn parse_str(&mut self) -> Result<string::String, ParserError> {
-        let mut escape = false;
-        let mut res = string::String::new();
-
-        loop {
-            self.bump();
-            if self.eof() {
-                return self.error(EOFWhileParsingString);
-            }
-
-            if escape {
-                match self.ch_or_null() {
-                    '"' => res.push('"'),
-                    '\\' => res.push('\\'),
-                    '/' => res.push('/'),
-                    'b' => res.push('\x08'),
-                    'f' => res.push('\x0c'),
-                    'n' => res.push('\n'),
-                    'r' => res.push('\r'),
-                    't' => res.push('\t'),
-                    'u' => match try!(self.decode_hex_escape()) {
-                        0xDC00 ... 0xDFFF => {
-                            return self.error(LoneLeadingSurrogateInHexEscape)
-                        }
-
-                        // Non-BMP characters are encoded as a sequence of
-                        // two hex escapes, representing UTF-16 surrogates.
-                        n1 @ 0xD800 ... 0xDBFF => {
-                            match (self.next_char(), self.next_char()) {
-                                (Some('\\'), Some('u')) => (),
-                                _ => return self.error(UnexpectedEndOfHexEscape),
-                            }
-
-                            let buf = [n1, try!(self.decode_hex_escape())];
-                            match unicode_str::utf16_items(&buf).next() {
-                                Some(Utf16Item::ScalarValue(c)) => res.push(c),
-                                _ => return self.error(LoneLeadingSurrogateInHexEscape),
-                            }
-                        }
-
-                        n => match char::from_u32(n as u32) {
-                            Some(c) => res.push(c),
-                            None => return self.error(InvalidUnicodeCodePoint),
-                        },
-                    },
-                    _ => return self.error(InvalidEscape),
-                }
-                escape = false;
-            } else if self.ch_is('\\') {
-                escape = true;
-            } else {
-                match self.ch {
-                    Some('"') => {
-                        self.bump();
-                        return Ok(res);
-                    },
-                    Some(c) => res.push(c),
-                    None => unreachable!()
-                }
-            }
-        }
-    }
-
-    // Invoked at each iteration, consumes the stream until it has enough
-    // information to return a JsonEvent.
-    // Manages an internal state so that parsing can be interrupted and resumed.
-    // Also keeps track of the position in the logical structure of the json
-    // stream int the form of a stack that can be queried by the user using the
-    // stack() method.
-    fn parse(&mut self) -> JsonEvent {
-        loop {
-            // The only paths where the loop can spin a new iteration
-            // are in the cases ParseArrayComma and ParseObjectComma if ','
-            // is parsed. In these cases the state is set to (respectively)
-            // ParseArray(false) and ParseObject(false), which always return,
-            // so there is no risk of getting stuck in an infinite loop.
-            // All other paths return before the end of the loop's iteration.
-            self.parse_whitespace();
-
-            match self.state {
-                ParseStart => {
-                    return self.parse_start();
-                }
-                ParseArray(first) => {
-                    return self.parse_array(first);
-                }
-                ParseArrayComma => {
-                    match self.parse_array_comma_or_end() {
-                        Some(evt) => { return evt; }
-                        None => {}
-                    }
-                }
-                ParseObject(first) => {
-                    return self.parse_object(first);
-                }
-                ParseObjectComma => {
-                    self.stack.pop();
-                    if self.ch_is(',') {
-                        self.state = ParseObject(false);
-                        self.bump();
-                    } else {
-                        return self.parse_object_end();
-                    }
-                }
-                _ => {
-                    return self.error_event(InvalidSyntax);
-                }
-            }
-        }
-    }
-
-    fn parse_start(&mut self) -> JsonEvent {
-        let val = self.parse_value();
-        self.state = match val {
-            Error(_) => ParseFinished,
-            ArrayStart => ParseArray(true),
-            ObjectStart => ParseObject(true),
-            _ => ParseBeforeFinish,
-        };
-        return val;
-    }
-
-    fn parse_array(&mut self, first: bool) -> JsonEvent {
-        if self.ch_is(']') {
-            if !first {
-                self.error_event(InvalidSyntax)
-            } else {
-                self.state = if self.stack.is_empty() {
-                    ParseBeforeFinish
-                } else if self.stack.last_is_index() {
-                    ParseArrayComma
-                } else {
-                    ParseObjectComma
-                };
-                self.bump();
-                ArrayEnd
-            }
-        } else {
-            if first {
-                self.stack.push_index(0);
-            }
-            let val = self.parse_value();
-            self.state = match val {
-                Error(_) => ParseFinished,
-                ArrayStart => ParseArray(true),
-                ObjectStart => ParseObject(true),
-                _ => ParseArrayComma,
-            };
-            val
-        }
-    }
-
-    fn parse_array_comma_or_end(&mut self) -> Option<JsonEvent> {
-        if self.ch_is(',') {
-            self.stack.bump_index();
-            self.state = ParseArray(false);
-            self.bump();
-            None
-        } else if self.ch_is(']') {
-            self.stack.pop();
-            self.state = if self.stack.is_empty() {
-                ParseBeforeFinish
-            } else if self.stack.last_is_index() {
-                ParseArrayComma
-            } else {
-                ParseObjectComma
-            };
-            self.bump();
-            Some(ArrayEnd)
-        } else if self.eof() {
-            Some(self.error_event(EOFWhileParsingArray))
-        } else {
-            Some(self.error_event(InvalidSyntax))
-        }
-    }
-
-    fn parse_object(&mut self, first: bool) -> JsonEvent {
-        if self.ch_is('}') {
-            if !first {
-                if self.stack.is_empty() {
-                    return self.error_event(TrailingComma);
-                } else {
-                    self.stack.pop();
-                }
-            }
-            self.state = if self.stack.is_empty() {
-                ParseBeforeFinish
-            } else if self.stack.last_is_index() {
-                ParseArrayComma
-            } else {
-                ParseObjectComma
-            };
-            self.bump();
-            return ObjectEnd;
-        }
-        if self.eof() {
-            return self.error_event(EOFWhileParsingObject);
-        }
-        if !self.ch_is('"') {
-            return self.error_event(KeyMustBeAString);
-        }
-        let s = match self.parse_str() {
-            Ok(s) => s,
-            Err(e) => {
-                self.state = ParseFinished;
-                return Error(e);
-            }
-        };
-        self.parse_whitespace();
-        if self.eof() {
-            return self.error_event(EOFWhileParsingObject);
-        } else if self.ch_or_null() != ':' {
-            return self.error_event(ExpectedColon);
-        }
-        self.stack.push_key(s);
-        self.bump();
-        self.parse_whitespace();
-
-        let val = self.parse_value();
-
-        self.state = match val {
-            Error(_) => ParseFinished,
-            ArrayStart => ParseArray(true),
-            ObjectStart => ParseObject(true),
-            _ => ParseObjectComma,
-        };
-        return val;
-    }
-
-    fn parse_object_end(&mut self) -> JsonEvent {
-        if self.ch_is('}') {
-            self.state = if self.stack.is_empty() {
-                ParseBeforeFinish
-            } else if self.stack.last_is_index() {
-                ParseArrayComma
-            } else {
-                ParseObjectComma
-            };
-            self.bump();
-            ObjectEnd
-        } else if self.eof() {
-            self.error_event(EOFWhileParsingObject)
-        } else {
-            self.error_event(InvalidSyntax)
-        }
-    }
-
-    fn parse_value(&mut self) -> JsonEvent {
-        if self.eof() { return self.error_event(EOFWhileParsingValue); }
-        match self.ch_or_null() {
-            'n' => { self.parse_ident("ull", NullValue) }
-            't' => { self.parse_ident("rue", BooleanValue(true)) }
-            'f' => { self.parse_ident("alse", BooleanValue(false)) }
-            '0' ... '9' | '-' => self.parse_number(),
-            '"' => match self.parse_str() {
-                Ok(s) => StringValue(s),
-                Err(e) => Error(e),
-            },
-            '[' => {
-                self.bump();
-                ArrayStart
-            }
-            '{' => {
-                self.bump();
-                ObjectStart
-            }
-            _ => { self.error_event(InvalidSyntax) }
-        }
-    }
-
-    fn parse_ident(&mut self, ident: &str, value: JsonEvent) -> JsonEvent {
-        if ident.chars().all(|c| Some(c) == self.next_char()) {
-            self.bump();
-            value
-        } else {
-            Error(SyntaxError(InvalidSyntax, self.line, self.col))
-        }
-    }
-
-    fn error_event(&mut self, reason: ErrorCode) -> JsonEvent {
-        self.state = ParseFinished;
-        Error(SyntaxError(reason, self.line, self.col))
-    }
-}
-
-/// A Builder consumes a json::Parser to create a generic Json structure.
-pub struct Builder<T> {
-    parser: Parser<T>,
-    token: Option<JsonEvent>,
-}
-
-impl<T: Iterator<Item=char>> Builder<T> {
-    /// Create a JSON Builder.
-    pub fn new(src: T) -> Builder<T> {
-        Builder { parser: Parser::new(src), token: None, }
-    }
-
-    // Decode a Json value from a Parser.
-    pub fn build(&mut self) -> Result<Json, BuilderError> {
-        self.bump();
-        let result = self.build_value();
-        self.bump();
-        match self.token {
-            None => {}
-            Some(Error(e)) => { return Err(e); }
-            ref tok => { panic!("unexpected token {}", tok.clone()); }
-        }
-        result
-    }
-
-    fn bump(&mut self) {
-        self.token = self.parser.next();
-    }
-
-    fn build_value(&mut self) -> Result<Json, BuilderError> {
-        return match self.token {
-            Some(NullValue) => Ok(Json::Null),
-            Some(I64Value(n)) => Ok(Json::I64(n)),
-            Some(U64Value(n)) => Ok(Json::U64(n)),
-            Some(F64Value(n)) => Ok(Json::F64(n)),
-            Some(BooleanValue(b)) => Ok(Json::Boolean(b)),
-            Some(StringValue(ref mut s)) => {
-                let mut temp = string::String::new();
-                swap(s, &mut temp);
-                Ok(Json::String(temp))
-            }
-            Some(Error(e)) => Err(e),
-            Some(ArrayStart) => self.build_array(),
-            Some(ObjectStart) => self.build_object(),
-            Some(ObjectEnd) => self.parser.error(InvalidSyntax),
-            Some(ArrayEnd) => self.parser.error(InvalidSyntax),
-            None => self.parser.error(EOFWhileParsingValue),
-        }
-    }
-
-    fn build_array(&mut self) -> Result<Json, BuilderError> {
-        self.bump();
-        let mut values = Vec::new();
-
-        loop {
-            if self.token == Some(ArrayEnd) {
-                return Ok(Json::Array(values.into_iter().collect()));
-            }
-            match self.build_value() {
-                Ok(v) => values.push(v),
-                Err(e) => { return Err(e) }
-            }
-            self.bump();
-        }
-    }
-
-    fn build_object(&mut self) -> Result<Json, BuilderError> {
-        self.bump();
-
-        let mut values = BTreeMap::new();
-
-        loop {
-            match self.token {
-                Some(ObjectEnd) => { return Ok(Json::Object(values)); }
-                Some(Error(e)) => { return Err(e); }
-                None => { break; }
-                _ => {}
-            }
-            let key = match self.parser.stack().top() {
-                Some(Key(k)) => { k.to_string() }
-                _ => { panic!("invalid state"); }
-            };
-            match self.build_value() {
-                Ok(value) => { values.insert(key, value); }
-                Err(e) => { return Err(e); }
-            }
-            self.bump();
-        }
-        return self.parser.error(EOFWhileParsingObject);
-    }
-}
-
-/// Decodes a json value from an `&mut io::Reader`
-pub fn from_reader(rdr: &mut io::Reader) -> Result<Json, BuilderError> {
-    let contents = match rdr.read_to_end() {
-        Ok(c)  => c,
-        Err(e) => return Err(io_error_to_error(e))
-    };
-    let s = match str::from_utf8(contents.as_slice()).ok() {
-        Some(s) => s,
-        _       => return Err(SyntaxError(NotUtf8, 0, 0))
-    };
-    let mut builder = Builder::new(s.chars());
-    builder.build()
-}
-
-/// Decodes a json value from a string
-pub fn from_str(s: &str) -> Result<Json, BuilderError> {
-    let mut builder = Builder::new(s.chars());
-    builder.build()
-}
-
-/// A structure to decode JSON to values in rust.
-pub struct Decoder {
-    stack: Vec<Json>,
-}
-
-impl Decoder {
-    /// Creates a new decoder instance for decoding the specified JSON value.
-    pub fn new(json: Json) -> Decoder {
-        Decoder { stack: vec![json] }
-    }
-}
-
-impl Decoder {
-    fn pop(&mut self) -> Json {
-        self.stack.pop().unwrap()
-    }
-}
-
-macro_rules! expect {
-    ($e:expr, Null) => ({
-        match $e {
-            Json::Null => Ok(()),
-            other => Err(ExpectedError("Null".to_string(),
-                                       format!("{}", other)))
-        }
-    });
-    ($e:expr, $t:ident) => ({
-        match $e {
-            Json::$t(v) => Ok(v),
-            other => {
-                Err(ExpectedError(stringify!($t).to_string(),
-                                  format!("{}", other)))
-            }
-        }
-    })
-}
-
-macro_rules! read_primitive {
-    ($name:ident, $ty:ty) => {
-        fn $name(&mut self) -> DecodeResult<$ty> {
-            match self.pop() {
-                Json::I64(f) => match num::cast(f) {
-                    Some(f) => Ok(f),
-                    None => Err(ExpectedError("Number".to_string(), format!("{}", f))),
-                },
-                Json::U64(f) => match num::cast(f) {
-                    Some(f) => Ok(f),
-                    None => Err(ExpectedError("Number".to_string(), format!("{}", f))),
-                },
-                Json::F64(f) => Err(ExpectedError("Integer".to_string(), format!("{}", f))),
-                // re: #12967.. a type w/ numeric keys (ie HashMap<uint, V> etc)
-                // is going to have a string here, as per JSON spec.
-                Json::String(s) => match s.parse() {
-                    Some(f) => Ok(f),
-                    None => Err(ExpectedError("Number".to_string(), s)),
-                },
-                value => Err(ExpectedError("Number".to_string(), format!("{}", value))),
-            }
-        }
-    }
-}
-
-impl ::Decoder<DecoderError> for Decoder {
-    fn read_nil(&mut self) -> DecodeResult<()> {
-        expect!(self.pop(), Null)
-    }
-
-    read_primitive! { read_uint, uint }
-    read_primitive! { read_u8, u8 }
-    read_primitive! { read_u16, u16 }
-    read_primitive! { read_u32, u32 }
-    read_primitive! { read_u64, u64 }
-    read_primitive! { read_int, int }
-    read_primitive! { read_i8, i8 }
-    read_primitive! { read_i16, i16 }
-    read_primitive! { read_i32, i32 }
-    read_primitive! { read_i64, i64 }
-
-    fn read_f32(&mut self) -> DecodeResult<f32> { self.read_f64().map(|x| x as f32) }
-
-    fn read_f64(&mut self) -> DecodeResult<f64> {
-        match self.pop() {
-            Json::I64(f) => Ok(f as f64),
-            Json::U64(f) => Ok(f as f64),
-            Json::F64(f) => Ok(f),
-            Json::String(s) => {
-                // re: #12967.. a type w/ numeric keys (ie HashMap<uint, V> etc)
-                // is going to have a string here, as per JSON spec.
-                match s.parse() {
-                    Some(f) => Ok(f),
-                    None => Err(ExpectedError("Number".to_string(), s)),
-                }
-            },
-            Json::Null => Ok(f64::NAN),
-            value => Err(ExpectedError("Number".to_string(), format!("{}", value)))
-        }
-    }
-
-    fn read_bool(&mut self) -> DecodeResult<bool> {
-        expect!(self.pop(), Boolean)
-    }
-
-    fn read_char(&mut self) -> DecodeResult<char> {
-        let s = try!(self.read_str());
-        {
-            let mut it = s.chars();
-            match (it.next(), it.next()) {
-                // exactly one character
-                (Some(c), None) => return Ok(c),
-                _ => ()
-            }
-        }
-        Err(ExpectedError("single character string".to_string(), format!("{}", s)))
-    }
-
-    fn read_str(&mut self) -> DecodeResult<string::String> {
-        expect!(self.pop(), String)
-    }
-
-    fn read_enum<T, F>(&mut self, _name: &str, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        f(self)
-    }
-
-    fn read_enum_variant<T, F>(&mut self, names: &[&str],
-                               mut f: F) -> DecodeResult<T>
-        where F: FnMut(&mut Decoder, uint) -> DecodeResult<T>,
-    {
-        let name = match self.pop() {
-            Json::String(s) => s,
-            Json::Object(mut o) => {
-                let n = match o.remove(&"variant".to_string()) {
-                    Some(Json::String(s)) => s,
-                    Some(val) => {
-                        return Err(ExpectedError("String".to_string(), format!("{}", val)))
-                    }
-                    None => {
-                        return Err(MissingFieldError("variant".to_string()))
-                    }
-                };
-                match o.remove(&"fields".to_string()) {
-                    Some(Json::Array(l)) => {
-                        for field in l.into_iter().rev() {
-                            self.stack.push(field);
-                        }
-                    },
-                    Some(val) => {
-                        return Err(ExpectedError("Array".to_string(), format!("{}", val)))
-                    }
-                    None => {
-                        return Err(MissingFieldError("fields".to_string()))
-                    }
-                }
-                n
-            }
-            json => {
-                return Err(ExpectedError("String or Object".to_string(), format!("{}", json)))
-            }
-        };
-        let idx = match names.iter().position(|n| *n == name[]) {
-            Some(idx) => idx,
-            None => return Err(UnknownVariantError(name))
-        };
-        f(self, idx)
-    }
-
-    fn read_enum_variant_arg<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        f(self)
-    }
-
-    fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) -> DecodeResult<T> where
-        F: FnMut(&mut Decoder, uint) -> DecodeResult<T>,
-    {
-        self.read_enum_variant(names, f)
-    }
-
-
-    fn read_enum_struct_variant_field<T, F>(&mut self,
-                                         _name: &str,
-                                         idx: uint,
-                                         f: F)
-                                         -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        self.read_enum_variant_arg(idx, f)
-    }
-
-    fn read_struct<T, F>(&mut self, _name: &str, _len: uint, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        let value = try!(f(self));
-        self.pop();
-        Ok(value)
-    }
-
-    fn read_struct_field<T, F>(&mut self,
-                               name: &str,
-                               _idx: uint,
-                               f: F)
-                               -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        let mut obj = try!(expect!(self.pop(), Object));
-
-        let value = match obj.remove(&name.to_string()) {
-            None => {
-                // Add a Null and try to parse it as an Option<_>
-                // to get None as a default value.
-                self.stack.push(Json::Null);
-                match f(self) {
-                    Ok(x) => x,
-                    Err(_) => return Err(MissingFieldError(name.to_string())),
-                }
-            },
-            Some(json) => {
-                self.stack.push(json);
-                try!(f(self))
-            }
-        };
-        self.stack.push(Json::Object(obj));
-        Ok(value)
-    }
-
-    fn read_tuple<T, F>(&mut self, tuple_len: uint, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        self.read_seq(move |d, len| {
-            if len == tuple_len {
-                f(d)
-            } else {
-                Err(ExpectedError(format!("Tuple{}", tuple_len), format!("Tuple{}", len)))
-            }
-        })
-    }
-
-    fn read_tuple_arg<T, F>(&mut self, idx: uint, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        self.read_seq_elt(idx, f)
-    }
-
-    fn read_tuple_struct<T, F>(&mut self,
-                               _name: &str,
-                               len: uint,
-                               f: F)
-                               -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        self.read_tuple(len, f)
-    }
-
-    fn read_tuple_struct_arg<T, F>(&mut self,
-                                   idx: uint,
-                                   f: F)
-                                   -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        self.read_tuple_arg(idx, f)
-    }
-
-    fn read_option<T, F>(&mut self, mut f: F) -> DecodeResult<T> where
-        F: FnMut(&mut Decoder, bool) -> DecodeResult<T>,
-    {
-        match self.pop() {
-            Json::Null => f(self, false),
-            value => { self.stack.push(value); f(self, true) }
-        }
-    }
-
-    fn read_seq<T, F>(&mut self, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder, uint) -> DecodeResult<T>,
-    {
-        let array = try!(expect!(self.pop(), Array));
-        let len = array.len();
-        for v in array.into_iter().rev() {
-            self.stack.push(v);
-        }
-        f(self, len)
-    }
-
-    fn read_seq_elt<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        f(self)
-    }
-
-    fn read_map<T, F>(&mut self, f: F) -> DecodeResult<T> where
-        F: FnOnce(&mut Decoder, uint) -> DecodeResult<T>,
-    {
-        let obj = try!(expect!(self.pop(), Object));
-        let len = obj.len();
-        for (key, value) in obj.into_iter() {
-            self.stack.push(value);
-            self.stack.push(Json::String(key));
-        }
-        f(self, len)
-    }
-
-    fn read_map_elt_key<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
-       F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        f(self)
-    }
-
-    fn read_map_elt_val<T, F>(&mut self, _idx: uint, f: F) -> DecodeResult<T> where
-       F: FnOnce(&mut Decoder) -> DecodeResult<T>,
-    {
-        f(self)
-    }
-
-    fn error(&mut self, err: &str) -> DecoderError {
-        ApplicationError(err.to_string())
-    }
-}
-
-/// A trait for converting values to JSON
-pub trait ToJson {
-    /// Converts the value of `self` to an instance of JSON
-    fn to_json(&self) -> Json;
-}
-
-macro_rules! to_json_impl_i64 {
-    ($($t:ty), +) => (
-        $(impl ToJson for $t {
-            fn to_json(&self) -> Json { Json::I64(*self as i64) }
-        })+
-    )
-}
-
-to_json_impl_i64! { int, i8, i16, i32, i64 }
-
-macro_rules! to_json_impl_u64 {
-    ($($t:ty), +) => (
-        $(impl ToJson for $t {
-            fn to_json(&self) -> Json { Json::U64(*self as u64) }
-        })+
-    )
-}
-
-to_json_impl_u64! { uint, u8, u16, u32, u64 }
-
-impl ToJson for Json {
-    fn to_json(&self) -> Json { self.clone() }
-}
-
-impl ToJson for f32 {
-    fn to_json(&self) -> Json { (*self as f64).to_json() }
-}
-
-impl ToJson for f64 {
-    fn to_json(&self) -> Json {
-        match self.classify() {
-            Fp::Nan | Fp::Infinite => Json::Null,
-            _                  => Json::F64(*self)
-        }
-    }
-}
-
-impl ToJson for () {
-    fn to_json(&self) -> Json { Json::Null }
-}
-
-impl ToJson for bool {
-    fn to_json(&self) -> Json { Json::Boolean(*self) }
-}
-
-impl ToJson for str {
-    fn to_json(&self) -> Json { Json::String(self.to_string()) }
-}
-
-impl ToJson for string::String {
-    fn to_json(&self) -> Json { Json::String((*self).clone()) }
-}
-
-macro_rules! tuple_impl {
-    // use variables to indicate the arity of the tuple
-    ($($tyvar:ident),* ) => {
-        // the trailing commas are for the 1 tuple
-        impl<
-            $( $tyvar : ToJson ),*
-            > ToJson for ( $( $tyvar ),* , ) {
-
-            #[inline]
-            #[allow(non_snake_case)]
-            fn to_json(&self) -> Json {
-                match *self {
-                    ($(ref $tyvar),*,) => Json::Array(vec![$($tyvar.to_json()),*])
-                }
-            }
-        }
-    }
-}
-
-tuple_impl!{A}
-tuple_impl!{A, B}
-tuple_impl!{A, B, C}
-tuple_impl!{A, B, C, D}
-tuple_impl!{A, B, C, D, E}
-tuple_impl!{A, B, C, D, E, F}
-tuple_impl!{A, B, C, D, E, F, G}
-tuple_impl!{A, B, C, D, E, F, G, H}
-tuple_impl!{A, B, C, D, E, F, G, H, I}
-tuple_impl!{A, B, C, D, E, F, G, H, I, J}
-tuple_impl!{A, B, C, D, E, F, G, H, I, J, K}
-tuple_impl!{A, B, C, D, E, F, G, H, I, J, K, L}
-
-impl<A: ToJson> ToJson for [A] {
-    fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) }
-}
-
-impl<A: ToJson> ToJson for Vec<A> {
-    fn to_json(&self) -> Json { Json::Array(self.iter().map(|elt| elt.to_json()).collect()) }
-}
-
-impl<A: ToJson> ToJson for BTreeMap<string::String, A> {
-    fn to_json(&self) -> Json {
-        let mut d = BTreeMap::new();
-        for (key, value) in self.iter() {
-            d.insert((*key).clone(), value.to_json());
-        }
-        Json::Object(d)
-    }
-}
-
-impl<A: ToJson> ToJson for HashMap<string::String, A> {
-    fn to_json(&self) -> Json {
-        let mut d = BTreeMap::new();
-        for (key, value) in self.iter() {
-            d.insert((*key).clone(), value.to_json());
-        }
-        Json::Object(d)
-    }
-}
-
-impl<A:ToJson> ToJson for Option<A> {
-    fn to_json(&self) -> Json {
-        match *self {
-            None => Json::Null,
-            Some(ref value) => value.to_json()
-        }
-    }
-}
-
-struct FormatShim<'a, 'b: 'a> {
-    inner: &'a mut fmt::Formatter<'b>,
-}
-
-impl<'a, 'b> fmt::Writer for FormatShim<'a, 'b> {
-    fn write_str(&mut self, s: &str) -> fmt::Result {
-        self.inner.write_str(s)
-    }
-}
-
-impl fmt::Show for Json {
-    /// Encodes a json value into a string
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let mut shim = FormatShim { inner: f };
-        let mut encoder = Encoder::new(&mut shim);
-        self.encode(&mut encoder)
-    }
-}
-
-impl<'a> fmt::Show for PrettyJson<'a> {
-    /// Encodes a json value into a string
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let mut shim = FormatShim { inner: f };
-        let mut encoder = PrettyEncoder::new(&mut shim);
-        self.inner.encode(&mut encoder)
-    }
-}
-
-impl<'a, T> fmt::Show for AsJson<'a, T>
-    where T: for<'b> Encodable<Encoder<'b>, fmt::Error>
-{
-    /// Encodes a json value into a string
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let mut shim = FormatShim { inner: f };
-        let mut encoder = Encoder::new(&mut shim);
-        self.inner.encode(&mut encoder)
-    }
-}
-
-impl<'a, T> AsPrettyJson<'a, T> {
-    /// Set the indentation level for the emitted JSON
-    pub fn indent(mut self, indent: uint) -> AsPrettyJson<'a, T> {
-        self.indent = Some(indent);
-        self
-    }
-}
-
-impl<'a, T> fmt::Show for AsPrettyJson<'a, T>
-    where T: for<'b> Encodable<PrettyEncoder<'b>, fmt::Error>
-{
-    /// Encodes a json value into a string
-    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        let mut shim = FormatShim { inner: f };
-        let mut encoder = PrettyEncoder::new(&mut shim);
-        match self.indent {
-            Some(n) => encoder.set_indent(n),
-            None => {}
-        }
-        self.inner.encode(&mut encoder)
-    }
-}
-
-impl FromStr for Json {
-    fn from_str(s: &str) -> Option<Json> {
-        from_str(s).ok()
-    }
-}
-
-#[cfg(test)]
-mod tests {
-    extern crate test;
-    use self::Animal::*;
-    use self::DecodeEnum::*;
-    use self::test::Bencher;
-    use {Encodable, Decodable};
-    use super::Json::*;
-    use super::ErrorCode::*;
-    use super::ParserError::*;
-    use super::DecoderError::*;
-    use super::JsonEvent::*;
-    use super::StackElement::*;
-    use super::{Json, from_str, DecodeResult, DecoderError, JsonEvent, Parser,
-                StackElement, Stack, Decoder};
-    use std::{i64, u64, f32, f64};
-    use std::collections::BTreeMap;
-    use std::num::Float;
-    use std::string;
-
-    #[derive(RustcDecodable, Eq, PartialEq, Show)]
-    struct OptionData {
-        opt: Option<uint>,
-    }
-
-    #[test]
-    fn test_decode_option_none() {
-        let s ="{}";
-        let obj: OptionData = super::decode(s).unwrap();
-        assert_eq!(obj, OptionData { opt: None });
-    }
-
-    #[test]
-    fn test_decode_option_some() {
-        let s = "{ \"opt\": 10 }";
-        let obj: OptionData = super::decode(s).unwrap();
-        assert_eq!(obj, OptionData { opt: Some(10u) });
-    }
-
-    #[test]
-    fn test_decode_option_malformed() {
-        check_err::<OptionData>("{ \"opt\": [] }",
-                                ExpectedError("Number".to_string(), "[]".to_string()));
-        check_err::<OptionData>("{ \"opt\": false }",
-                                ExpectedError("Number".to_string(), "false".to_string()));
-    }
-
-    #[derive(PartialEq, RustcEncodable, RustcDecodable, Show)]
-    enum Animal {
-        Dog,
-        Frog(string::String, int)
-    }
-
-    #[derive(PartialEq, RustcEncodable, RustcDecodable, Show)]
-    struct Inner {
-        a: (),
-        b: uint,
-        c: Vec<string::String>,
-    }
-
-    #[derive(PartialEq, RustcEncodable, RustcDecodable, Show)]
-    struct Outer {
-        inner: Vec<Inner>,
-    }
-
-    fn mk_object(items: &[(string::String, Json)]) -> Json {
-        let mut d = BTreeMap::new();
-
-        for item in items.iter() {
-            match *item {
-                (ref key, ref value) => { d.insert((*key).clone(), (*value).clone()); },
-            }
-        };
-
-        Object(d)
-    }
-
-    #[test]
-    fn test_from_str_trait() {
-        let s = "null";
-        assert!(s.parse::<Json>().unwrap() == s.parse().unwrap());
-    }
-
-    #[test]
-    fn test_write_null() {
-        assert_eq!(Null.to_string(), "null");
-        assert_eq!(Null.pretty().to_string(), "null");
-    }
-
-    #[test]
-    fn test_write_i64() {
-        assert_eq!(U64(0).to_string(), "0");
-        assert_eq!(U64(0).pretty().to_string(), "0");
-
-        assert_eq!(U64(1234).to_string(), "1234");
-        assert_eq!(U64(1234).pretty().to_string(), "1234");
-
-        assert_eq!(I64(-5678).to_string(), "-5678");
-        assert_eq!(I64(-5678).pretty().to_string(), "-5678");
-
-        assert_eq!(U64(7650007200025252000).to_string(), "7650007200025252000");
-        assert_eq!(U64(7650007200025252000).pretty().to_string(), "7650007200025252000");
-    }
-
-    #[test]
-    fn test_write_f64() {
-        assert_eq!(F64(3.0).to_string(), "3.0");
-        assert_eq!(F64(3.0).pretty().to_string(), "3.0");
-
-        assert_eq!(F64(3.1).to_string(), "3.1");
-        assert_eq!(F64(3.1).pretty().to_string(), "3.1");
-
-        assert_eq!(F64(-1.5).to_string(), "-1.5");
-        assert_eq!(F64(-1.5).pretty().to_string(), "-1.5");
-
-        assert_eq!(F64(0.5).to_string(), "0.5");
-        assert_eq!(F64(0.5).pretty().to_string(), "0.5");
-
-        assert_eq!(F64(f64::NAN).to_string(), "null");
-        assert_eq!(F64(f64::NAN).pretty().to_string(), "null");
-
-        assert_eq!(F64(f64::INFINITY).to_string(), "null");
-        assert_eq!(F64(f64::INFINITY).pretty().to_string(), "null");
-
-        assert_eq!(F64(f64::NEG_INFINITY).to_string(), "null");
-        assert_eq!(F64(f64::NEG_INFINITY).pretty().to_string(), "null");
-    }
-
-    #[test]
-    fn test_write_str() {
-        assert_eq!(String("".to_string()).to_string(), "\"\"");
-        assert_eq!(String("".to_string()).pretty().to_string(), "\"\"");
-
-        assert_eq!(String("homura".to_string()).to_string(), "\"homura\"");
-        assert_eq!(String("madoka".to_string()).pretty().to_string(), "\"madoka\"");
-    }
-
-    #[test]
-    fn test_write_bool() {
-        assert_eq!(Boolean(true).to_string(), "true");
-        assert_eq!(Boolean(true).pretty().to_string(), "true");
-
-        assert_eq!(Boolean(false).to_string(), "false");
-        assert_eq!(Boolean(false).pretty().to_string(), "false");
-    }
-
-    #[test]
-    fn test_write_array() {
-        assert_eq!(Array(vec![]).to_string(), "[]");
-        assert_eq!(Array(vec![]).pretty().to_string(), "[]");
-
-        assert_eq!(Array(vec![Boolean(true)]).to_string(), "[true]");
-        assert_eq!(
-            Array(vec![Boolean(true)]).pretty().to_string(),
-            "\
-            [\n  \
-                true\n\
-            ]"
-        );
-
-        let long_test_array = Array(vec![
-            Boolean(false),
-            Null,
-            Array(vec![String("foo\nbar".to_string()), F64(3.5)])]);
-
-        assert_eq!(long_test_array.to_string(),
-            "[false,null,[\"foo\\nbar\",3.5]]");
-        assert_eq!(
-            long_test_array.pretty().to_string(),
-            "\
-            [\n  \
-                false,\n  \
-                null,\n  \
-                [\n    \
-                    \"foo\\nbar\",\n    \
-                    3.5\n  \
-                ]\n\
-            ]"
-        );
-    }
-
-    #[test]
-    fn test_write_object() {
-        assert_eq!(mk_object(&[]).to_string(), "{}");
-        assert_eq!(mk_object(&[]).pretty().to_string(), "{}");
-
-        assert_eq!(
-            mk_object(&[
-                ("a".to_string(), Boolean(true))
-            ]).to_string(),
-            "{\"a\":true}"
-        );
-        assert_eq!(
-            mk_object(&[("a".to_string(), Boolean(true))]).pretty().to_string(),
-            "\
-            {\n  \
-                \"a\": true\n\
-            }"
-        );
-
-        let complex_obj = mk_object(&[
-                ("b".to_string(), Array(vec![
-                    mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]),
-                    mk_object(&[("d".to_string(), String("".to_string()))])
-                ]))
-            ]);
-
-        assert_eq!(
-            complex_obj.to_string(),
-            "{\
-                \"b\":[\
-                    {\"c\":\"\\f\\r\"},\
-                    {\"d\":\"\"}\
-                ]\
-            }"
-        );
-        assert_eq!(
-            complex_obj.pretty().to_string(),
-            "\
-            {\n  \
-                \"b\": [\n    \
-                    {\n      \
-                        \"c\": \"\\f\\r\"\n    \
-                    },\n    \
-                    {\n      \
-                        \"d\": \"\"\n    \
-                    }\n  \
-                ]\n\
-            }"
-        );
-
-        let a = mk_object(&[
-            ("a".to_string(), Boolean(true)),
-            ("b".to_string(), Array(vec![
-                mk_object(&[("c".to_string(), String("\x0c\r".to_string()))]),
-                mk_object(&[("d".to_string(), String("".to_string()))])
-            ]))
-        ]);
-
-        // We can't compare the strings directly because the object fields be
-        // printed in a different order.
-        assert_eq!(a.clone(), a.to_string().parse().unwrap());
-        assert_eq!(a.clone(), a.pretty().to_string().parse().unwrap());
-    }
-
-    #[test]
-    fn test_write_enum() {
-        let animal = Dog;
-        assert_eq!(
-            format!("{}", super::as_json(&animal)),
-            "\"Dog\""
-        );
-        assert_eq!(
-            format!("{}", super::as_pretty_json(&animal)),
-            "\"Dog\""
-        );
-
-        let animal = Frog("Henry".to_string(), 349);
-        assert_eq!(
-            format!("{}", super::as_json(&animal)),
-            "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}"
-        );
-        assert_eq!(
-            format!("{}", super::as_pretty_json(&animal)),
-            "{\n  \
-               \"variant\": \"Frog\",\n  \
-               \"fields\": [\n    \
-                 \"Henry\",\n    \
-                 349\n  \
-               ]\n\
-             }"
-        );
-    }
-
-    macro_rules! check_encoder_for_simple {
-        ($value:expr, $expected:expr) => ({
-            let s = format!("{}", super::as_json(&$value));
-            assert_eq!(s, $expected);
-
-            let s = format!("{}", super::as_pretty_json(&$value));
-            assert_eq!(s, $expected);
-        })
-    }
-
-    #[test]
-    fn test_write_some() {
-        check_encoder_for_simple!(Some("jodhpurs".to_string()), "\"jodhpurs\"");
-    }
-
-    #[test]
-    fn test_write_none() {
-        check_encoder_for_simple!(None::<string::String>, "null");
-    }
-
-    #[test]
-    fn test_write_char() {
-        check_encoder_for_simple!('a', "\"a\"");
-        check_encoder_for_simple!('\t', "\"\\t\"");
-        check_encoder_for_simple!('\u{0000}', "\"\\u0000\"");
-        check_encoder_for_simple!('\u{001b}', "\"\\u001b\"");
-        check_encoder_for_simple!('\u{007f}', "\"\\u007f\"");
-        check_encoder_for_simple!('\u{00a0}', "\"\u{00a0}\"");
-        check_encoder_for_simple!('\u{abcd}', "\"\u{abcd}\"");
-        check_encoder_for_simple!('\u{10ffff}', "\"\u{10ffff}\"");
-    }
-
-    #[test]
-    fn test_trailing_characters() {
-        assert_eq!(from_str("nulla"),  Err(SyntaxError(TrailingCharacters, 1, 5)));
-        assert_eq!(from_str("truea"),  Err(SyntaxError(TrailingCharacters, 1, 5)));
-        assert_eq!(from_str("falsea"), Err(SyntaxError(TrailingCharacters, 1, 6)));
-        assert_eq!(from_str("1a"),     Err(SyntaxError(TrailingCharacters, 1, 2)));
-        assert_eq!(from_str("[]a"),    Err(SyntaxError(TrailingCharacters, 1, 3)));
-        assert_eq!(from_str("{}a"),    Err(SyntaxError(TrailingCharacters, 1, 3)));
-    }
-
-    #[test]
-    fn test_read_identifiers() {
-        assert_eq!(from_str("n"),    Err(SyntaxError(InvalidSyntax, 1, 2)));
-        assert_eq!(from_str("nul"),  Err(SyntaxError(InvalidSyntax, 1, 4)));
-        assert_eq!(from_str("t"),    Err(SyntaxError(InvalidSyntax, 1, 2)));
-        assert_eq!(from_str("truz"), Err(SyntaxError(InvalidSyntax, 1, 4)));
-        assert_eq!(from_str("f"),    Err(SyntaxError(InvalidSyntax, 1, 2)));
-        assert_eq!(from_str("faz"),  Err(SyntaxError(InvalidSyntax, 1, 3)));
-
-        assert_eq!(from_str("null"), Ok(Null));
-        assert_eq!(from_str("true"), Ok(Boolean(true)));
-        assert_eq!(from_str("false"), Ok(Boolean(false)));
-        assert_eq!(from_str(" null "), Ok(Null));
-        assert_eq!(from_str(" true "), Ok(Boolean(true)));
-        assert_eq!(from_str(" false "), Ok(Boolean(false)));
-    }
-
-    #[test]
-    fn test_decode_identifiers() {
-        let v: () = super::decode("null").unwrap();
-        assert_eq!(v, ());
-
-        let v: bool = super::decode("true").unwrap();
-        assert_eq!(v, true);
-
-        let v: bool = super::decode("false").unwrap();
-        assert_eq!(v, false);
-    }
-
-    #[test]
-    fn test_read_number() {
-        assert_eq!(from_str("+"),   Err(SyntaxError(InvalidSyntax, 1, 1)));
-        assert_eq!(from_str("."),   Err(SyntaxError(InvalidSyntax, 1, 1)));
-        assert_eq!(from_str("NaN"), Err(SyntaxError(InvalidSyntax, 1, 1)));
-        assert_eq!(from_str("-"),   Err(SyntaxError(InvalidNumber, 1, 2)));
-        assert_eq!(from_str("00"),  Err(SyntaxError(InvalidNumber, 1, 2)));
-        assert_eq!(from_str("1."),  Err(SyntaxError(InvalidNumber, 1, 3)));
-        assert_eq!(from_str("1e"),  Err(SyntaxError(InvalidNumber, 1, 3)));
-        assert_eq!(from_str("1e+"), Err(SyntaxError(InvalidNumber, 1, 4)));
-
-        assert_eq!(from_str("18446744073709551616"), Err(SyntaxError(InvalidNumber, 1, 20)));
-        assert_eq!(from_str("-9223372036854775809"), Err(SyntaxError(InvalidNumber, 1, 21)));
-
-        assert_eq!(from_str("3"), Ok(U64(3)));
-        assert_eq!(from_str("3.1"), Ok(F64(3.1)));
-        assert_eq!(from_str("-1.2"), Ok(F64(-1.2)));
-        assert_eq!(from_str("0.4"), Ok(F64(0.4)));
-        assert_eq!(from_str("0.4e5"), Ok(F64(0.4e5)));
-        assert_eq!(from_str("0.4e+15"), Ok(F64(0.4e15)));
-        assert_eq!(from_str("0.4e-01"), Ok(F64(0.4e-01)));
-        assert_eq!(from_str(" 3 "), Ok(U64(3)));
-
-        assert_eq!(from_str("-9223372036854775808"), Ok(I64(i64::MIN)));
-        assert_eq!(from_str("9223372036854775807"), Ok(U64(i64::MAX as u64)));
-        assert_eq!(from_str("18446744073709551615"), Ok(U64(u64::MAX)));
-    }
-
-    #[test]
-    fn test_decode_numbers() {
-        let v: f64 = super::decode("3").unwrap();
-        assert_eq!(v, 3.0);
-
-        let v: f64 = super::decode("3.1").unwrap();
-        assert_eq!(v, 3.1);
-
-        let v: f64 = super::decode("-1.2").unwrap();
-        assert_eq!(v, -1.2);
-
-        let v: f64 = super::decode("0.4").unwrap();
-        assert_eq!(v, 0.4);
-
-        let v: f64 = super::decode("0.4e5").unwrap();
-        assert_eq!(v, 0.4e5);
-
-        let v: f64 = super::decode("0.4e15").unwrap();
-        assert_eq!(v, 0.4e15);
-
-        let v: f64 = super::decode("0.4e-01").unwrap();
-        assert_eq!(v, 0.4e-01);
-
-        let v: u64 = super::decode("0").unwrap();
-        assert_eq!(v, 0);
-
-        let v: u64 = super::decode("18446744073709551615").unwrap();
-        assert_eq!(v, u64::MAX);
-
-        let v: i64 = super::decode("-9223372036854775808").unwrap();
-        assert_eq!(v, i64::MIN);
-
-        let v: i64 = super::decode("9223372036854775807").unwrap();
-        assert_eq!(v, i64::MAX);
-
-        let res: DecodeResult<i64> = super::decode("765.25252");
-        assert_eq!(res, Err(ExpectedError("Integer".to_string(), "765.25252".to_string())));
-    }
-
-    #[test]
-    fn test_read_str() {
-        assert_eq!(from_str("\""),    Err(SyntaxError(EOFWhileParsingString, 1, 2)));
-        assert_eq!(from_str("\"lol"), Err(SyntaxError(EOFWhileParsingString, 1, 5)));
-
-        assert_eq!(from_str("\"\""), Ok(String("".to_string())));
-        assert_eq!(from_str("\"foo\""), Ok(String("foo".to_string())));
-        assert_eq!(from_str("\"\\\"\""), Ok(String("\"".to_string())));
-        assert_eq!(from_str("\"\\b\""), Ok(String("\x08".to_string())));
-        assert_eq!(from_str("\"\\n\""), Ok(String("\n".to_string())));
-        assert_eq!(from_str("\"\\r\""), Ok(String("\r".to_string())));
-        assert_eq!(from_str("\"\\t\""), Ok(String("\t".to_string())));
-        assert_eq!(from_str(" \"foo\" "), Ok(String("foo".to_string())));
-        assert_eq!(from_str("\"\\u12ab\""), Ok(String("\u{12ab}".to_string())));
-        assert_eq!(from_str("\"\\uAB12\""), Ok(String("\u{AB12}".to_string())));
-    }
-
-    #[test]
-    fn test_decode_str() {
-        let s = [("\"\"", ""),
-                 ("\"foo\"", "foo"),
-                 ("\"\\\"\"", "\""),
-                 ("\"\\b\"", "\x08"),
-                 ("\"\\n\"", "\n"),
-                 ("\"\\r\"", "\r"),
-                 ("\"\\t\"", "\t"),
-                 ("\"\\u12ab\"", "\u{12ab}"),
-                 ("\"\\uAB12\"", "\u{AB12}")];
-
-        for &(i, o) in s.iter() {
-            let v: string::String = super::decode(i).unwrap();
-            assert_eq!(v, o);
-        }
-    }
-
-    #[test]
-    fn test_read_array() {
-        assert_eq!(from_str("["),     Err(SyntaxError(EOFWhileParsingValue, 1, 2)));
-        assert_eq!(from_str("[1"),    Err(SyntaxError(EOFWhileParsingArray, 1, 3)));
-        assert_eq!(from_str("[1,"),   Err(SyntaxError(EOFWhileParsingValue, 1, 4)));
-        assert_eq!(from_str("[1,]"),  Err(SyntaxError(InvalidSyntax,        1, 4)));
-        assert_eq!(from_str("[6 7]"), Err(SyntaxError(InvalidSyntax,        1, 4)));
-
-        assert_eq!(from_str("[]"), Ok(Array(vec![])));
-        assert_eq!(from_str("[ ]"), Ok(Array(vec![])));
-        assert_eq!(from_str("[true]"), Ok(Array(vec![Boolean(true)])));
-        assert_eq!(from_str("[ false ]"), Ok(Array(vec![Boolean(false)])));
-        assert_eq!(from_str("[null]"), Ok(Array(vec![Null])));
-        assert_eq!(from_str("[3, 1]"),
-                     Ok(Array(vec![U64(3), U64(1)])));
-        assert_eq!(from_str("\n[3, 2]\n"),
-                     Ok(Array(vec![U64(3), U64(2)])));
-        assert_eq!(from_str("[2, [4, 1]]"),
-               Ok(Array(vec![U64(2), Array(vec![U64(4), U64(1)])])));
-    }
-
-    #[test]
-    fn test_decode_array() {
-        let v: Vec<()> = super::decode("[]").unwrap();
-        assert_eq!(v, vec![]);
-
-        let v: Vec<()> = super::decode("[null]").unwrap();
-        assert_eq!(v, vec![()]);
-
-        let v: Vec<bool> = super::decode("[true]").unwrap();
-        assert_eq!(v, vec![true]);
-
-        let v: Vec<int> = super::decode("[3, 1]").unwrap();
-        assert_eq!(v, vec![3, 1]);
-
-        let v: Vec<Vec<uint>> = super::decode("[[3], [1, 2]]").unwrap();
-        assert_eq!(v, vec![vec![3], vec![1, 2]]);
-    }
-
-    #[test]
-    fn test_decode_tuple() {
-        let t: (uint, uint, uint) = super::decode("[1, 2, 3]").unwrap();
-        assert_eq!(t, (1u, 2, 3));
-
-        let t: (uint, string::String) = super::decode("[1, \"two\"]").unwrap();
-        assert_eq!(t, (1u, "two".to_string()));
-    }
-
-    #[test]
-    fn test_decode_tuple_malformed_types() {
-        assert!(super::decode::<(uint, string::String)>("[1, 2]").is_err());
-    }
-
-    #[test]
-    fn test_decode_tuple_malformed_length() {
-        assert!(super::decode::<(uint, uint)>("[1, 2, 3]").is_err());
-    }
-
-    #[test]
-    fn test_read_object() {
-        assert_eq!(from_str("{"),       Err(SyntaxError(EOFWhileParsingObject, 1, 2)));
-        assert_eq!(from_str("{ "),      Err(SyntaxError(EOFWhileParsingObject, 1, 3)));
-        assert_eq!(from_str("{1"),      Err(SyntaxError(KeyMustBeAString,      1, 2)));
-        assert_eq!(from_str("{ \"a\""), Err(SyntaxError(EOFWhileParsingObject, 1, 6)));
-        assert_eq!(from_str("{\"a\""),  Err(SyntaxError(EOFWhileParsingObject, 1, 5)));
-        assert_eq!(from_str("{\"a\" "), Err(SyntaxError(EOFWhileParsingObject, 1, 6)));
-
-        assert_eq!(from_str("{\"a\" 1"),   Err(SyntaxError(ExpectedColon,         1, 6)));
-        assert_eq!(from_str("{\"a\":"),    Err(SyntaxError(EOFWhileParsingValue,  1, 6)));
-        assert_eq!(from_str("{\"a\":1"),   Err(SyntaxError(EOFWhileParsingObject, 1, 7)));
-        assert_eq!(from_str("{\"a\":1 1"), Err(SyntaxError(InvalidSyntax,         1, 8)));
-        assert_eq!(from_str("{\"a\":1,"),  Err(SyntaxError(EOFWhileParsingObject, 1, 8)));
-
-        assert_eq!(from_str("{}").unwrap(), mk_object(&[]));
-        assert_eq!(from_str("{\"a\": 3}").unwrap(),
-                  mk_object(&[("a".to_string(), U64(3))]));
-
-        assert_eq!(from_str(
-                      "{ \"a\": null, \"b\" : true }").unwrap(),
-                  mk_object(&[
-                      ("a".to_string(), Null),
-                      ("b".to_string(), Boolean(true))]));
-        assert_eq!(from_str("\n{ \"a\": null, \"b\" : true }\n").unwrap(),
-                  mk_object(&[
-                      ("a".to_string(), Null),
-                      ("b".to_string(), Boolean(true))]));
-        assert_eq!(from_str(
-                      "{\"a\" : 1.0 ,\"b\": [ true ]}").unwrap(),
-                  mk_object(&[
-                      ("a".to_string(), F64(1.0)),
-                      ("b".to_string(), Array(vec![Boolean(true)]))
-                  ]));
-        assert_eq!(from_str(
-                      "{\
-                          \"a\": 1.0, \
-                          \"b\": [\
-                              true,\
-                              \"foo\\nbar\", \
-                              { \"c\": {\"d\": null} } \
-                          ]\
-                      }").unwrap(),
-                  mk_object(&[
-                      ("a".to_string(), F64(1.0)),
-                      ("b".to_string(), Array(vec![
-                          Boolean(true),
-                          String("foo\nbar".to_string()),
-                          mk_object(&[
-                              ("c".to_string(), mk_object(&[("d".to_string(), Null)]))
-                          ])
-                      ]))
-                  ]));
-    }
-
-    #[test]
-    fn test_decode_struct() {
-        let s = "{
-            \"inner\": [
-                { \"a\": null, \"b\": 2, \"c\": [\"abc\", \"xyz\"] }
-            ]
-        }";
-
-        let v: Outer = super::decode(s).unwrap();
-        assert_eq!(
-            v,
-            Outer {
-                inner: vec![
-                    Inner { a: (), b: 2, c: vec!["abc".to_string(), "xyz".to_string()] }
-                ]
-            }
-        );
-    }
-
-    #[derive(RustcDecodable)]
-    struct FloatStruct {
-        f: f64,
-        a: Vec<f64>
-    }
-    #[test]
-    fn test_decode_struct_with_nan() {
-        let s = "{\"f\":null,\"a\":[null,123]}";
-        let obj: FloatStruct = super::decode(s).unwrap();
-        assert!(obj.f.is_nan());
-        assert!(obj.a[0].is_nan());
-        assert_eq!(obj.a[1], 123f64);
-    }
-
-    #[test]
-    fn test_decode_option() {
-        let value: Option<string::String> = super::decode("null").unwrap();
-        assert_eq!(value, None);
-
-        let value: Option<string::String> = super::decode("\"jodhpurs\"").unwrap();
-        assert_eq!(value, Some("jodhpurs".to_string()));
-    }
-
-    #[test]
-    fn test_decode_enum() {
-        let value: Animal = super::decode("\"Dog\"").unwrap();
-        assert_eq!(value, Dog);
-
-        let s = "{\"variant\":\"Frog\",\"fields\":[\"Henry\",349]}";
-        let value: Animal = super::decode(s).unwrap();
-        assert_eq!(value, Frog("Henry".to_string(), 349));
-    }
-
-    #[test]
-    fn test_decode_map() {
-        let s = "{\"a\": \"Dog\", \"b\": {\"variant\":\"Frog\",\
-                  \"fields\":[\"Henry\", 349]}}";
-        let mut map: BTreeMap<string::String, Animal> = super::decode(s).unwrap();
-
-        assert_eq!(map.remove(&"a".to_string()), Some(Dog));
-        assert_eq!(map.remove(&"b".to_string()), Some(Frog("Henry".to_string(), 349)));
-    }
-
-    #[test]
-    fn test_multiline_errors() {
-        assert_eq!(from_str("{\n  \"foo\":\n \"bar\""),
-            Err(SyntaxError(EOFWhileParsingObject, 3u, 8u)));
-    }
-
-    #[derive(RustcDecodable)]
-    #[allow(dead_code)]
-    struct DecodeStruct {
-        x: f64,
-        y: bool,
-        z: string::String,
-        w: Vec<DecodeStruct>
-    }
-    #[derive(RustcDecodable)]
-    enum DecodeEnum {
-        A(f64),
-        B(string::String)
-    }
-    fn check_err<T: Decodable<Decoder, DecoderError>>(to_parse: &'static str,
-                                                      expected: DecoderError) {
-        let res: DecodeResult<T> = match from_str(to_parse) {
-            Err(e) => Err(ParseError(e)),
-            Ok(json) => Decodable::decode(&mut Decoder::new(json))
-        };
-        match res {
-            Ok(_) => panic!("`{}` parsed & decoded ok, expecting error `{}`",
-                              to_parse, expected),
-            Err(ParseError(e)) => panic!("`{}` is not valid json: {}",
-                                           to_parse, e),
-            Err(e) => {
-                assert_eq!(e, expected);
-            }
-        }
-    }
-    #[test]
-    fn test_decode_errors_struct() {
-        check_err::<DecodeStruct>("[]", ExpectedError("Object".to_string(), "[]".to_string()));
-        check_err::<DecodeStruct>("{\"x\": true, \"y\": true, \"z\": \"\", \"w\": []}",
-                                  ExpectedError("Number".to_string(), "true".to_string()));
-        check_err::<DecodeStruct>("{\"x\": 1, \"y\": [], \"z\": \"\", \"w\": []}",
-                                  ExpectedError("Boolean".to_string(), "[]".to_string()));
-        check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": {}, \"w\": []}",
-                                  ExpectedError("String".to_string(), "{}".to_string()));
-        check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": \"\", \"w\": null}",
-                                  ExpectedError("Array".to_string(), "null".to_string()));
-        check_err::<DecodeStruct>("{\"x\": 1, \"y\": true, \"z\": \"\"}",
-                                  MissingFieldError("w".to_string()));
-    }
-    #[test]
-    fn test_decode_errors_enum() {
-        check_err::<DecodeEnum>("{}",
-                                MissingFieldError("variant".to_string()));
-        check_err::<DecodeEnum>("{\"variant\": 1}",
-                                ExpectedError("String".to_string(), "1".to_string()));
-        check_err::<DecodeEnum>("{\"variant\": \"A\"}",
-                                MissingFieldError("fields".to_string()));
-        check_err::<DecodeEnum>("{\"variant\": \"A\", \"fields\": null}",
-                                ExpectedError("Array".to_string(), "null".to_string()));
-        check_err::<DecodeEnum>("{\"variant\": \"C\", \"fields\": []}",
-                                UnknownVariantError("C".to_string()));
-    }
-
-    #[test]
-    fn test_find(){
-        let json_value = from_str("{\"dog\" : \"cat\"}").unwrap();
-        let found_str = json_value.find("dog");
-        assert!(found_str.unwrap().as_string().unwrap() == "cat");
-    }
-
-    #[test]
-    fn test_find_path(){
-        let json_value = from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap();
-        let found_str = json_value.find_path(&["dog", "cat", "mouse"]);
-        assert!(found_str.unwrap().as_string().unwrap() == "cheese");
-    }
-
-    #[test]
-    fn test_search(){
-        let json_value = from_str("{\"dog\":{\"cat\": {\"mouse\" : \"cheese\"}}}").unwrap();
-        let found_str = json_value.search("mouse").and_then(|j| j.as_string());
-        assert!(found_str.unwrap() == "cheese");
-    }
-
-    #[test]
-    fn test_index(){
-        let json_value = from_str("{\"animals\":[\"dog\",\"cat\",\"mouse\"]}").unwrap();
-        let ref array = json_value["animals"];
-        assert_eq!(array[0].as_string().unwrap(), "dog");
-        assert_eq!(array[1].as_string().unwrap(), "cat");
-        assert_eq!(array[2].as_string().unwrap(), "mouse");
-    }
-
-    #[test]
-    fn test_is_object(){
-        let json_value = from_str("{}").unwrap();
-        assert!(json_value.is_object());
-    }
-
-    #[test]
-    fn test_as_object(){
-        let json_value = from_str("{}").unwrap();
-        let json_object = json_value.as_object();
-        assert!(json_object.is_some());
-    }
-
-    #[test]
-    fn test_is_array(){
-        let json_value = from_str("[1, 2, 3]").unwrap();
-        assert!(json_value.is_array());
-    }
-
-    #[test]
-    fn test_as_array(){
-        let json_value = from_str("[1, 2, 3]").unwrap();
-        let json_array = json_value.as_array();
-        let expected_length = 3;
-        assert!(json_array.is_some() && json_array.unwrap().len() == expected_length);
-    }
-
-    #[test]
-    fn test_is_string(){
-        let json_value = from_str("\"dog\"").unwrap();
-        assert!(json_value.is_string());
-    }
-
-    #[test]
-    fn test_as_string(){
-        let json_value = from_str("\"dog\"").unwrap();
-        let json_str = json_value.as_string();
-        let expected_str = "dog";
-        assert_eq!(json_str, Some(expected_str));
-    }
-
-    #[test]
-    fn test_is_number(){
-        let json_value = from_str("12").unwrap();
-        assert!(json_value.is_number());
-    }
-
-    #[test]
-    fn test_is_i64(){
-        let json_value = from_str("-12").unwrap();
-        assert!(json_value.is_i64());
-
-        let json_value = from_str("12").unwrap();
-        assert!(!json_value.is_i64());
-
-        let json_value = from_str("12.0").unwrap();
-        assert!(!json_value.is_i64());
-    }
-
-    #[test]
-    fn test_is_u64(){
-        let json_value = from_str("12").unwrap();
-        assert!(json_value.is_u64());
-
-        let json_value = from_str("-12").unwrap();
-        assert!(!json_value.is_u64());
-
-        let json_value = from_str("12.0").unwrap();
-        assert!(!json_value.is_u64());
-    }
-
-    #[test]
-    fn test_is_f64(){
-        let json_value = from_str("12").unwrap();
-        assert!(!json_value.is_f64());
-
-        let json_value = from_str("-12").unwrap();
-        assert!(!json_value.is_f64());
-
-        let json_value = from_str("12.0").unwrap();
-        assert!(json_value.is_f64());
-
-        let json_value = from_str("-12.0").unwrap();
-        assert!(json_value.is_f64());
-    }
-
-    #[test]
-    fn test_as_i64(){
-        let json_value = from_str("-12").unwrap();
-        let json_num = json_value.as_i64();
-        assert_eq!(json_num, Some(-12));
-    }
-
-    #[test]
-    fn test_as_u64(){
-        let json_value = from_str("12").unwrap();
-        let json_num = json_value.as_u64();
-        assert_eq!(json_num, Some(12));
-    }
-
-    #[test]
-    fn test_as_f64(){
-        let json_value = from_str("12.0").unwrap();
-        let json_num = json_value.as_f64();
-        assert_eq!(json_num, Some(12f64));
-    }
-
-    #[test]
-    fn test_is_boolean(){
-        let json_value = from_str("false").unwrap();
-        assert!(json_value.is_boolean());
-    }
-
-    #[test]
-    fn test_as_boolean(){
-        let json_value = from_str("false").unwrap();
-        let json_bool = json_value.as_boolean();
-        let expected_bool = false;
-        assert!(json_bool.is_some() && json_bool.unwrap() == expected_bool);
-    }
-
-    #[test]
-    fn test_is_null(){
-        let json_value = from_str("null").unwrap();
-        assert!(json_value.is_null());
-    }
-
-    #[test]
-    fn test_as_null(){
-        let json_value = from_str("null").unwrap();
-        let json_null = json_value.as_null();
-        let expected_null = ();
-        assert!(json_null.is_some() && json_null.unwrap() == expected_null);
-    }
-
-    #[test]
-    fn test_encode_hashmap_with_numeric_key() {
-        use std::str::from_utf8;
-        use std::io::Writer;
-        use std::collections::HashMap;
-        let mut hm: HashMap<uint, bool> = HashMap::new();
-        hm.insert(1, true);
-        let mut mem_buf = Vec::new();
-        write!(&mut mem_buf, "{}", super::as_pretty_json(&hm)).unwrap();
-        let json_str = from_utf8(mem_buf[]).unwrap();
-        match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
-            _ => {} // it parsed and we are good to go
-        }
-    }
-
-    #[test]
-    fn test_prettyencode_hashmap_with_numeric_key() {
-        use std::str::from_utf8;
-        use std::io::Writer;
-        use std::collections::HashMap;
-        let mut hm: HashMap<uint, bool> = HashMap::new();
-        hm.insert(1, true);
-        let mut mem_buf = Vec::new();
-        write!(&mut mem_buf, "{}", super::as_pretty_json(&hm)).unwrap();
-        let json_str = from_utf8(mem_buf[]).unwrap();
-        match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
-            _ => {} // it parsed and we are good to go
-        }
-    }
-
-    #[test]
-    fn test_prettyencoder_indent_level_param() {
-        use std::str::from_utf8;
-        use std::collections::BTreeMap;
-
-        let mut tree = BTreeMap::new();
-
-        tree.insert("hello".to_string(), String("guten tag".to_string()));
-        tree.insert("goodbye".to_string(), String("sayonara".to_string()));
-
-        let json = Array(
-            // The following layout below should look a lot like
-            // the pretty-printed JSON (indent * x)
-            vec!
-            ( // 0x
-                String("greetings".to_string()), // 1x
-                Object(tree), // 1x + 2x + 2x + 1x
-            ) // 0x
-            // End JSON array (7 lines)
-        );
-
-        // Helper function for counting indents
-        fn indents(source: &str) -> uint {
-            let trimmed = source.trim_left_matches(' ');
-            source.len() - trimmed.len()
-        }
-
-        // Test up to 4 spaces of indents (more?)
-        for i in range(0, 4u) {
-            let mut writer = Vec::new();
-            write!(&mut writer, "{}",
-                   super::as_pretty_json(&json).indent(i)).unwrap();
-
-            let printed = from_utf8(writer[]).unwrap();
-
-            // Check for indents at each line
-            let lines: Vec<&str> = printed.lines().collect();
-            assert_eq!(lines.len(), 7); // JSON should be 7 lines
-
-            assert_eq!(indents(lines[0]), 0 * i); // [
-            assert_eq!(indents(lines[1]), 1 * i); //   "greetings",
-            assert_eq!(indents(lines[2]), 1 * i); //   {
-            assert_eq!(indents(lines[3]), 2 * i); //     "hello": "guten tag",
-            assert_eq!(indents(lines[4]), 2 * i); //     "goodbye": "sayonara"
-            assert_eq!(indents(lines[5]), 1 * i); //   },
-            assert_eq!(indents(lines[6]), 0 * i); // ]
-
-            // Finally, test that the pretty-printed JSON is valid
-            from_str(printed).ok().expect("Pretty-printed JSON is invalid!");
-        }
-    }
-
-    #[test]
-    fn test_hashmap_with_numeric_key_can_handle_double_quote_delimited_key() {
-        use std::collections::HashMap;
-        use Decodable;
-        let json_str = "{\"1\":true}";
-        let json_obj = match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
-            Ok(o) => o
-        };
-        let mut decoder = Decoder::new(json_obj);
-        let _hm: HashMap<uint, bool> = Decodable::decode(&mut decoder).unwrap();
-    }
-
-    #[test]
-    fn test_hashmap_with_numeric_key_will_error_with_string_keys() {
-        use std::collections::HashMap;
-        use Decodable;
-        let json_str = "{\"a\":true}";
-        let json_obj = match from_str(json_str) {
-            Err(_) => panic!("Unable to parse json_str: {}", json_str),
-            Ok(o) => o
-        };
-        let mut decoder = Decoder::new(json_obj);
-        let result: Result<HashMap<uint, bool>, DecoderError> = Decodable::decode(&mut decoder);
-        assert_eq!(result, Err(ExpectedError("Number".to_string(), "a".to_string())));
-    }
-
-    fn assert_stream_equal(src: &str,
-                           expected: Vec<(JsonEvent, Vec<StackElement>)>) {
-        let mut parser = Parser::new(src.chars());
-        let mut i = 0;
-        loop {
-            let evt = match parser.next() {
-                Some(e) => e,
-                None => { break; }
-            };
-            let (ref expected_evt, ref expected_stack) = expected[i];
-            if !parser.stack().is_equal_to(expected_stack.as_slice()) {
-                panic!("Parser stack is not equal to {}", expected_stack);
-            }
-            assert_eq!(&evt, expected_evt);
-            i+=1;
-        }
-    }
-    #[test]
-    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
-    fn test_streaming_parser() {
-        assert_stream_equal(
-            r#"{ "foo":"bar", "array" : [0, 1, 2, 3, 4, 5], "idents":[null,true,false]}"#,
-            vec![
-                (ObjectStart,             vec![]),
-                  (StringValue("bar".to_string()),   vec![Key("foo")]),
-                  (ArrayStart,            vec![Key("array")]),
-                    (U64Value(0),         vec![Key("array"), Index(0)]),
-                    (U64Value(1),         vec![Key("array"), Index(1)]),
-                    (U64Value(2),         vec![Key("array"), Index(2)]),
-                    (U64Value(3),         vec![Key("array"), Index(3)]),
-                    (U64Value(4),         vec![Key("array"), Index(4)]),
-                    (U64Value(5),         vec![Key("array"), Index(5)]),
-                  (ArrayEnd,              vec![Key("array")]),
-                  (ArrayStart,            vec![Key("idents")]),
-                    (NullValue,           vec![Key("idents"), Index(0)]),
-                    (BooleanValue(true),  vec![Key("idents"), Index(1)]),
-                    (BooleanValue(false), vec![Key("idents"), Index(2)]),
-                  (ArrayEnd,              vec![Key("idents")]),
-                (ObjectEnd,               vec![]),
-            ]
-        );
-    }
-    fn last_event(src: &str) -> JsonEvent {
-        let mut parser = Parser::new(src.chars());
-        let mut evt = NullValue;
-        loop {
-            evt = match parser.next() {
-                Some(e) => e,
-                None => return evt,
-            }
-        }
-    }
-
-    #[test]
-    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
-    fn test_read_object_streaming() {
-        assert_eq!(last_event("{ "),      Error(SyntaxError(EOFWhileParsingObject, 1, 3)));
-        assert_eq!(last_event("{1"),      Error(SyntaxError(KeyMustBeAString,      1, 2)));
-        assert_eq!(last_event("{ \"a\""), Error(SyntaxError(EOFWhileParsingObject, 1, 6)));
-        assert_eq!(last_event("{\"a\""),  Error(SyntaxError(EOFWhileParsingObject, 1, 5)));
-        assert_eq!(last_event("{\"a\" "), Error(SyntaxError(EOFWhileParsingObject, 1, 6)));
-
-        assert_eq!(last_event("{\"a\" 1"),   Error(SyntaxError(ExpectedColon,         1, 6)));
-        assert_eq!(last_event("{\"a\":"),    Error(SyntaxError(EOFWhileParsingValue,  1, 6)));
-        assert_eq!(last_event("{\"a\":1"),   Error(SyntaxError(EOFWhileParsingObject, 1, 7)));
-        assert_eq!(last_event("{\"a\":1 1"), Error(SyntaxError(InvalidSyntax,         1, 8)));
-        assert_eq!(last_event("{\"a\":1,"),  Error(SyntaxError(EOFWhileParsingObject, 1, 8)));
-        assert_eq!(last_event("{\"a\":1,}"), Error(SyntaxError(TrailingComma, 1, 8)));
-
-        assert_stream_equal(
-            "{}",
-            vec![(ObjectStart, vec![]), (ObjectEnd, vec![])]
-        );
-        assert_stream_equal(
-            "{\"a\": 3}",
-            vec![
-                (ObjectStart,        vec![]),
-                  (U64Value(3),      vec![Key("a")]),
-                (ObjectEnd,          vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "{ \"a\": null, \"b\" : true }",
-            vec![
-                (ObjectStart,           vec![]),
-                  (NullValue,           vec![Key("a")]),
-                  (BooleanValue(true),  vec![Key("b")]),
-                (ObjectEnd,             vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "{\"a\" : 1.0 ,\"b\": [ true ]}",
-            vec![
-                (ObjectStart,           vec![]),
-                  (F64Value(1.0),       vec![Key("a")]),
-                  (ArrayStart,          vec![Key("b")]),
-                    (BooleanValue(true),vec![Key("b"), Index(0)]),
-                  (ArrayEnd,            vec![Key("b")]),
-                (ObjectEnd,             vec![]),
-            ]
-        );
-        assert_stream_equal(
-            r#"{
-                "a": 1.0,
-                "b": [
-                    true,
-                    "foo\nbar",
-                    { "c": {"d": null} }
-                ]
-            }"#,
-            vec![
-                (ObjectStart,                   vec![]),
-                  (F64Value(1.0),               vec![Key("a")]),
-                  (ArrayStart,                  vec![Key("b")]),
-                    (BooleanValue(true),        vec![Key("b"), Index(0)]),
-                    (StringValue("foo\nbar".to_string()),  vec![Key("b"), Index(1)]),
-                    (ObjectStart,               vec![Key("b"), Index(2)]),
-                      (ObjectStart,             vec![Key("b"), Index(2), Key("c")]),
-                        (NullValue,             vec![Key("b"), Index(2), Key("c"), Key("d")]),
-                      (ObjectEnd,               vec![Key("b"), Index(2), Key("c")]),
-                    (ObjectEnd,                 vec![Key("b"), Index(2)]),
-                  (ArrayEnd,                    vec![Key("b")]),
-                (ObjectEnd,                     vec![]),
-            ]
-        );
-    }
-    #[test]
-    #[cfg_attr(target_word_size = "32", ignore)] // FIXME(#14064)
-    fn test_read_array_streaming() {
-        assert_stream_equal(
-            "[]",
-            vec![
-                (ArrayStart, vec![]),
-                (ArrayEnd,   vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "[ ]",
-            vec![
-                (ArrayStart, vec![]),
-                (ArrayEnd,   vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "[true]",
-            vec![
-                (ArrayStart,             vec![]),
-                    (BooleanValue(true), vec![Index(0)]),
-                (ArrayEnd,               vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "[ false ]",
-            vec![
-                (ArrayStart,              vec![]),
-                    (BooleanValue(false), vec![Index(0)]),
-                (ArrayEnd,                vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "[null]",
-            vec![
-                (ArrayStart,    vec![]),
-                    (NullValue, vec![Index(0)]),
-                (ArrayEnd,      vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "[3, 1]",
-            vec![
-                (ArrayStart,      vec![]),
-                    (U64Value(3), vec![Index(0)]),
-                    (U64Value(1), vec![Index(1)]),
-                (ArrayEnd,        vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "\n[3, 2]\n",
-            vec![
-                (ArrayStart,      vec![]),
-                    (U64Value(3), vec![Index(0)]),
-                    (U64Value(2), vec![Index(1)]),
-                (ArrayEnd,        vec![]),
-            ]
-        );
-        assert_stream_equal(
-            "[2, [4, 1]]",
-            vec![
-                (ArrayStart,           vec![]),
-                    (U64Value(2),      vec![Index(0)]),
-                    (ArrayStart,       vec![Index(1)]),
-                        (U64Value(4),  vec![Index(1), Index(0)]),
-                        (U64Value(1),  vec![Index(1), Index(1)]),
-                    (ArrayEnd,         vec![Index(1)]),
-                (ArrayEnd,             vec![]),
-            ]
-        );
-
-        assert_eq!(last_event("["), Error(SyntaxError(EOFWhileParsingValue, 1,  2)));
-
-        assert_eq!(from_str("["),     Err(SyntaxError(EOFWhileParsingValue, 1, 2)));
-        assert_eq!(from_str("[1"),    Err(SyntaxError(EOFWhileParsingArray, 1, 3)));
-        assert_eq!(from_str("[1,"),   Err(SyntaxError(EOFWhileParsingValue, 1, 4)));
-        assert_eq!(from_str("[1,]"),  Err(SyntaxError(InvalidSyntax,        1, 4)));
-        assert_eq!(from_str("[6 7]"), Err(SyntaxError(InvalidSyntax,        1, 4)));
-
-    }
-    #[test]
-    fn test_trailing_characters_streaming() {
-        assert_eq!(last_event("nulla"),  Error(SyntaxError(TrailingCharacters, 1, 5)));
-        assert_eq!(last_event("truea"),  Error(SyntaxError(TrailingCharacters, 1, 5)));
-        assert_eq!(last_event("falsea"), Error(SyntaxError(TrailingCharacters, 1, 6)));
-        assert_eq!(last_event("1a"),     Error(SyntaxError(TrailingCharacters, 1, 2)));
-        assert_eq!(last_event("[]a"),    Error(SyntaxError(TrailingCharacters, 1, 3)));
-        assert_eq!(last_event("{}a"),    Error(SyntaxError(TrailingCharacters, 1, 3)));
-    }
-    #[test]
-    fn test_read_identifiers_streaming() {
-        assert_eq!(Parser::new("null".chars()).next(), Some(NullValue));
-        assert_eq!(Parser::new("true".chars()).next(), Some(BooleanValue(true)));
-        assert_eq!(Parser::new("false".chars()).next(), Some(BooleanValue(false)));
-
-        assert_eq!(last_event("n"),    Error(SyntaxError(InvalidSyntax, 1, 2)));
-        assert_eq!(last_event("nul"),  Error(SyntaxError(InvalidSyntax, 1, 4)));
-        assert_eq!(last_event("t"),    Error(SyntaxError(InvalidSyntax, 1, 2)));
-        assert_eq!(last_event("truz"), Error(SyntaxError(InvalidSyntax, 1, 4)));
-        assert_eq!(last_event("f"),    Error(SyntaxError(InvalidSyntax, 1, 2)));
-        assert_eq!(last_event("faz"),  Error(SyntaxError(InvalidSyntax, 1, 3)));
-    }
-
-    #[test]
-    fn test_stack() {
-        let mut stack = Stack::new();
-
-        assert!(stack.is_empty());
-        assert!(stack.len() == 0);
-        assert!(!stack.last_is_index());
-
-        stack.push_index(0);
-        stack.bump_index();
-
-        assert!(stack.len() == 1);
-        assert!(stack.is_equal_to(&[Index(1)]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.ends_with(&[Index(1)]));
-        assert!(stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
-
-        stack.push_key("foo".to_string());
-
-        assert!(stack.len() == 2);
-        assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.ends_with(&[Index(1), Key("foo")]));
-        assert!(stack.ends_with(&[Key("foo")]));
-        assert!(!stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
-        assert!(stack.get(1) == Key("foo"));
-
-        stack.push_key("bar".to_string());
-
-        assert!(stack.len() == 3);
-        assert!(stack.is_equal_to(&[Index(1), Key("foo"), Key("bar")]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.starts_with(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1), Key("foo"), Key("bar")]));
-        assert!(stack.ends_with(&[Key("bar")]));
-        assert!(stack.ends_with(&[Key("foo"), Key("bar")]));
-        assert!(stack.ends_with(&[Index(1), Key("foo"), Key("bar")]));
-        assert!(!stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
-        assert!(stack.get(1) == Key("foo"));
-        assert!(stack.get(2) == Key("bar"));
-
-        stack.pop();
-
-        assert!(stack.len() == 2);
-        assert!(stack.is_equal_to(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1), Key("foo")]));
-        assert!(stack.starts_with(&[Index(1)]));
-        assert!(stack.ends_with(&[Index(1), Key("foo")]));
-        assert!(stack.ends_with(&[Key("foo")]));
-        assert!(!stack.last_is_index());
-        assert!(stack.get(0) == Index(1));
-        assert!(stack.get(1) == Key("foo"));
-    }
-
-    #[test]
-    fn test_to_json() {
-        use std::collections::{HashMap,BTreeMap};
-        use super::ToJson;
-
-        let array2 = Array(vec!(U64(1), U64(2)));
-        let array3 = Array(vec!(U64(1), U64(2), U64(3)));
-        let object = {
-            let mut tree_map = BTreeMap::new();
-            tree_map.insert("a".to_string(), U64(1));
-            tree_map.insert("b".to_string(), U64(2));
-            Object(tree_map)
-        };
-
-        assert_eq!(array2.to_json(), array2);
-        assert_eq!(object.to_json(), object);
-        assert_eq!(3_i.to_json(), I64(3));
-        assert_eq!(4_i8.to_json(), I64(4));
-        assert_eq!(5_i16.to_json(), I64(5));
-        assert_eq!(6_i32.to_json(), I64(6));
-        assert_eq!(7_i64.to_json(), I64(7));
-        assert_eq!(8_u.to_json(), U64(8));
-        assert_eq!(9_u8.to_json(), U64(9));
-        assert_eq!(10_u16.to_json(), U64(10));
-        assert_eq!(11_u32.to_json(), U64(11));
-        assert_eq!(12_u64.to_json(), U64(12));
-        assert_eq!(13.0_f32.to_json(), F64(13.0_f64));
-        assert_eq!(14.0_f64.to_json(), F64(14.0_f64));
-        assert_eq!(().to_json(), Null);
-        assert_eq!(f32::INFINITY.to_json(), Null);
-        assert_eq!(f64::NAN.to_json(), Null);
-        assert_eq!(true.to_json(), Boolean(true));
-        assert_eq!(false.to_json(), Boolean(false));
-        assert_eq!("abc".to_json(), String("abc".to_string()));
-        assert_eq!("abc".to_string().to_json(), String("abc".to_string()));
-        assert_eq!((1u, 2u).to_json(), array2);
-        assert_eq!((1u, 2u, 3u).to_json(), array3);
-        assert_eq!([1u, 2].to_json(), array2);
-        assert_eq!((&[1u, 2, 3]).to_json(), array3);
-        assert_eq!((vec![1u, 2]).to_json(), array2);
-        assert_eq!(vec!(1u, 2, 3).to_json(), array3);
-        let mut tree_map = BTreeMap::new();
-        tree_map.insert("a".to_string(), 1u);
-        tree_map.insert("b".to_string(), 2);
-        assert_eq!(tree_map.to_json(), object);
-        let mut hash_map = HashMap::new();
-        hash_map.insert("a".to_string(), 1u);
-        hash_map.insert("b".to_string(), 2);
-        assert_eq!(hash_map.to_json(), object);
-        assert_eq!(Some(15i).to_json(), I64(15));
-        assert_eq!(Some(15u).to_json(), U64(15));
-        assert_eq!(None::<int>.to_json(), Null);
-    }
-
-    #[bench]
-    fn bench_streaming_small(b: &mut Bencher) {
-        b.iter( || {
-            let mut parser = Parser::new(
-                r#"{
-                    "a": 1.0,
-                    "b": [
-                        true,
-                        "foo\nbar",
-                        { "c": {"d": null} }
-                    ]
-                }"#.chars()
-            );
-            loop {
-                match parser.next() {
-                    None => return,
-                    _ => {}
-                }
-            }
-        });
-    }
-    #[bench]
-    fn bench_small(b: &mut Bencher) {
-        b.iter( || {
-            let _ = from_str(r#"{
-                "a": 1.0,
-                "b": [
-                    true,
-                    "foo\nbar",
-                    { "c": {"d": null} }
-                ]
-            }"#);
-        });
-    }
-
-    fn big_json() -> string::String {
-        let mut src = "[\n".to_string();
-        for _ in range(0i, 500) {
-            src.push_str(r#"{ "a": true, "b": null, "c":3.1415, "d": "Hello world", "e": \
-                            [1,2,3]},"#);
-        }
-        src.push_str("{}]");
-        return src;
-    }
-
-    #[bench]
-    fn bench_streaming_large(b: &mut Bencher) {
-        let src = big_json();
-        b.iter( || {
-            let mut parser = Parser::new(src.chars());
-            loop {
-                match parser.next() {
-                    None => return,
-                    _ => {}
-                }
-            }
-        });
-    }
-    #[bench]
-    fn bench_large(b: &mut Bencher) {
-        let src = big_json();
-        b.iter( || { let _ = from_str(src.as_slice()); });
-    }
-}
index 8fe15f00ded73e55f60285fd6720e192686b49fb..139170fc012cb59d869ab95f93cde444c84cd778 100644 (file)
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![allow(unknown_features)]
-#![feature(macro_rules, default_type_params, phase, slicing_syntax, globs)]
-#![feature(unboxed_closures)]
-#![feature(associated_types)]
+#![feature(slicing_syntax)]
+#![feature(old_impl_check)]
+#![cfg_attr(stage0, allow(unused_attributes))]
 
 // test harness access
-#[cfg(test)]
-extern crate test;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
+#[cfg(test)] extern crate test;
+#[macro_use] extern crate log;
 
 extern crate unicode;
-
 extern crate collections;
 
 pub use self::serialize::{Decoder, Encoder, Decodable, Encodable,
                           DecoderHelpers, EncoderHelpers};
 
-#[cfg(stage0)]
-#[path = "serialize_stage0.rs"]
-mod serialize;
-#[cfg(not(stage0))]
 mod serialize;
-
-#[cfg(stage0)]
-#[path = "collection_impls_stage0.rs"]
-mod collection_impls;
-#[cfg(not(stage0))]
 mod collection_impls;
 
 pub mod base64;
 pub mod hex;
-
-#[cfg(stage0)]
-#[path = "json_stage0.rs"]
-pub mod json;
-#[cfg(not(stage0))]
 pub mod json;
 
 mod rustc_serialize {
index a04f67f765108e1a0a0aec7c9202fcdc5828696a..7b6ca10669df6036022f49518cff9c2f33709229 100644 (file)
@@ -326,7 +326,7 @@ fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
 
 impl Encodable for String {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
-        s.emit_str(self[])
+        s.emit_str(self.index(&FullRange))
     }
 }
 
@@ -499,7 +499,7 @@ macro_rules! peel {
 /// Evaluates to the number of identifiers passed to it, for example: `count_idents!(a, b, c) == 3
 macro_rules! count_idents {
     () => { 0u };
-    ($_i:ident $(, $rest:ident)*) => { 1 + count_idents!($($rest),*) }
+    ($_i:ident, $($rest:ident,)*) => { 1 + count_idents!($($rest,)*) }
 }
 
 macro_rules! tuple {
@@ -508,7 +508,7 @@ macro_rules! tuple {
         impl<$($name:Decodable),*> Decodable for ($($name,)*) {
             #[allow(non_snake_case)]
             fn decode<D: Decoder>(d: &mut D) -> Result<($($name,)*), D::Error> {
-                let len: uint = count_idents!($($name),*);
+                let len: uint = count_idents!($($name,)*);
                 d.read_tuple(len, |d| {
                     let mut i = 0;
                     let ret = ($(try!(d.read_tuple_arg({ i+=1; i-1 },
@@ -610,8 +610,8 @@ fn decode<D: Decoder>(d: &mut D) -> Result<Arc<T>, D::Error> {
 
 pub trait EncoderHelpers: Encoder {
     fn emit_from_vec<T, F>(&mut self, v: &[T], f: F)
-                           -> Result<(), <Self as Encoder>::Error>
-        where F: FnMut(&mut Self, &T) -> Result<(), <Self as Encoder>::Error>;
+                           -> Result<(), Self::Error>
+        where F: FnMut(&mut Self, &T) -> Result<(), Self::Error>;
 }
 
 impl<S:Encoder> EncoderHelpers for S {
@@ -631,8 +631,8 @@ fn emit_from_vec<T, F>(&mut self, v: &[T], mut f: F) -> Result<(), S::Error> whe
 
 pub trait DecoderHelpers: Decoder {
     fn read_to_vec<T, F>(&mut self, f: F)
-                         -> Result<Vec<T>, <Self as Decoder>::Error> where
-        F: FnMut(&mut Self) -> Result<T, <Self as Decoder>::Error>;
+                         -> Result<Vec<T>, Self::Error> where
+        F: FnMut(&mut Self) -> Result<T, Self::Error>;
 }
 
 impl<D: Decoder> DecoderHelpers for D {
diff --git a/src/libserialize/serialize_stage0.rs b/src/libserialize/serialize_stage0.rs
deleted file mode 100644 (file)
index fd37bb6..0000000
+++ /dev/null
@@ -1,629 +0,0 @@
-// Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-//! Support code for encoding and decoding types.
-
-/*
-Core encoding and decoding interfaces.
-*/
-
-use std::path;
-use std::rc::Rc;
-use std::cell::{Cell, RefCell};
-use std::sync::Arc;
-
-pub trait Encoder<E> {
-    // Primitive types:
-    fn emit_nil(&mut self) -> Result<(), E>;
-    fn emit_uint(&mut self, v: uint) -> Result<(), E>;
-    fn emit_u64(&mut self, v: u64) -> Result<(), E>;
-    fn emit_u32(&mut self, v: u32) -> Result<(), E>;
-    fn emit_u16(&mut self, v: u16) -> Result<(), E>;
-    fn emit_u8(&mut self, v: u8) -> Result<(), E>;
-    fn emit_int(&mut self, v: int) -> Result<(), E>;
-    fn emit_i64(&mut self, v: i64) -> Result<(), E>;
-    fn emit_i32(&mut self, v: i32) -> Result<(), E>;
-    fn emit_i16(&mut self, v: i16) -> Result<(), E>;
-    fn emit_i8(&mut self, v: i8) -> Result<(), E>;
-    fn emit_bool(&mut self, v: bool) -> Result<(), E>;
-    fn emit_f64(&mut self, v: f64) -> Result<(), E>;
-    fn emit_f32(&mut self, v: f32) -> Result<(), E>;
-    fn emit_char(&mut self, v: char) -> Result<(), E>;
-    fn emit_str(&mut self, v: &str) -> Result<(), E>;
-
-    // Compound types:
-    fn emit_enum<F>(&mut self, name: &str, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    fn emit_enum_variant<F>(&mut self, v_name: &str,
-                            v_id: uint,
-                            len: uint,
-                            f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_enum_variant_arg<F>(&mut self, a_idx: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    fn emit_enum_struct_variant<F>(&mut self, v_name: &str,
-                                   v_id: uint,
-                                   len: uint,
-                                   f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_enum_struct_variant_field<F>(&mut self,
-                                         f_name: &str,
-                                         f_idx: uint,
-                                         f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    fn emit_struct<F>(&mut self, name: &str, len: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_struct_field<F>(&mut self, f_name: &str, f_idx: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    fn emit_tuple<F>(&mut self, len: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_tuple_arg<F>(&mut self, idx: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    fn emit_tuple_struct<F>(&mut self, name: &str, len: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_tuple_struct_arg<F>(&mut self, f_idx: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    // Specialized types:
-    fn emit_option<F>(&mut self, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_option_none(&mut self) -> Result<(), E>;
-    fn emit_option_some<F>(&mut self, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    fn emit_seq<F>(&mut self, len: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_seq_elt<F>(&mut self, idx: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-
-    fn emit_map<F>(&mut self, len: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-    fn emit_map_elt_key<F>(&mut self, idx: uint, f: F) -> Result<(), E> where
-        F: FnMut(&mut Self) -> Result<(), E>;
-    fn emit_map_elt_val<F>(&mut self, idx: uint, f: F) -> Result<(), E> where
-        F: FnOnce(&mut Self) -> Result<(), E>;
-}
-
-pub trait Decoder<E> {
-    // Primitive types:
-    fn read_nil(&mut self) -> Result<(), E>;
-    fn read_uint(&mut self) -> Result<uint, E>;
-    fn read_u64(&mut self) -> Result<u64, E>;
-    fn read_u32(&mut self) -> Result<u32, E>;
-    fn read_u16(&mut self) -> Result<u16, E>;
-    fn read_u8(&mut self) -> Result<u8, E>;
-    fn read_int(&mut self) -> Result<int, E>;
-    fn read_i64(&mut self) -> Result<i64, E>;
-    fn read_i32(&mut self) -> Result<i32, E>;
-    fn read_i16(&mut self) -> Result<i16, E>;
-    fn read_i8(&mut self) -> Result<i8, E>;
-    fn read_bool(&mut self) -> Result<bool, E>;
-    fn read_f64(&mut self) -> Result<f64, E>;
-    fn read_f32(&mut self) -> Result<f32, E>;
-    fn read_char(&mut self) -> Result<char, E>;
-    fn read_str(&mut self) -> Result<String, E>;
-
-    // Compound types:
-    fn read_enum<T, F>(&mut self, name: &str, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    fn read_enum_variant<T, F>(&mut self, names: &[&str], f: F) -> Result<T, E> where
-        F: FnMut(&mut Self, uint) -> Result<T, E>;
-    fn read_enum_variant_arg<T, F>(&mut self, a_idx: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    fn read_enum_struct_variant<T, F>(&mut self, names: &[&str], f: F) -> Result<T, E> where
-        F: FnMut(&mut Self, uint) -> Result<T, E>;
-    fn read_enum_struct_variant_field<T, F>(&mut self,
-                                            &f_name: &str,
-                                            f_idx: uint,
-                                            f: F)
-                                            -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    fn read_struct<T, F>(&mut self, s_name: &str, len: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-    fn read_struct_field<T, F>(&mut self,
-                               f_name: &str,
-                               f_idx: uint,
-                               f: F)
-                               -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    fn read_tuple<T, F>(&mut self, len: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-    fn read_tuple_arg<T, F>(&mut self, a_idx: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    fn read_tuple_struct<T, F>(&mut self, s_name: &str, len: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-    fn read_tuple_struct_arg<T, F>(&mut self, a_idx: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    // Specialized types:
-    fn read_option<T, F>(&mut self, f: F) -> Result<T, E> where
-        F: FnMut(&mut Self, bool) -> Result<T, E>;
-
-    fn read_seq<T, F>(&mut self, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self, uint) -> Result<T, E>;
-    fn read_seq_elt<T, F>(&mut self, idx: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    fn read_map<T, F>(&mut self, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self, uint) -> Result<T, E>;
-    fn read_map_elt_key<T, F>(&mut self, idx: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-    fn read_map_elt_val<T, F>(&mut self, idx: uint, f: F) -> Result<T, E> where
-        F: FnOnce(&mut Self) -> Result<T, E>;
-
-    // Failure
-    fn error(&mut self, err: &str) -> E;
-}
-
-pub trait Encodable<S:Encoder<E>, E> {
-    fn encode(&self, s: &mut S) -> Result<(), E>;
-}
-
-pub trait Decodable<D:Decoder<E>, E> {
-    fn decode(d: &mut D) -> Result<Self, E>;
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for uint {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_uint(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for uint {
-    fn decode(d: &mut D) -> Result<uint, E> {
-        d.read_uint()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for u8 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_u8(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for u8 {
-    fn decode(d: &mut D) -> Result<u8, E> {
-        d.read_u8()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for u16 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_u16(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for u16 {
-    fn decode(d: &mut D) -> Result<u16, E> {
-        d.read_u16()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for u32 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_u32(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for u32 {
-    fn decode(d: &mut D) -> Result<u32, E> {
-        d.read_u32()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for u64 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_u64(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for u64 {
-    fn decode(d: &mut D) -> Result<u64, E> {
-        d.read_u64()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for int {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_int(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for int {
-    fn decode(d: &mut D) -> Result<int, E> {
-        d.read_int()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for i8 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_i8(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for i8 {
-    fn decode(d: &mut D) -> Result<i8, E> {
-        d.read_i8()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for i16 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_i16(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for i16 {
-    fn decode(d: &mut D) -> Result<i16, E> {
-        d.read_i16()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for i32 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_i32(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for i32 {
-    fn decode(d: &mut D) -> Result<i32, E> {
-        d.read_i32()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for i64 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_i64(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for i64 {
-    fn decode(d: &mut D) -> Result<i64, E> {
-        d.read_i64()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for str {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_str(self)
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for String {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_str(self[])
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for String {
-    fn decode(d: &mut D) -> Result<String, E> {
-        d.read_str()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for f32 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_f32(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for f32 {
-    fn decode(d: &mut D) -> Result<f32, E> {
-        d.read_f32()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for f64 {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_f64(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for f64 {
-    fn decode(d: &mut D) -> Result<f64, E> {
-        d.read_f64()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for bool {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_bool(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for bool {
-    fn decode(d: &mut D) -> Result<bool, E> {
-        d.read_bool()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for char {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_char(*self)
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for char {
-    fn decode(d: &mut D) -> Result<char, E> {
-        d.read_char()
-    }
-}
-
-impl<E, S:Encoder<E>> Encodable<S, E> for () {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_nil()
-    }
-}
-
-impl<E, D:Decoder<E>> Decodable<D, E> for () {
-    fn decode(d: &mut D) -> Result<(), E> {
-        d.read_nil()
-    }
-}
-
-impl<'a, E, S: Encoder<E>, T: ?Sized + Encodable<S, E>> Encodable<S, E> for &'a T {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        (**self).encode(s)
-    }
-}
-
-impl<E, S: Encoder<E>, T: ?Sized + Encodable<S, E>> Encodable<S, E> for Box<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        (**self).encode(s)
-    }
-}
-
-impl<E, D:Decoder<E>, T: Decodable<D, E>> Decodable<D, E> for Box<T> {
-    fn decode(d: &mut D) -> Result<Box<T>, E> {
-        Ok(box try!(Decodable::decode(d)))
-    }
-}
-
-impl<E, D:Decoder<E>, T: Decodable<D, E>> Decodable<D, E> for Box<[T]> {
-    fn decode(d: &mut D) -> Result<Box<[T]>, E> {
-        let v: Vec<T> = try!(Decodable::decode(d));
-        Ok(v.into_boxed_slice())
-    }
-}
-
-impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for Rc<T> {
-    #[inline]
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        (**self).encode(s)
-    }
-}
-
-impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for Rc<T> {
-    #[inline]
-    fn decode(d: &mut D) -> Result<Rc<T>, E> {
-        Ok(Rc::new(try!(Decodable::decode(d))))
-    }
-}
-
-impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for [T] {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_seq(self.len(), |s| {
-            for (i, e) in self.iter().enumerate() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)))
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for Vec<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_seq(self.len(), |s| {
-            for (i, e) in self.iter().enumerate() {
-                try!(s.emit_seq_elt(i, |s| e.encode(s)))
-            }
-            Ok(())
-        })
-    }
-}
-
-impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for Vec<T> {
-    fn decode(d: &mut D) -> Result<Vec<T>, E> {
-        d.read_seq(|d, len| {
-            let mut v = Vec::with_capacity(len);
-            for i in range(0, len) {
-                v.push(try!(d.read_seq_elt(i, |d| Decodable::decode(d))));
-            }
-            Ok(v)
-        })
-    }
-}
-
-impl<E, S:Encoder<E>,T:Encodable<S, E>> Encodable<S, E> for Option<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_option(|s| {
-            match *self {
-                None => s.emit_option_none(),
-                Some(ref v) => s.emit_option_some(|s| v.encode(s)),
-            }
-        })
-    }
-}
-
-impl<E, D:Decoder<E>,T:Decodable<D, E>> Decodable<D, E> for Option<T> {
-    fn decode(d: &mut D) -> Result<Option<T>, E> {
-        d.read_option(|d, b| {
-            if b {
-                Ok(Some(try!(Decodable::decode(d))))
-            } else {
-                Ok(None)
-            }
-        })
-    }
-}
-
-macro_rules! peel {
-    ($name:ident, $($other:ident,)*) => (tuple! { $($other,)* })
-}
-
-/// Evaluates to the number of identifiers passed to it, for example: `count_idents!(a, b, c) == 3
-macro_rules! count_idents {
-    () => { 0u };
-    ($_i:ident $(, $rest:ident)*) => { 1 + count_idents!($($rest),*) }
-}
-
-macro_rules! tuple {
-    () => ();
-    ( $($name:ident,)+ ) => (
-        impl<E, D:Decoder<E>,$($name:Decodable<D, E>),*> Decodable<D,E> for ($($name,)*) {
-            #[allow(non_snake_case)]
-            fn decode(d: &mut D) -> Result<($($name,)*), E> {
-                let len: uint = count_idents!($($name),*);
-                d.read_tuple(len, |d| {
-                    let mut i = 0;
-                    let ret = ($(try!(d.read_tuple_arg({ i+=1; i-1 }, |d| -> Result<$name,E> {
-                        Decodable::decode(d)
-                    })),)*);
-                    return Ok(ret);
-                })
-            }
-        }
-        impl<E, S:Encoder<E>,$($name:Encodable<S, E>),*> Encodable<S, E> for ($($name,)*) {
-            #[allow(non_snake_case)]
-            fn encode(&self, s: &mut S) -> Result<(), E> {
-                let ($(ref $name,)*) = *self;
-                let mut n = 0;
-                $(let $name = $name; n += 1;)*
-                s.emit_tuple(n, |s| {
-                    let mut i = 0;
-                    $(try!(s.emit_tuple_arg({ i+=1; i-1 }, |s| $name.encode(s)));)*
-                    Ok(())
-                })
-            }
-        }
-        peel! { $($name,)* }
-    )
-}
-
-tuple! { T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, }
-
-impl<E, S: Encoder<E>> Encodable<S, E> for path::posix::Path {
-    fn encode(&self, e: &mut S) -> Result<(), E> {
-        self.as_vec().encode(e)
-    }
-}
-
-impl<E, D: Decoder<E>> Decodable<D, E> for path::posix::Path {
-    fn decode(d: &mut D) -> Result<path::posix::Path, E> {
-        let bytes: Vec<u8> = try!(Decodable::decode(d));
-        Ok(path::posix::Path::new(bytes))
-    }
-}
-
-impl<E, S: Encoder<E>> Encodable<S, E> for path::windows::Path {
-    fn encode(&self, e: &mut S) -> Result<(), E> {
-        self.as_vec().encode(e)
-    }
-}
-
-impl<E, D: Decoder<E>> Decodable<D, E> for path::windows::Path {
-    fn decode(d: &mut D) -> Result<path::windows::Path, E> {
-        let bytes: Vec<u8> = try!(Decodable::decode(d));
-        Ok(path::windows::Path::new(bytes))
-    }
-}
-
-impl<E, S: Encoder<E>, T: Encodable<S, E> + Copy> Encodable<S, E> for Cell<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        self.get().encode(s)
-    }
-}
-
-impl<E, D: Decoder<E>, T: Decodable<D, E> + Copy> Decodable<D, E> for Cell<T> {
-    fn decode(d: &mut D) -> Result<Cell<T>, E> {
-        Ok(Cell::new(try!(Decodable::decode(d))))
-    }
-}
-
-// FIXME: #15036
-// Should use `try_borrow`, returning a
-// `encoder.error("attempting to Encode borrowed RefCell")`
-// from `encode` when `try_borrow` returns `None`.
-
-impl<E, S: Encoder<E>, T: Encodable<S, E>> Encodable<S, E> for RefCell<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        self.borrow().encode(s)
-    }
-}
-
-impl<E, D: Decoder<E>, T: Decodable<D, E>> Decodable<D, E> for RefCell<T> {
-    fn decode(d: &mut D) -> Result<RefCell<T>, E> {
-        Ok(RefCell::new(try!(Decodable::decode(d))))
-    }
-}
-
-impl<E, S:Encoder<E>, T:Encodable<S, E>> Encodable<S, E> for Arc<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        (**self).encode(s)
-    }
-}
-
-impl<E, D:Decoder<E>,T:Decodable<D, E>+Send+Sync> Decodable<D, E> for Arc<T> {
-    fn decode(d: &mut D) -> Result<Arc<T>, E> {
-        Ok(Arc::new(try!(Decodable::decode(d))))
-    }
-}
-
-// ___________________________________________________________________________
-// Helper routines
-
-pub trait EncoderHelpers<E> {
-    fn emit_from_vec<T, F>(&mut self, v: &[T], f: F) -> Result<(), E> where
-        F: FnMut(&mut Self, &T) -> Result<(), E>;
-}
-
-impl<E, S:Encoder<E>> EncoderHelpers<E> for S {
-    fn emit_from_vec<T, F>(&mut self, v: &[T], mut f: F) -> Result<(), E> where
-        F: FnMut(&mut S, &T) -> Result<(), E>,
-    {
-        self.emit_seq(v.len(), |this| {
-            for (i, e) in v.iter().enumerate() {
-                try!(this.emit_seq_elt(i, |this| {
-                    f(this, e)
-                }));
-            }
-            Ok(())
-        })
-    }
-}
-
-pub trait DecoderHelpers<E> {
-    fn read_to_vec<T, F>(&mut self, f: F) -> Result<Vec<T>, E> where
-        F: FnMut(&mut Self) -> Result<T, E>;
-}
-
-impl<E, D:Decoder<E>> DecoderHelpers<E> for D {
-    fn read_to_vec<T, F>(&mut self, mut f: F) -> Result<Vec<T>, E> where F:
-        FnMut(&mut D) -> Result<T, E>,
-    {
-        self.read_seq(|this, len| {
-            let mut v = Vec::with_capacity(len);
-            for i in range(0, len) {
-                v.push(try!(this.read_seq_elt(i, |this| f(this))));
-            }
-            Ok(v)
-        })
-    }
-}
index ed3f2cbe1a1da3f5471e06bb12aa2d0de1f0309d..5764962b51b02162367f2031e4f90976f9fa2e9d 100644 (file)
@@ -71,7 +71,7 @@
 ///     let mut flags = FLAG_A | FLAG_B;
 ///     flags.clear();
 ///     assert!(flags.is_empty());
-///     assert_eq!(format!("{}", flags).as_slice(), "hi!");
+///     assert_eq!(format!("{:?}", flags).as_slice(), "hi!");
 /// }
 /// ```
 ///
index f9c7d10d40e7fe8d44ab23e49b7b7aa04be4416b..c3381d5cd64a007ee6778bccca0c86c1f509f0ec 100644 (file)
 use self::SearchResult::*;
 use self::VacantEntryState::*;
 
-use borrow::{BorrowFrom, ToOwned};
+use borrow::BorrowFrom;
 use clone::Clone;
 use cmp::{max, Eq, PartialEq};
 use default::Default;
 use fmt::{self, Show};
 use hash::{Hash, Hasher, RandomSipHasher};
 use iter::{self, Iterator, IteratorExt, FromIterator, Extend, Map};
-use kinds::Sized;
+use marker::Sized;
 use mem::{self, replace};
 use num::{Int, UnsignedInt};
 use ops::{Deref, FnMut, Index, IndexMut};
@@ -292,7 +292,7 @@ fn test_resize_policy() {
 ///
 /// // Use derived implementation to print the status of the vikings.
 /// for (viking, health) in vikings.iter() {
-///     println!("{} has {} hp", viking, health);
+///     println!("{:?} has {} hp", viking, health);
 /// }
 /// ```
 #[derive(Clone)]
@@ -439,6 +439,7 @@ fn into_option(self) -> Option<FullBucket<K, V, M>> {
     }
 }
 
+#[old_impl_check]
 impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
     fn make_hash<X: ?Sized + Hash<S>>(&self, x: &X) -> SafeHash {
         table::make_hash(&self.hasher, x)
@@ -517,6 +518,7 @@ pub fn with_capacity(capacity: uint) -> HashMap<K, V, RandomSipHasher> {
     }
 }
 
+#[old_impl_check]
 impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> HashMap<K, V, H> {
     /// Creates an empty hashmap which will use the given hasher to hash keys.
     ///
@@ -920,16 +922,14 @@ fn last_two<A, B, C>((_, b, c): (A, B, C)) -> (B, C) { (b, c) }
         }
     }
 
-    #[stable]
     /// Gets the given key's corresponding entry in the map for in-place manipulation.
-    /// Regardless of whether or not `to_owned()` has been called, the key must hash the same way.
-    pub fn entry<'a, Q: ?Sized>(&'a mut self, key: &'a Q) -> Entry<'a, Q, K, V>
-        where Q: Eq + Hash<S> + ToOwned<K>
+    #[unstable = "precise API still being fleshed out"]
+    pub fn entry<'a>(&'a mut self, key: K) -> Entry<'a, K, V>
     {
         // Gotta resize now.
         self.reserve(1);
 
-        let hash = self.make_hash(key);
+        let hash = self.make_hash(&key);
         search_entry_hashed(&mut self.table, hash, key)
     }
 
@@ -1142,9 +1142,8 @@ pub fn remove<Q: ?Sized>(&mut self, k: &Q) -> Option<V>
     }
 }
 
-fn search_entry_hashed<'a, K, V, Q: ?Sized>(table: &'a mut RawTable<K,V>, hash: SafeHash, k: &'a Q)
-        -> Entry<'a, Q, K, V>
-    where Q: Eq + ToOwned<K>
+fn search_entry_hashed<'a, K: Eq, V>(table: &'a mut RawTable<K,V>, hash: SafeHash, k: K)
+        -> Entry<'a, K, V>
 {
     // Worst case, we'll find one empty bucket among `size + 1` buckets.
     let size = table.size();
@@ -1167,7 +1166,7 @@ fn search_entry_hashed<'a, K, V, Q: ?Sized>(table: &'a mut RawTable<K,V>, hash:
         // hash matches?
         if bucket.hash() == hash {
             // key matches?
-            if *k == *BorrowFrom::borrow_from(bucket.read().0) {
+            if k == *bucket.read().0 {
                 return Occupied(OccupiedEntry{
                     elem: bucket,
                 });
@@ -1191,6 +1190,7 @@ fn search_entry_hashed<'a, K, V, Q: ?Sized>(table: &'a mut RawTable<K,V>, hash:
 }
 
 #[stable]
+#[old_impl_check]
 impl<K: Eq + Hash<S>, V: PartialEq, S, H: Hasher<S>> PartialEq for HashMap<K, V, H> {
     fn eq(&self, other: &HashMap<K, V, H>) -> bool {
         if self.len() != other.len() { return false; }
@@ -1202,16 +1202,18 @@ fn eq(&self, other: &HashMap<K, V, H>) -> bool {
 }
 
 #[stable]
+#[old_impl_check]
 impl<K: Eq + Hash<S>, V: Eq, S, H: Hasher<S>> Eq for HashMap<K, V, H> {}
 
 #[stable]
+#[old_impl_check]
 impl<K: Eq + Hash<S> + Show, V: Show, S, H: Hasher<S>> Show for HashMap<K, V, H> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
+        try!(write!(f, "HashMap {{"));
 
         for (i, (k, v)) in self.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{}: {}", *k, *v));
+            try!(write!(f, "{:?}: {:?}", *k, *v));
         }
 
         write!(f, "}}")
@@ -1219,6 +1221,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[stable]
+#[old_impl_check]
 impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> Default for HashMap<K, V, H> {
     #[stable]
     fn default() -> HashMap<K, V, H> {
@@ -1227,6 +1230,7 @@ fn default() -> HashMap<K, V, H> {
 }
 
 #[stable]
+#[old_impl_check]
 impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> Index<Q> for HashMap<K, V, H>
     where Q: BorrowFrom<K> + Hash<S> + Eq
 {
@@ -1239,6 +1243,7 @@ fn index<'a>(&'a self, index: &Q) -> &'a V {
 }
 
 #[stable]
+#[old_impl_check]
 impl<K: Hash<S> + Eq, Q: ?Sized, V, S, H: Hasher<S>> IndexMut<Q> for HashMap<K, V, H>
     where Q: BorrowFrom<K> + Hash<S> + Eq
 {
@@ -1323,27 +1328,27 @@ pub struct Drain<'a, K: 'a, V: 'a> {
     >
 }
 
-#[stable]
 /// A view into a single occupied location in a HashMap
+#[unstable = "precise API still being fleshed out"]
 pub struct OccupiedEntry<'a, K: 'a, V: 'a> {
     elem: FullBucket<K, V, &'a mut RawTable<K, V>>,
 }
 
-#[stable]
 /// A view into a single empty location in a HashMap
-pub struct VacantEntry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> {
+#[unstable = "precise API still being fleshed out"]
+pub struct VacantEntry<'a, K: 'a, V: 'a> {
     hash: SafeHash,
-    key: &'a Q,
+    key: K,
     elem: VacantEntryState<K, V, &'a mut RawTable<K, V>>,
 }
 
-#[stable]
 /// A view into a single location in a map, which may be vacant or occupied
-pub enum Entry<'a, Q: ?Sized + 'a, K: 'a, V: 'a> {
+#[unstable = "precise API still being fleshed out"]
+pub enum Entry<'a, K: 'a, V: 'a> {
     /// An occupied Entry
     Occupied(OccupiedEntry<'a, K, V>),
     /// A vacant Entry
-    Vacant(VacantEntry<'a, Q, K, V>),
+    Vacant(VacantEntry<'a, K, V>),
 }
 
 /// Possible states of a VacantEntry
@@ -1409,10 +1414,10 @@ fn size_hint(&self) -> (uint, Option<uint>) {
     }
 }
 
-impl<'a, Q: ?Sized, K, V> Entry<'a, Q, K, V> {
-    #[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
+impl<'a, K, V> Entry<'a, K, V> {
     /// Returns a mutable reference to the entry if occupied, or the VacantEntry if vacant
-    pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
+    pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, K, V>> {
         match self {
             Occupied(entry) => Ok(entry.into_mut()),
             Vacant(entry) => Err(entry),
@@ -1420,27 +1425,24 @@ pub fn get(self) -> Result<&'a mut V, VacantEntry<'a, Q, K, V>> {
     }
 }
 
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
 impl<'a, K, V> OccupiedEntry<'a, K, V> {
-    #[stable]
     /// Gets a reference to the value in the entry
     pub fn get(&self) -> &V {
         self.elem.read().1
     }
 
-    #[stable]
     /// Gets a mutable reference to the value in the entry
     pub fn get_mut(&mut self) -> &mut V {
         self.elem.read_mut().1
     }
 
-    #[stable]
     /// Converts the OccupiedEntry into a mutable reference to the value in the entry
     /// with a lifetime bound to the map itself
     pub fn into_mut(self) -> &'a mut V {
         self.elem.into_mut_refs().1
     }
 
-    #[stable]
     /// Sets the value of the entry, and returns the entry's old value
     pub fn insert(&mut self, mut value: V) -> V {
         let old_value = self.get_mut();
@@ -1448,30 +1450,30 @@ pub fn insert(&mut self, mut value: V) -> V {
         value
     }
 
-    #[stable]
     /// Takes the value out of the entry, and returns it
     pub fn remove(self) -> V {
         pop_internal(self.elem).1
     }
 }
 
-impl<'a, Q: ?Sized + 'a + ToOwned<K>, K: 'a, V: 'a> VacantEntry<'a, Q, K, V> {
-    #[stable]
+#[unstable = "matches collection reform v2 specification, waiting for dust to settle"]
+impl<'a, K: 'a, V: 'a> VacantEntry<'a, K, V> {
     /// Sets the value of the entry with the VacantEntry's key,
     /// and returns a mutable reference to it
     pub fn insert(self, value: V) -> &'a mut V {
         match self.elem {
             NeqElem(bucket, ib) => {
-                robin_hood(bucket, ib, self.hash, self.key.to_owned(), value)
+                robin_hood(bucket, ib, self.hash, self.key, value)
             }
             NoElem(bucket) => {
-                bucket.put(self.hash, self.key.to_owned(), value).into_mut_refs().1
+                bucket.put(self.hash, self.key, value).into_mut_refs().1
             }
         }
     }
 }
 
 #[stable]
+#[old_impl_check]
 impl<K: Eq + Hash<S>, V, S, H: Hasher<S> + Default> FromIterator<(K, V)> for HashMap<K, V, H> {
     fn from_iter<T: Iterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, H> {
         let lower = iter.size_hint().0;
@@ -1482,6 +1484,7 @@ fn from_iter<T: Iterator<Item=(K, V)>>(iter: T) -> HashMap<K, V, H> {
 }
 
 #[stable]
+#[old_impl_check]
 impl<K: Eq + Hash<S>, V, S, H: Hasher<S>> Extend<(K, V)> for HashMap<K, V, H> {
     fn extend<T: Iterator<Item=(K, V)>>(&mut self, mut iter: T) {
         for (k, v) in iter {
@@ -1497,8 +1500,6 @@ mod test_map {
     use super::HashMap;
     use super::Entry::{Occupied, Vacant};
     use iter::{range_inclusive, range_step_inclusive, repeat};
-    use borrow::ToOwned;
-    use hash;
     use cell::RefCell;
     use rand::{weak_rng, Rng};
 
@@ -1891,10 +1892,11 @@ fn test_show() {
         map.insert(1i, 2i);
         map.insert(3i, 4i);
 
-        let map_str = format!("{}", map);
+        let map_str = format!("{:?}", map);
 
-        assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
-        assert_eq!(format!("{}", empty), "{}");
+        assert!(map_str == "HashMap {1i: 2i, 3i: 4i}" ||
+                map_str == "HashMap {3i: 4i, 1i: 2i}");
+        assert_eq!(format!("{:?}", empty), "HashMap {}");
     }
 
     #[test]
@@ -2092,7 +2094,7 @@ fn test_entry(){
         let mut map: HashMap<int, int> = xs.iter().map(|&x| x).collect();
 
         // Existing key (insert)
-        match map.entry(&1) {
+        match map.entry(1) {
             Vacant(_) => unreachable!(),
             Occupied(mut view) => {
                 assert_eq!(view.get(), &10);
@@ -2104,7 +2106,7 @@ fn test_entry(){
 
 
         // Existing key (update)
-        match map.entry(&2) {
+        match map.entry(2) {
             Vacant(_) => unreachable!(),
             Occupied(mut view) => {
                 let v = view.get_mut();
@@ -2116,7 +2118,7 @@ fn test_entry(){
         assert_eq!(map.len(), 6);
 
         // Existing key (take)
-        match map.entry(&3) {
+        match map.entry(3) {
             Vacant(_) => unreachable!(),
             Occupied(view) => {
                 assert_eq!(view.remove(), 30);
@@ -2127,7 +2129,7 @@ fn test_entry(){
 
 
         // Inexistent key (insert)
-        match map.entry(&10) {
+        match map.entry(10) {
             Occupied(_) => unreachable!(),
             Vacant(view) => {
                 assert_eq!(*view.insert(1000), 1000);
@@ -2158,7 +2160,7 @@ fn check(m: &HashMap<int, ()>) {
 
         for i in range(0u, 1000) {
             let x = rng.gen_range(-10, 10);
-            match m.entry(&x) {
+            match m.entry(x) {
                 Vacant(_) => {},
                 Occupied(e) => {
                     println!("{}: remove {}", i, x);
index 211bfe2c10e8fede558452f3c9a12918bd60054c..f66e538494248a7305935c50df5a32efc0f90391 100644 (file)
@@ -13,7 +13,7 @@
 use borrow::BorrowFrom;
 use clone::Clone;
 use cmp::{Eq, PartialEq};
-use core::kinds::Sized;
+use core::marker::Sized;
 use default::Default;
 use fmt::Show;
 use fmt;
@@ -22,9 +22,6 @@
 use ops::{BitOr, BitAnd, BitXor, Sub};
 use option::Option::{Some, None, self};
 
-// NOTE: for old macros; remove after the next snapshot
-#[cfg(stage0)] use result::Result::{Ok, Err};
-
 use super::map::{self, HashMap, Keys, INITIAL_CAPACITY};
 
 // Future Optimization (FIXME!)
@@ -88,7 +85,7 @@
 ///
 /// // Use derived implementation to print the vikings.
 /// for x in vikings.iter() {
-///     println!("{}", x);
+///     println!("{:?}", x);
 /// }
 /// ```
 #[derive(Clone)]
@@ -128,6 +125,7 @@ pub fn with_capacity(capacity: uint) -> HashSet<T, RandomSipHasher> {
     }
 }
 
+#[old_impl_check]
 impl<T: Eq + Hash<S>, S, H: Hasher<S>> HashSet<T, H> {
     /// Creates a new empty hash set which will use the given hasher to hash
     /// keys.
@@ -571,6 +569,7 @@ pub fn remove<Q: ?Sized>(&mut self, value: &Q) -> bool
 }
 
 #[stable]
+#[old_impl_check]
 impl<T: Eq + Hash<S>, S, H: Hasher<S>> PartialEq for HashSet<T, H> {
     fn eq(&self, other: &HashSet<T, H>) -> bool {
         if self.len() != other.len() { return false; }
@@ -580,16 +579,18 @@ fn eq(&self, other: &HashSet<T, H>) -> bool {
 }
 
 #[stable]
+#[old_impl_check]
 impl<T: Eq + Hash<S>, S, H: Hasher<S>> Eq for HashSet<T, H> {}
 
 #[stable]
+#[old_impl_check]
 impl<T: Eq + Hash<S> + fmt::Show, S, H: Hasher<S>> fmt::Show for HashSet<T, H> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        try!(write!(f, "{{"));
+        try!(write!(f, "HashSet {{"));
 
         for (i, x) in self.iter().enumerate() {
             if i != 0 { try!(write!(f, ", ")); }
-            try!(write!(f, "{}", *x));
+            try!(write!(f, "{:?}", *x));
         }
 
         write!(f, "}}")
@@ -597,6 +598,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 }
 
 #[stable]
+#[old_impl_check]
 impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> FromIterator<T> for HashSet<T, H> {
     fn from_iter<I: Iterator<Item=T>>(iter: I) -> HashSet<T, H> {
         let lower = iter.size_hint().0;
@@ -607,6 +609,7 @@ fn from_iter<I: Iterator<Item=T>>(iter: I) -> HashSet<T, H> {
 }
 
 #[stable]
+#[old_impl_check]
 impl<T: Eq + Hash<S>, S, H: Hasher<S>> Extend<T> for HashSet<T, H> {
     fn extend<I: Iterator<Item=T>>(&mut self, mut iter: I) {
         for k in iter {
@@ -616,6 +619,7 @@ fn extend<I: Iterator<Item=T>>(&mut self, mut iter: I) {
 }
 
 #[stable]
+#[old_impl_check]
 impl<T: Eq + Hash<S>, S, H: Hasher<S> + Default> Default for HashSet<T, H> {
     #[stable]
     fn default() -> HashSet<T, H> {
@@ -624,6 +628,7 @@ fn default() -> HashSet<T, H> {
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, 'b, T: Eq + Hash<S> + Clone, S, H: Hasher<S> + Default>
 BitOr<&'b HashSet<T, H>> for &'a HashSet<T, H> {
     type Output = HashSet<T, H>;
@@ -654,6 +659,7 @@ fn bitor(self, rhs: &HashSet<T, H>) -> HashSet<T, H> {
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, 'b, T: Eq + Hash<S> + Clone, S, H: Hasher<S> + Default>
 BitAnd<&'b HashSet<T, H>> for &'a HashSet<T, H> {
     type Output = HashSet<T, H>;
@@ -684,6 +690,7 @@ fn bitand(self, rhs: &HashSet<T, H>) -> HashSet<T, H> {
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, 'b, T: Eq + Hash<S> + Clone, S, H: Hasher<S> + Default>
 BitXor<&'b HashSet<T, H>> for &'a HashSet<T, H> {
     type Output = HashSet<T, H>;
@@ -714,6 +721,7 @@ fn bitxor(self, rhs: &HashSet<T, H>) -> HashSet<T, H> {
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, 'b, T: Eq + Hash<S> + Clone, S, H: Hasher<S> + Default>
 Sub<&'b HashSet<T, H>> for &'a HashSet<T, H> {
     type Output = HashSet<T, H>;
@@ -816,6 +824,7 @@ fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, T, S, H> Iterator for Intersection<'a, T, H>
     where T: Eq + Hash<S>, H: Hasher<S>
 {
@@ -839,6 +848,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, T, S, H> Iterator for Difference<'a, T, H>
     where T: Eq + Hash<S>, H: Hasher<S>
 {
@@ -862,6 +872,7 @@ fn size_hint(&self) -> (uint, Option<uint>) {
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, T, S, H> Iterator for SymmetricDifference<'a, T, H>
     where T: Eq + Hash<S>, H: Hasher<S>
 {
@@ -872,6 +883,7 @@ fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
 }
 
 #[stable]
+#[old_impl_check]
 impl<'a, T, S, H> Iterator for Union<'a, T, H>
     where T: Eq + Hash<S>, H: Hasher<S>
 {
@@ -1116,10 +1128,10 @@ fn test_show() {
         set.insert(1i);
         set.insert(2);
 
-        let set_str = format!("{}", set);
+        let set_str = format!("{:?}", set);
 
-        assert!(set_str == "{1, 2}" || set_str == "{2, 1}");
-        assert_eq!(format!("{}", empty), "{}");
+        assert!(set_str == "HashSet {1i, 2i}" || set_str == "HashSet {2i, 1i}");
+        assert_eq!(format!("{:?}", empty), "HashSet {}");
     }
 
     #[test]
index 1eb4408eedc403d4d4fb0e273e9bd9d52ad88eeb..6eb98da4da46e7c0223773cf4f88d8a3ee4ae436 100644 (file)
@@ -16,7 +16,7 @@
 use cmp;
 use hash::{Hash, Hasher};
 use iter::{Iterator, count};
-use kinds::{Copy, Sized, marker};
+use marker::{Copy, Sized, self};
 use mem::{min_align_of, size_of};
 use mem;
 use num::{Int, UnsignedInt};
index ef9d28bbbb2e863bd993080831155ff454335613..9b2a4926bcb925cc985dcb1cdacaacb7d6c61bdf 100644 (file)
 //! let message = "she sells sea shells by the sea shore";
 //!
 //! for c in message.chars() {
-//!     match count.entry(&c) {
+//!     match count.entry(c) {
 //!         Vacant(entry) => { entry.insert(1u); },
 //!         Occupied(mut entry) => *entry.get_mut() += 1,
 //!     }
 //! for id in orders.into_iter() {
 //!     // If this is the first time we've seen this customer, initialize them
 //!     // with no blood alcohol. Otherwise, just retrieve them.
-//!     let person = match blood_alcohol.entry(&id) {
+//!     let person = match blood_alcohol.entry(id) {
 //!         Vacant(entry) => entry.insert(Person{id: id, blood_alcohol: 0.0}),
 //!         Occupied(entry) => entry.into_mut(),
 //!     };
index 32e1922ae74fd62a92261c95f5fb0451da6088db..9963e4861b778772967f4274a1e59ac6aee39a49 100644 (file)
 //! }
 //! ```
 
+#![stable]
+
 use prelude::v1::*;
 
 use str::Utf8Error;
 use string::{FromUtf8Error, FromUtf16Error};
 
 /// Base functionality for all errors in Rust.
+#[unstable = "the exact API of this trait may change"]
 pub trait Error: Send {
     /// A short description of the error; usually a static string.
     fn description(&self) -> &str;
@@ -96,18 +99,21 @@ fn cause(&self) -> Option<&Error> { None }
 }
 
 /// A trait for types that can be converted from a given error type `E`.
+#[stable]
 pub trait FromError<E> {
     /// Perform the conversion.
     fn from_error(err: E) -> Self;
 }
 
 // Any type is convertable from itself
+#[stable]
 impl<E> FromError<E> for E {
     fn from_error(err: E) -> E {
         err
     }
 }
 
+#[stable]
 impl Error for Utf8Error {
     fn description(&self) -> &str {
         match *self {
@@ -119,11 +125,13 @@ fn description(&self) -> &str {
     fn detail(&self) -> Option<String> { Some(self.to_string()) }
 }
 
+#[stable]
 impl Error for FromUtf8Error {
     fn description(&self) -> &str { "invalid utf-8" }
     fn detail(&self) -> Option<String> { Some(self.to_string()) }
 }
 
+#[stable]
 impl Error for FromUtf16Error {
     fn description(&self) -> &str { "invalid utf-16" }
 }
index e48137047b0a95a81265a3264f776124f9db76de..50538d3e43def43f5df8407a74cc061acd563bd8 100644 (file)
@@ -37,7 +37,7 @@ pub fn on_fail(obj: &(Any+Send), file: &'static str, line: uint) {
     let msg = match obj.downcast_ref::<&'static str>() {
         Some(s) => *s,
         None => match obj.downcast_ref::<String>() {
-            Some(s) => s[],
+            Some(s) => s.index(&FullRange),
             None => "Box<Any>",
         }
     };
index ca797e44ccd007c08b1cb135498cf6d00dc20c10..1623b6452b7168ec977063c10ba85daa605db021 100644 (file)
@@ -31,7 +31,7 @@
 //! format!("Hello");                  // => "Hello"
 //! format!("Hello, {}!", "world");    // => "Hello, world!"
 //! format!("The number is {}", 1i);   // => "The number is 1"
-//! format!("{}", (3i, 4i));           // => "(3, 4)"
+//! format!("{:?}", (3i, 4i));         // => "(3i, 4i)"
 //! format!("{value}", value=4i);      // => "4"
 //! format!("{} {}", 1i, 2u);          // => "1 2"
 //! # }
@@ -87,7 +87,7 @@
 //! # fn main() {
 //! format!("{argument}", argument = "test");   // => "test"
 //! format!("{name} {}", 1i, name = 2i);        // => "2 1"
-//! format!("{a} {c} {b}", a="a", b=(), c=3i);  // => "a 3 ()"
+//! format!("{a} {c} {b}", a="a", b='b', c=3i);  // => "a 3 b"
 //! # }
 //! ```
 //!
 //! This allows multiple actual types to be formatted via `{:x}` (like `i8` as
 //! well as `int`).  The current mapping of types to traits is:
 //!
-//! * *nothing* ⇒ `Show`
+//! * *nothing* ⇒ `String`
+//! * `?` ⇒ `Show`
 //! * `o` ⇒ `Octal`
 //! * `x` ⇒ `LowerHex`
 //! * `X` ⇒ `UpperHex`
 //! `std::fmt::Binary` trait can then be formatted with `{:b}`. Implementations
 //! are provided for these traits for a number of primitive types by the
 //! standard library as well. If no format is specified (as in `{}` or `{:6}`),
-//! then the format trait used is the `Show` trait. This is one of the more
-//! commonly implemented traits when formatting a custom type.
+//! then the format trait used is the `String` trait.
 //!
 //! When implementing a format trait for your own type, you will have to
 //! implement a method of the signature:
 //! use std::f64;
 //! use std::num::Float;
 //!
+//! #[deriving(Show)]
 //! struct Vector2D {
 //!     x: int,
 //!     y: int,
 //! }
 //!
-//! impl fmt::Show for Vector2D {
+//! impl fmt::String for Vector2D {
 //!     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 //!         // The `f` value implements the `Writer` trait, which is what the
 //!         // write! macro is expecting. Note that this formatting ignores the
 //!     let myvector = Vector2D { x: 3, y: 4 };
 //!
 //!     println!("{}", myvector);       // => "(3, 4)"
+//!     println!("{:?}", myvector);     // => "Vector2D {x: 3i, y:4i}"
 //!     println!("{:10.3b}", myvector); // => "     5.000"
 //! }
 //! ```
 //!
+//! #### fmt::String vs fmt::Show
+//!
+//! These two formatting traits have distinct purposes:
+//!
+//! - `fmt::String` implementations assert that the type can be faithfully
+//!   represented as a UTF-8 string at all times. It is **not** expected that
+//!   all types implement the `String` trait.
+//! - `fmt::Show` implementations should be implemented for **all** public types.
+//!   Output will typically represent the internal state as faithfully as possible.
+//!   The purpose of the `Show` trait is to facilitate debugging Rust code. In
+//!   most cases, using `#[deriving(Show)]` is sufficient and recommended.
+//!
+//! Some examples of the output from both traits:
+//!
+//! ```
+//! assert_eq!(format!("{} {:?}", 3i32, 4i32), "3 4i32");
+//! assert_eq!(format!("{} {:?}", 'a', 'b'), "a 'b'");
+//! assert_eq!(format!("{} {:?}", "foo\n", "bar\n"), "foo\n \"bar\\n\"");
+//! ```
+//!
 //! ### Related macros
 //!
 //! There are a number of related macros in the `format!` family. The ones that
 use string;
 
 pub use core::fmt::{Formatter, Result, Writer, rt};
-pub use core::fmt::{Show, Octal, Binary};
+pub use core::fmt::{Show, String, Octal, Binary};
 pub use core::fmt::{LowerHex, UpperHex, Pointer};
 pub use core::fmt::{LowerExp, UpperExp};
 pub use core::fmt::Error;
index ac2b01e995e2c62b5b17cea4e589659149bff133..69e7e429d07da01b5d7726415d17f08b1163d626 100644 (file)
@@ -63,7 +63,7 @@
 
 pub use core::hash::{Hash, Hasher, Writer, hash, sip};
 
-use core::kinds::Sized;
+use core::marker::Sized;
 use default::Default;
 use rand::Rng;
 use rand;
index d590aa8419453d6de9ce3ed35c62fba98b719052..74c503e6f2ba8e26c3d6defd7e4e3d2184a7cd7c 100644 (file)
@@ -15,7 +15,7 @@
 use cmp;
 use io::{Reader, Writer, Stream, Buffer, DEFAULT_BUF_SIZE, IoResult};
 use iter::{IteratorExt, ExactSizeIterator};
-use ops::Drop;
+use ops::{Drop, Index};
 use option::Option;
 use option::Option::{Some, None};
 use result::Result::Ok;
@@ -23,9 +23,6 @@
 use slice;
 use vec::Vec;
 
-// NOTE: for old macros; remove after the next snapshot
-#[cfg(stage0)] use result::Result::Err;
-
 /// Wraps a Reader and buffers input from it
 ///
 /// It can be excessively inefficient to work directly with a `Reader`. For
@@ -100,7 +97,7 @@ fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> {
             self.cap = try!(self.inner.read(self.buf.as_mut_slice()));
             self.pos = 0;
         }
-        Ok(self.buf[self.pos..self.cap])
+        Ok(self.buf.index(&(self.pos..self.cap)))
     }
 
     fn consume(&mut self, amt: uint) {
@@ -117,7 +114,7 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
         let nread = {
             let available = try!(self.fill_buf());
             let nread = cmp::min(available.len(), buf.len());
-            slice::bytes::copy_memory(buf, available[..nread]);
+            slice::bytes::copy_memory(buf, available.index(&(0..nread)));
             nread
         };
         self.pos += nread;
@@ -171,7 +168,7 @@ pub fn new(inner: W) -> BufferedWriter<W> {
 
     fn flush_buf(&mut self) -> IoResult<()> {
         if self.pos != 0 {
-            let ret = self.inner.as_mut().unwrap().write(self.buf[..self.pos]);
+            let ret = self.inner.as_mut().unwrap().write(self.buf.index(&(0..self.pos)));
             self.pos = 0;
             ret
         } else {
@@ -263,9 +260,9 @@ impl<W: Writer> Writer for LineBufferedWriter<W> {
     fn write(&mut self, buf: &[u8]) -> IoResult<()> {
         match buf.iter().rposition(|&b| b == b'\n') {
             Some(i) => {
-                try!(self.inner.write(buf[..i + 1]));
+                try!(self.inner.write(buf.index(&(0..(i + 1)))));
                 try!(self.inner.flush());
-                try!(self.inner.write(buf[i + 1..]));
+                try!(self.inner.write(buf.index(&((i + 1)..))));
                 Ok(())
             }
             None => self.inner.write(buf),
@@ -472,41 +469,37 @@ fn test_buffered_writer() {
 
         writer.write(&[0, 1]).unwrap();
         let b: &[_] = &[];
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
 
         writer.write(&[2]).unwrap();
         let b: &[_] = &[0, 1];
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
 
         writer.write(&[3]).unwrap();
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
 
         writer.flush().unwrap();
         let a: &[_] = &[0, 1, 2, 3];
-        assert_eq!(a, writer.get_ref()[]);
+        assert_eq!(a, &writer.get_ref()[]);
 
         writer.write(&[4]).unwrap();
         writer.write(&[5]).unwrap();
-        assert_eq!(a, writer.get_ref()[]);
+        assert_eq!(a, &writer.get_ref()[]);
 
         writer.write(&[6]).unwrap();
         let a: &[_] = &[0, 1, 2, 3, 4, 5];
-        assert_eq!(a,
-                   writer.get_ref()[]);
+        assert_eq!(a, &writer.get_ref()[]);
 
         writer.write(&[7, 8]).unwrap();
         let a: &[_] = &[0, 1, 2, 3, 4, 5, 6];
-        assert_eq!(a,
-                   writer.get_ref()[]);
+        assert_eq!(a, &writer.get_ref()[]);
 
         writer.write(&[9, 10, 11]).unwrap();
         let a: &[_] = &[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11];
-        assert_eq!(a,
-                   writer.get_ref()[]);
+        assert_eq!(a, &writer.get_ref()[]);
 
         writer.flush().unwrap();
-        assert_eq!(a,
-                   writer.get_ref()[]);
+        assert_eq!(a, &writer.get_ref()[]);
     }
 
     #[test]
@@ -514,10 +507,10 @@ fn test_buffered_writer_inner_flushes() {
         let mut w = BufferedWriter::with_capacity(3, Vec::new());
         w.write(&[0, 1]).unwrap();
         let a: &[_] = &[];
-        assert_eq!(a, w.get_ref()[]);
+        assert_eq!(a, &w.get_ref()[]);
         let w = w.into_inner();
         let a: &[_] = &[0, 1];
-        assert_eq!(a, w[]);
+        assert_eq!(a, w.index(&FullRange));
     }
 
     // This is just here to make sure that we don't infinite loop in the
@@ -559,21 +552,21 @@ fn test_line_buffer() {
         let mut writer = LineBufferedWriter::new(Vec::new());
         writer.write(&[0]).unwrap();
         let b: &[_] = &[];
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
         writer.write(&[1]).unwrap();
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
         writer.flush().unwrap();
         let b: &[_] = &[0, 1];
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
         writer.write(&[0, b'\n', 1, b'\n', 2]).unwrap();
         let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n'];
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
         writer.flush().unwrap();
         let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2];
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
         writer.write(&[3, b'\n']).unwrap();
         let b: &[_] = &[0, 1, 0, b'\n', 1, b'\n', 2, 3, b'\n'];
-        assert_eq!(writer.get_ref()[], b);
+        assert_eq!(&writer.get_ref()[], b);
     }
 
     #[test]
@@ -614,14 +607,14 @@ fn test_short_reads() {
     #[test]
     fn read_char_buffered() {
         let buf = [195u8, 159u8];
-        let mut reader = BufferedReader::with_capacity(1, buf[]);
+        let mut reader = BufferedReader::with_capacity(1, buf.index(&FullRange));
         assert_eq!(reader.read_char(), Ok('ß'));
     }
 
     #[test]
     fn test_chars() {
         let buf = [195u8, 159u8, b'a'];
-        let mut reader = BufferedReader::with_capacity(1, buf[]);
+        let mut reader = BufferedReader::with_capacity(1, buf.index(&FullRange));
         let mut it = reader.chars();
         assert_eq!(it.next(), Some(Ok('ß')));
         assert_eq!(it.next(), Some(Ok('a')));
index f47f6237b72910e46568e246a5c8a2175b729d07..bce097e17ef0f8d9573331194830bd5de399c530 100644 (file)
@@ -13,6 +13,7 @@
 use sync::mpsc::{Sender, Receiver};
 use io;
 use option::Option::{None, Some};
+use ops::Index;
 use result::Result::{Ok, Err};
 use slice::{bytes, SliceExt};
 use super::{Buffer, Reader, Writer, IoResult};
@@ -90,7 +91,7 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
                 Some(src) => {
                     let dst = buf.slice_from_mut(num_read);
                     let count = cmp::min(src.len(), dst.len());
-                    bytes::copy_memory(dst, src[..count]);
+                    bytes::copy_memory(dst, src.index(&(0..count)));
                     count
                 },
                 None => 0,
@@ -172,7 +173,7 @@ fn test_rx_reader() {
           tx.send(vec![3u8, 4u8]).unwrap();
           tx.send(vec![5u8, 6u8]).unwrap();
           tx.send(vec![7u8, 8u8]).unwrap();
-        }).detach();
+        });
 
         let mut reader = ChanReader::new(rx);
         let mut buf = [0u8; 3];
@@ -215,7 +216,7 @@ fn test_rx_buffer() {
           tx.send(b"rld\nhow ".to_vec()).unwrap();
           tx.send(b"are you?".to_vec()).unwrap();
           tx.send(b"".to_vec()).unwrap();
-        }).detach();
+        });
 
         let mut reader = ChanReader::new(rx);
 
@@ -234,7 +235,7 @@ fn test_chan_writer() {
         writer.write_be_u32(42).unwrap();
 
         let wanted = vec![0u8, 0u8, 0u8, 42u8];
-        let got = match Thread::spawn(move|| { rx.recv().unwrap() }).join() {
+        let got = match Thread::scoped(move|| { rx.recv().unwrap() }).join() {
             Ok(got) => got,
             Err(_) => panic!(),
         };
index 4691c06c1de16abfa62f6da9b9e815cd43c9aafc..eadca8e42e5505b7305e4097a193c60a74249402 100644 (file)
@@ -156,7 +156,7 @@ pub fn open_mode(path: &Path,
                 })
             }
         }).update_err("couldn't open path as file", |e| {
-            format!("{}; path={}; mode={}; access={}", e, path.display(),
+            format!("{}; path={:?}; mode={}; access={}", e, path.display(),
                 mode_string(mode), access_string(access))
         })
     }
@@ -211,7 +211,7 @@ pub fn path<'a>(&'a self) -> &'a Path {
     pub fn fsync(&mut self) -> IoResult<()> {
         self.fd.fsync()
             .update_err("couldn't fsync file",
-                        |e| format!("{}; path={}", e, self.path.display()))
+                        |e| format!("{}; path={:?}", e, self.path.display()))
     }
 
     /// This function is similar to `fsync`, except that it may not synchronize
@@ -221,7 +221,7 @@ pub fn fsync(&mut self) -> IoResult<()> {
     pub fn datasync(&mut self) -> IoResult<()> {
         self.fd.datasync()
             .update_err("couldn't datasync file",
-                        |e| format!("{}; path={}", e, self.path.display()))
+                        |e| format!("{}; path={:?}", e, self.path.display()))
     }
 
     /// Either truncates or extends the underlying file, updating the size of
@@ -235,7 +235,7 @@ pub fn datasync(&mut self) -> IoResult<()> {
     pub fn truncate(&mut self, size: i64) -> IoResult<()> {
         self.fd.truncate(size)
             .update_err("couldn't truncate file", |e|
-                format!("{}; path={}; size={}", e, self.path.display(), size))
+                format!("{}; path={:?}; size={:?}", e, self.path.display(), size))
     }
 
     /// Returns true if the stream has reached the end of the file.
@@ -255,7 +255,7 @@ pub fn eof(&self) -> bool {
     pub fn stat(&self) -> IoResult<FileStat> {
         self.fd.fstat()
             .update_err("couldn't fstat file", |e|
-                format!("{}; path={}", e, self.path.display()))
+                format!("{}; path={:?}", e, self.path.display()))
     }
 }
 
@@ -283,7 +283,7 @@ pub fn stat(&self) -> IoResult<FileStat> {
 pub fn unlink(path: &Path) -> IoResult<()> {
     fs_imp::unlink(path)
            .update_err("couldn't unlink path", |e|
-               format!("{}; path={}", e, path.display()))
+               format!("{}; path={:?}", e, path.display()))
 }
 
 /// Given a path, query the file system to get information about a file,
@@ -310,7 +310,7 @@ pub fn unlink(path: &Path) -> IoResult<()> {
 pub fn stat(path: &Path) -> IoResult<FileStat> {
     fs_imp::stat(path)
            .update_err("couldn't stat path", |e|
-               format!("{}; path={}", e, path.display()))
+               format!("{}; path={:?}", e, path.display()))
 }
 
 /// Perform the same operation as the `stat` function, except that this
@@ -324,7 +324,7 @@ pub fn stat(path: &Path) -> IoResult<FileStat> {
 pub fn lstat(path: &Path) -> IoResult<FileStat> {
     fs_imp::lstat(path)
            .update_err("couldn't lstat path", |e|
-               format!("{}; path={}", e, path.display()))
+               format!("{}; path={:?}", e, path.display()))
 }
 
 /// Rename a file or directory to a new name.
@@ -346,7 +346,7 @@ pub fn lstat(path: &Path) -> IoResult<FileStat> {
 pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
     fs_imp::rename(from, to)
            .update_err("couldn't rename path", |e|
-               format!("{}; from={}; to={}", e, from.display(), to.display()))
+               format!("{}; from={:?}; to={:?}", e, from.display(), to.display()))
 }
 
 /// Copies the contents of one file to another. This function will also
@@ -380,7 +380,7 @@ pub fn rename(from: &Path, to: &Path) -> IoResult<()> {
 pub fn copy(from: &Path, to: &Path) -> IoResult<()> {
     fn update_err<T>(result: IoResult<T>, from: &Path, to: &Path) -> IoResult<T> {
         result.update_err("couldn't copy path", |e| {
-            format!("{}; from={}; to={}", e, from.display(), to.display())
+            format!("{}; from={:?}; to={:?}", e, from.display(), to.display())
         })
     }
 
@@ -424,14 +424,14 @@ fn update_err<T>(result: IoResult<T>, from: &Path, to: &Path) -> IoResult<T> {
 pub fn chmod(path: &Path, mode: io::FilePermission) -> IoResult<()> {
     fs_imp::chmod(path, mode.bits() as uint)
            .update_err("couldn't chmod path", |e|
-               format!("{}; path={}; mode={}", e, path.display(), mode))
+               format!("{}; path={:?}; mode={:?}", e, path.display(), mode))
 }
 
 /// Change the user and group owners of a file at the specified path.
 pub fn chown(path: &Path, uid: int, gid: int) -> IoResult<()> {
     fs_imp::chown(path, uid, gid)
            .update_err("couldn't chown path", |e|
-               format!("{}; path={}; uid={}; gid={}", e, path.display(), uid, gid))
+               format!("{}; path={:?}; uid={}; gid={}", e, path.display(), uid, gid))
 }
 
 /// Creates a new hard link on the filesystem. The `dst` path will be a
@@ -440,7 +440,7 @@ pub fn chown(path: &Path, uid: int, gid: int) -> IoResult<()> {
 pub fn link(src: &Path, dst: &Path) -> IoResult<()> {
     fs_imp::link(src, dst)
            .update_err("couldn't link path", |e|
-               format!("{}; src={}; dest={}", e, src.display(), dst.display()))
+               format!("{}; src={:?}; dest={:?}", e, src.display(), dst.display()))
 }
 
 /// Creates a new symbolic link on the filesystem. The `dst` path will be a
@@ -448,7 +448,7 @@ pub fn link(src: &Path, dst: &Path) -> IoResult<()> {
 pub fn symlink(src: &Path, dst: &Path) -> IoResult<()> {
     fs_imp::symlink(src, dst)
            .update_err("couldn't symlink path", |e|
-               format!("{}; src={}; dest={}", e, src.display(), dst.display()))
+               format!("{}; src={:?}; dest={:?}", e, src.display(), dst.display()))
 }
 
 /// Reads a symlink, returning the file that the symlink points to.
@@ -460,7 +460,7 @@ pub fn symlink(src: &Path, dst: &Path) -> IoResult<()> {
 pub fn readlink(path: &Path) -> IoResult<Path> {
     fs_imp::readlink(path)
            .update_err("couldn't resolve symlink for path", |e|
-               format!("{}; path={}", e, path.display()))
+               format!("{}; path={:?}", e, path.display()))
 }
 
 /// Create a new, empty directory at the provided path
@@ -483,7 +483,7 @@ pub fn readlink(path: &Path) -> IoResult<Path> {
 pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
     fs_imp::mkdir(path, mode.bits() as uint)
            .update_err("couldn't create directory", |e|
-               format!("{}; path={}; mode={}", e, path.display(), mode))
+               format!("{}; path={:?}; mode={:?}", e, path.display(), mode))
 }
 
 /// Remove an existing, empty directory
@@ -505,7 +505,7 @@ pub fn mkdir(path: &Path, mode: FilePermission) -> IoResult<()> {
 pub fn rmdir(path: &Path) -> IoResult<()> {
     fs_imp::rmdir(path)
            .update_err("couldn't remove directory", |e|
-               format!("{}; path={}", e, path.display()))
+               format!("{}; path={:?}", e, path.display()))
 }
 
 /// Retrieve a vector containing all entries within a provided directory
@@ -545,7 +545,7 @@ pub fn rmdir(path: &Path) -> IoResult<()> {
 pub fn readdir(path: &Path) -> IoResult<Vec<Path>> {
     fs_imp::readdir(path)
            .update_err("couldn't read directory",
-                       |e| format!("{}; path={}", e, path.display()))
+                       |e| format!("{}; path={:?}", e, path.display()))
 }
 
 /// Returns an iterator that will recursively walk the directory structure
@@ -555,7 +555,7 @@ pub fn readdir(path: &Path) -> IoResult<Vec<Path>> {
 pub fn walk_dir(path: &Path) -> IoResult<Directories> {
     Ok(Directories {
         stack: try!(readdir(path).update_err("couldn't walk directory",
-                                             |e| format!("{}; path={}", e, path.display())))
+                                             |e| format!("{}; path={:?}", e, path.display())))
     })
 }
 
@@ -605,7 +605,7 @@ pub fn mkdir_recursive(path: &Path, mode: FilePermission) -> IoResult<()> {
 
         let result = mkdir(&curpath, mode)
             .update_err("couldn't recursively mkdir",
-                        |e| format!("{}; path={}", e, path.display()));
+                        |e| format!("{}; path={:?}", e, path.display()));
 
         match result {
             Err(mkdir_err) => {
@@ -632,7 +632,7 @@ pub fn rmdir_recursive(path: &Path) -> IoResult<()> {
     rm_stack.push(path.clone());
 
     fn rmdir_failed(err: &IoError, path: &Path) -> String {
-        format!("rmdir_recursive failed; path={}; cause={}",
+        format!("rmdir_recursive failed; path={:?}; cause={}",
                 path.display(), err)
     }
 
@@ -692,14 +692,14 @@ fn update_err<T>(err: IoResult<T>, path: &Path) -> IoResult<T> {
 pub fn change_file_times(path: &Path, atime: u64, mtime: u64) -> IoResult<()> {
     fs_imp::utime(path, atime, mtime)
            .update_err("couldn't change_file_times", |e|
-               format!("{}; path={}", e, path.display()))
+               format!("{}; path={:?}", e, path.display()))
 }
 
 impl Reader for File {
     fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
         fn update_err<T>(result: IoResult<T>, file: &File) -> IoResult<T> {
             result.update_err("couldn't read file",
-                              |e| format!("{}; path={}",
+                              |e| format!("{}; path={:?}",
                                           e, file.path.display()))
         }
 
@@ -722,7 +722,7 @@ impl Writer for File {
     fn write(&mut self, buf: &[u8]) -> IoResult<()> {
         self.fd.write(buf)
             .update_err("couldn't write to file",
-                        |e| format!("{}; path={}", e, self.path.display()))
+                        |e| format!("{}; path={:?}", e, self.path.display()))
     }
 }
 
@@ -730,7 +730,7 @@ impl Seek for File {
     fn tell(&self) -> IoResult<u64> {
         self.fd.tell()
             .update_err("couldn't retrieve file cursor (`tell`)",
-                        |e| format!("{}; path={}", e, self.path.display()))
+                        |e| format!("{}; path={:?}", e, self.path.display()))
     }
 
     fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> {
@@ -743,7 +743,7 @@ fn seek(&mut self, pos: i64, style: SeekStyle) -> IoResult<()> {
             Err(e) => Err(e),
         };
         err.update_err("couldn't seek in file",
-                       |e| format!("{}; path={}", e, self.path.display()))
+                       |e| format!("{}; path={:?}", e, self.path.display()))
     }
 }
 
@@ -832,13 +832,13 @@ mod test {
     macro_rules! check { ($e:expr) => (
         match $e {
             Ok(t) => t,
-            Err(e) => panic!("{} failed with: {}", stringify!($e), e),
+            Err(e) => panic!("{} failed with: {:?}", stringify!($e), e),
         }
     ) }
 
     macro_rules! error { ($e:expr, $s:expr) => (
         match $e {
-            Ok(_) => panic!("Unexpected success. Should've been: {}", $s),
+            Ok(_) => panic!("Unexpected success. Should've been: {:?}", $s),
             Err(ref err) => assert!(err.to_string().contains($s.as_slice()),
                                     format!("`{}` did not contain `{}`", err, $s))
         }
@@ -889,7 +889,7 @@ fn file_test_io_smoke_test() {
             let mut read_buf = [0; 1028];
             let read_str = match check!(read_stream.read(&mut read_buf)) {
                 -1|0 => panic!("shouldn't happen"),
-                n => str::from_utf8(read_buf[..n]).unwrap().to_string()
+                n => str::from_utf8(read_buf.index(&(0..n))).unwrap().to_string()
             };
             assert_eq!(read_str.as_slice(), message);
         }
@@ -906,7 +906,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]
@@ -920,7 +920,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]
@@ -1188,7 +1188,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,7 +1255,7 @@ fn copy_file_does_not_exist() {
 
         error!(copy(&from, &to),
             format!("couldn't copy path (the source path is not an \
-                    existing file; from={}; to={})",
+                    existing file; from={:?}; to={:?})",
                     from.display(), to.display()));
 
         match copy(&from, &to) {
index 5c17644a1ace7834e118dfdd53cd0d00534d2471..9a6ad04fdbc3eb1687fd43494cde57376d446c6f 100644 (file)
@@ -13,6 +13,7 @@
 //! Readers and Writers for in-memory buffers
 
 use cmp::min;
+use ops::Index;
 use option::Option::None;
 use result::Result::{Err, Ok};
 use io;
@@ -159,7 +160,7 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 
         let write_len = min(buf.len(), self.buf.len() - self.pos);
         {
-            let input = self.buf[self.pos.. self.pos + write_len];
+            let input = self.buf.index(&(self.pos.. (self.pos + write_len)));
             let output = buf.slice_to_mut(write_len);
             assert_eq!(input.len(), output.len());
             slice::bytes::copy_memory(output, input);
@@ -187,7 +188,7 @@ impl Buffer for MemReader {
     #[inline]
     fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> {
         if self.pos < self.buf.len() {
-            Ok(self.buf[self.pos..])
+            Ok(self.buf.index(&(self.pos..)))
         } else {
             Err(io::standard_error(io::EndOfFile))
         }
@@ -204,7 +205,7 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 
         let write_len = min(buf.len(), self.len());
         {
-            let input = self[..write_len];
+            let input = self.index(&(0..write_len));
             let output = buf.slice_to_mut(write_len);
             slice::bytes::copy_memory(output, input);
         }
@@ -227,7 +228,7 @@ fn fill_buf(&mut self) -> IoResult<&[u8]> {
 
     #[inline]
     fn consume(&mut self, amt: uint) {
-        *self = self[amt..];
+        *self = self.index(&(amt..));
     }
 }
 
@@ -286,7 +287,7 @@ fn write(&mut self, src: &[u8]) -> IoResult<()> {
 
             Ok(())
         } else {
-            slice::bytes::copy_memory(dst, src[..dst_len]);
+            slice::bytes::copy_memory(dst, src.index(&(0..dst_len)));
 
             self.pos += dst_len;
 
@@ -349,7 +350,7 @@ fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> {
 
         let write_len = min(buf.len(), self.buf.len() - self.pos);
         {
-            let input = self.buf[self.pos.. self.pos + write_len];
+            let input = self.buf.index(&(self.pos.. (self.pos + write_len)));
             let output = buf.slice_to_mut(write_len);
             assert_eq!(input.len(), output.len());
             slice::bytes::copy_memory(output, input);
@@ -377,7 +378,7 @@ impl<'a> Buffer for BufReader<'a> {
     #[inline]
     fn fill_buf(&mut self) -> IoResult<&[u8]> {
         if self.pos < self.buf.len() {
-            Ok(self.buf[self.pos..])
+            Ok(self.buf.index(&(self.pos..)))
         } else {
             Err(io::standard_error(io::EndOfFile))
         }
@@ -390,9 +391,9 @@ fn fill_buf(&mut self) -> IoResult<&[u8]> {
 #[cfg(test)]
 mod test {
     extern crate "test" as test_crate;
-    use prelude::v1::*;
-
-    use io::{SeekSet, SeekCur, SeekEnd};
+    use io::{SeekSet, SeekCur, SeekEnd, Reader, Writer, Seek};
+    use prelude::v1::{Ok, Err, range,  Vec, Buffer,  AsSlice, SliceExt};
+    use prelude::v1::{IteratorExt, Index};
     use io;
     use iter::repeat;
     use self::test_crate::Bencher;
@@ -498,7 +499,7 @@ fn test_mem_reader() {
         assert_eq!(buf, b);
         assert_eq!(reader.read(&mut buf), Ok(3));
         let b: &[_] = &[5, 6, 7];
-        assert_eq!(buf[0..3], b);
+        assert_eq!(buf.index(&(0..3)), b);
         assert!(reader.read(&mut buf).is_err());
         let mut reader = MemReader::new(vec!(0, 1, 2, 3, 4, 5, 6, 7));
         assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
@@ -524,7 +525,7 @@ fn test_slice_reader() {
         assert_eq!(buf.as_slice(), b);
         assert_eq!(reader.read(&mut buf), Ok(3));
         let b: &[_] = &[5, 6, 7];
-        assert_eq!(buf[0..3], b);
+        assert_eq!(buf.index(&(0..3)), b);
         assert!(reader.read(&mut buf).is_err());
         let mut reader = &mut in_buf.as_slice();
         assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
@@ -551,7 +552,7 @@ fn test_buf_reader() {
         assert_eq!(buf, b);
         assert_eq!(reader.read(&mut buf), Ok(3));
         let b: &[_] = &[5, 6, 7];
-        assert_eq!(buf[0..3], b);
+        assert_eq!(buf.index(&(0..3)), b);
         assert!(reader.read(&mut buf).is_err());
         let mut reader = BufReader::new(in_buf.as_slice());
         assert_eq!(reader.read_until(3).unwrap(), vec!(0, 1, 2, 3));
index 5bef473db990c8879a7fcb23d801ad6a88321769..9ef9081bc3c848e443ce6921ca52772dc077b17b 100644 (file)
 //!     for stream in acceptor.incoming() {
 //!         match stream {
 //!             Err(e) => { /* connection failed */ }
-//!             Ok(stream) => Thread::spawn(move|| {
-//!                 // connection succeeded
-//!                 handle_client(stream)
-//!             }).detach()
+//!             Ok(stream) => {
+//!                 Thread::spawn(move|| {
+//!                     // connection succeeded
+//!                     handle_client(stream)
+//!                 });
+//!             }
 //!         }
 //!     }
 //!
 use fmt;
 use int;
 use iter::{Iterator, IteratorExt};
-use kinds::Sized;
+use marker::Sized;
 use mem::transmute;
-use ops::FnOnce;
+use ops::{FnOnce, Index};
 use option::Option;
 use option::Option::{Some, None};
 use os;
 pub mod timer;
 pub mod util;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod test;
 
 /// The default buffer size for various I/O operations
 /// # FIXME
 ///
 /// Is something like this sufficient? It's kind of archaic
-#[derive(PartialEq, Eq, Clone)]
+#[derive(PartialEq, Eq, Clone, Show)]
 pub struct IoError {
     /// An enumeration which can be matched against for determining the flavor
     /// of error.
@@ -339,7 +340,7 @@ pub fn last_error() -> IoError {
     }
 }
 
-impl fmt::Show for IoError {
+impl fmt::String for IoError {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             IoError { kind: OtherIoError, desc: "unknown error", detail: Some(ref detail) } =>
@@ -1068,7 +1069,7 @@ fn write_line(&mut self, s: &str) -> IoResult<()> {
     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);
-        self.write(buf[..n])
+        self.write(buf.index(&(0..n)))
     }
 
     /// Write the result of passing n through `int::to_str_bytes`.
@@ -1453,7 +1454,7 @@ fn read_until(&mut self, byte: u8) -> IoResult<Vec<u8>> {
                 };
                 match available.iter().position(|&b| b == byte) {
                     Some(i) => {
-                        res.push_all(available[..i + 1]);
+                        res.push_all(available.index(&(0..(i + 1))));
                         used = i + 1;
                         break
                     }
@@ -1492,7 +1493,7 @@ fn read_char(&mut self) -> IoResult<char> {
                 }
             }
         }
-        match str::from_utf8(buf[..width]).ok() {
+        match str::from_utf8(buf.index(&(0..width))).ok() {
             Some(s) => Ok(s.char_at(0)),
             None => Err(standard_error(InvalidInput))
         }
@@ -1604,6 +1605,7 @@ pub struct IncomingConnections<'a, A: ?Sized +'a> {
     inc: &'a mut A,
 }
 
+#[old_impl_check]
 impl<'a, T, A: ?Sized + Acceptor<T>> Iterator for IncomingConnections<'a, A> {
     type Item = IoResult<T>;
 
@@ -1656,7 +1658,7 @@ pub fn standard_error(kind: IoErrorKind) -> IoError {
 /// A mode specifies how a file should be opened or created. These modes are
 /// passed to `File::open_mode` and are used to control where the file is
 /// positioned when it is initially opened.
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone, PartialEq, Eq, Show)]
 pub enum FileMode {
     /// Opens a file positioned at the beginning.
     Open,
@@ -1668,7 +1670,7 @@ pub enum FileMode {
 
 /// Access permissions with which the file should be opened. `File`s
 /// opened with `Read` will return an error if written to.
-#[derive(Copy, Clone, PartialEq, Eq)]
+#[derive(Copy, Clone, PartialEq, Eq, Show)]
 pub enum FileAccess {
     /// Read-only access, requests to write will result in an error
     Read,
@@ -1780,9 +1782,11 @@ pub struct UnstableFileStat {
     pub gen: u64,
 }
 
+
+// NOTE(stage0): change this one last #[doc=..] to /// after the next snapshot
 bitflags! {
-    #[doc = "A set of permissions for a file or directory is represented"]
-    #[doc = "by a set of flags which are or'd together."]
+    #[doc = "A set of permissions for a file or directory is represented by a set of"]
+    /// flags which are or'd together.
     flags FilePermission: u32 {
         const USER_READ     = 0o400,
         const USER_WRITE    = 0o200,
@@ -1798,20 +1802,20 @@ pub struct UnstableFileStat {
         const GROUP_RWX = GROUP_READ.bits | GROUP_WRITE.bits | GROUP_EXECUTE.bits,
         const OTHER_RWX = OTHER_READ.bits | OTHER_WRITE.bits | OTHER_EXECUTE.bits,
 
-        #[doc = "Permissions for user owned files, equivalent to 0644 on"]
-        #[doc = "unix-like systems."]
+        /// Permissions for user owned files, equivalent to 0644 on unix-like
+        /// systems.
         const USER_FILE = USER_READ.bits | USER_WRITE.bits | GROUP_READ.bits | OTHER_READ.bits,
 
-        #[doc = "Permissions for user owned directories, equivalent to 0755 on"]
-        #[doc = "unix-like systems."]
+        /// Permissions for user owned directories, equivalent to 0755 on
+        /// unix-like systems.
         const USER_DIR  = USER_RWX.bits | GROUP_READ.bits | GROUP_EXECUTE.bits |
                    OTHER_READ.bits | OTHER_EXECUTE.bits,
 
-        #[doc = "Permissions for user owned executables, equivalent to 0755"]
-        #[doc = "on unix-like systems."]
+        /// Permissions for user owned executables, equivalent to 0755
+        /// on unix-like systems.
         const USER_EXEC = USER_DIR.bits,
 
-        #[doc = "All possible permissions enabled."]
+        /// All possible permissions enabled.
         const ALL_PERMISSIONS = USER_RWX.bits | GROUP_RWX.bits | OTHER_RWX.bits,
     }
 }
@@ -1825,6 +1829,12 @@ fn default() -> FilePermission { FilePermission::empty() }
 }
 
 impl fmt::Show for FilePermission {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for FilePermission {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{:04o}", self.bits)
     }
index 24d45dcd65275a5a7531d34048ee3db7a6c21150..7825a4e16e161d5b0a46c46f386e9ccea7be772a 100644 (file)
@@ -29,7 +29,7 @@
 use vec::Vec;
 
 /// Hints to the types of sockets that are desired when looking up hosts
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub enum SocketType {
     Stream, Datagram, Raw
 }
@@ -38,7 +38,7 @@ pub enum SocketType {
 /// to manipulate how a query is performed.
 ///
 /// The meaning of each of these flags can be found with `man -s 3 getaddrinfo`
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub enum Flag {
     AddrConfig,
     All,
@@ -51,7 +51,7 @@ pub enum Flag {
 
 /// A transport protocol associated with either a hint or a return value of
 /// `lookup`
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub enum Protocol {
     TCP, UDP
 }
@@ -61,7 +61,7 @@ pub enum Protocol {
 ///
 /// For details on these fields, see their corresponding definitions via
 /// `man -s 3 getaddrinfo`
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub struct Hint {
     pub family: uint,
     pub socktype: Option<SocketType>,
@@ -69,7 +69,7 @@ pub struct Hint {
     pub flags: uint,
 }
 
-#[derive(Copy)]
+#[derive(Copy, Show)]
 pub struct Info {
     pub address: SocketAddr,
     pub family: uint,
index d398b61fe64cf8596d7926626ffd1eca5c03ac22..b9f653f86c2b0b514fd6aee236feacb79671d26b 100644 (file)
@@ -22,7 +22,7 @@
 use io::{self, IoResult, IoError};
 use io::net;
 use iter::{Iterator, IteratorExt};
-use ops::{FnOnce, FnMut};
+use ops::{FnOnce, FnMut, Index};
 use option::Option;
 use option::Option::{None, Some};
 use result::Result::{Ok, Err};
 
 pub type Port = u16;
 
-#[derive(Copy, PartialEq, Eq, Clone, Hash)]
+#[derive(Copy, PartialEq, Eq, Clone, Hash, Show)]
 pub enum IpAddr {
     Ipv4Addr(u8, u8, u8, u8),
     Ipv6Addr(u16, u16, u16, u16, u16, u16, u16, u16)
 }
 
-impl fmt::Show for IpAddr {
+impl fmt::String for IpAddr {
     fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             Ipv4Addr(a, b, c, d) =>
@@ -63,13 +63,13 @@ fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
-#[derive(Copy, PartialEq, Eq, Clone, Hash)]
+#[derive(Copy, PartialEq, Eq, Clone, Hash, Show)]
 pub struct SocketAddr {
     pub ip: IpAddr,
     pub port: Port,
 }
 
-impl fmt::Show for SocketAddr {
+impl fmt::String for SocketAddr {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match self.ip {
             Ipv4Addr(..) => write!(f, "{}:{}", self.ip, self.port),
@@ -313,7 +313,7 @@ fn ipv6_addr_from_head_tail(head: &[u16], tail: &[u16]) -> IpAddr {
 
         let mut tail = [0u16; 8];
         let (tail_size, _) = read_groups(self, &mut tail, 8 - head_size);
-        Some(ipv6_addr_from_head_tail(head[..head_size], tail[..tail_size]))
+        Some(ipv6_addr_from_head_tail(head.index(&(0..head_size)), tail.index(&(0..tail_size))))
     }
 
     fn read_ipv6_addr(&mut self) -> Option<IpAddr> {
index 738c70412f78a0aa3def5993a313879ecdeed747..29295b5751cd4c92aec5c684ac8b8106d057a9d6 100644 (file)
@@ -608,7 +608,7 @@ fn close_readwrite_smoke() {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut b = [0];
         let mut s = UnixStream::connect(&addr).unwrap();
@@ -645,7 +645,7 @@ fn close_read_wakes_up() {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = UnixStream::connect(&addr).unwrap();
         let s2 = s.clone();
@@ -672,7 +672,7 @@ fn readwrite_timeouts() {
             rx.recv().unwrap();
             assert!(s.write(&[0]).is_ok());
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         s.set_timeout(Some(20));
@@ -716,7 +716,7 @@ fn read_timeouts() {
                 }
             }
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         s.set_read_timeout(Some(20));
@@ -739,7 +739,7 @@ fn write_timeouts() {
             rx.recv().unwrap();
             assert!(s.write(&[0]).is_ok());
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         s.set_write_timeout(Some(20));
@@ -766,7 +766,7 @@ fn timeout_concurrent_read() {
             rx.recv().unwrap();
             assert!(s.write(&[0]).is_ok());
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         let s2 = s.clone();
index 3e59aaa05efd285d8b7f5f3af68273e0d6ac5f37..7a376b50cd7dd9ad8705684c93bb89bfee84b263 100644 (file)
@@ -146,7 +146,7 @@ pub fn set_keepalive(&mut self, delay_in_seconds: Option<uint>) -> IoResult<()>
     ///     timer::sleep(Duration::seconds(1));
     ///     let mut stream = stream2;
     ///     stream.close_read();
-    /// }).detach();
+    /// });
     ///
     /// // wait for some data, will get canceled after one second
     /// let mut buf = [0];
@@ -295,10 +295,12 @@ fn as_inner(&self) -> &TcpStreamImp {
 /// for stream in acceptor.incoming() {
 ///     match stream {
 ///         Err(e) => { /* connection failed */ }
-///         Ok(stream) => Thread::spawn(move|| {
-///             // connection succeeded
-///             handle_client(stream)
-///         }).detach()
+///         Ok(stream) => {
+///             Thread::spawn(move|| {
+///                 // connection succeeded
+///                 handle_client(stream)
+///             });
+///         }
 ///     }
 /// }
 ///
@@ -432,7 +434,7 @@ impl TcpAcceptor {
     ///             Err(e) => panic!("unexpected error: {}", e),
     ///         }
     ///     }
-    /// }).detach();
+    /// });
     ///
     /// # fn wait_for_sigint() {}
     /// // Now that our accept loop is running, wait for the program to be
@@ -660,7 +662,7 @@ fn read_eof_twice_ip4() {
             Ok(..) => panic!(),
             Err(ref e) => {
                 assert!(e.kind == NotConnected || e.kind == EndOfFile,
-                        "unknown kind: {}", e.kind);
+                        "unknown kind: {:?}", e.kind);
             }
         }
     }
@@ -684,7 +686,7 @@ fn read_eof_twice_ip6() {
             Ok(..) => panic!(),
             Err(ref e) => {
                 assert!(e.kind == NotConnected || e.kind == EndOfFile,
-                        "unknown kind: {}", e.kind);
+                        "unknown kind: {:?}", e.kind);
             }
         }
     }
@@ -997,7 +999,7 @@ fn double_bind() {
             Ok(..) => panic!(),
             Err(e) => {
                 assert!(e.kind == ConnectionRefused || e.kind == OtherIoError,
-                        "unknown error: {} {}", e, e.kind);
+                        "unknown error: {} {:?}", e, e.kind);
             }
         }
     }
@@ -1186,7 +1188,7 @@ fn close_readwrite_smoke() {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv().unwrap();
-        }).detach();
+        });
 
         let mut b = [0];
         let mut s = TcpStream::connect(addr).unwrap();
@@ -1223,7 +1225,7 @@ fn close_read_wakes_up() {
             let mut a = a;
             let _s = a.accept().unwrap();
             let _ = rx.recv().unwrap();
-        }).detach();
+        });
 
         let mut s = TcpStream::connect(addr).unwrap();
         let s2 = s.clone();
@@ -1250,7 +1252,7 @@ fn readwrite_timeouts() {
             rx.recv().unwrap();
             assert!(s.write(&[0]).is_ok());
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         s.set_timeout(Some(20));
@@ -1289,7 +1291,7 @@ fn read_timeouts() {
                 }
             }
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         s.set_read_timeout(Some(20));
@@ -1312,7 +1314,7 @@ fn write_timeouts() {
             rx.recv().unwrap();
             assert!(s.write(&[0]).is_ok());
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         s.set_write_timeout(Some(20));
@@ -1340,7 +1342,7 @@ fn timeout_concurrent_read() {
             rx.recv().unwrap();
             assert_eq!(s.write(&[0]), Ok(()));
             let _ = rx.recv();
-        }).detach();
+        });
 
         let mut s = a.accept().unwrap();
         let s2 = s.clone();
index ea232ad0c3f1b0876b1d860fb1dd1447397b7d1f..55df6330dd33c463bec0e55d5d005b3573651fb8 100644 (file)
@@ -395,7 +395,14 @@ pub fn status(&self) -> IoResult<ProcessExit> {
     }
 }
 
+#[cfg(stage0)]
 impl fmt::Show for Command {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for Command {
     /// Format the program and arguments of a Command for display. Any
     /// non-utf8 data is lossily converted using the utf8 replacement
     /// character.
@@ -504,6 +511,14 @@ pub enum ProcessExit {
 }
 
 impl fmt::Show for ProcessExit {
+    /// Format a ProcessExit enum, to nicely present the information.
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+
+impl fmt::String for ProcessExit {
     /// Format a ProcessExit enum, to nicely present the information.
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
@@ -705,7 +720,7 @@ fn read(stream: Option<io::PipeStream>) -> Receiver<IoResult<Vec<u8>>> {
                     Thread::spawn(move |:| {
                         let mut stream = stream;
                         tx.send(stream.read_to_end()).unwrap();
-                    }).detach();
+                    });
                 }
                 None => tx.send(Ok(Vec::new())).unwrap()
             }
@@ -752,12 +767,12 @@ fn drop(&mut self) {
 
 #[cfg(test)]
 mod tests {
-    use prelude::v1::*;
-
+    use io::{Truncate, Write, TimedOut, timer, process, FileNotFound};
+    use prelude::v1::{Ok, Err, range, drop, Some, None, Vec};
+    use prelude::v1::{Path, String, Reader, Writer, Clone};
+    use prelude::v1::{SliceExt, Str, StrExt, AsSlice, ToString, GenericPath};
     use io::fs::PathExtensions;
-    use io::process;
     use io::timer::*;
-    use io::{Truncate, Write, TimedOut, timer, FileNotFound};
     use rt::running_on_valgrind;
     use str;
     use super::{CreatePipe};
index f571bed3ba2264c58893bd7a1db5ef9207ae8ebd..9ee2f5705b82824ebd2110814539004795037b4d 100644 (file)
@@ -34,7 +34,7 @@
 use fmt;
 use io::{Reader, Writer, IoResult, IoError, OtherIoError, Buffer,
          standard_error, EndOfFile, LineBufferedWriter, BufferedReader};
-use kinds::{Sync, Send};
+use marker::{Sync, Send};
 use libc;
 use mem;
 use option::Option;
@@ -349,7 +349,7 @@ fn with_task_stdout<F>(f: F) where F: FnOnce(&mut Writer) -> IoResult<()> {
     });
     match result {
         Ok(()) => {}
-        Err(e) => panic!("failed printing to stdout: {}", e),
+        Err(e) => panic!("failed printing to stdout: {:?}", e),
     }
 }
 
index e073f76af825ce77628696d262a99af136589f6b..8a0445be47135775ba1483c0371457c231785eed 100644 (file)
@@ -358,7 +358,7 @@ fn closing_channel_during_drop_doesnt_kill_everything() {
 
         Thread::spawn(move|| {
             let _ = timer_rx.recv();
-        }).detach();
+        });
 
         // when we drop the TimerWatcher we're going to destroy the channel,
         // which must wake up the task on the other end
@@ -372,7 +372,7 @@ fn reset_doesnt_switch_tasks() {
 
         Thread::spawn(move|| {
             let _ = timer_rx.recv();
-        }).detach();
+        });
 
         timer.oneshot(Duration::milliseconds(1));
     }
@@ -385,7 +385,7 @@ fn reset_doesnt_switch_tasks2() {
 
         Thread::spawn(move|| {
             let _ = timer_rx.recv();
-        }).detach();
+        });
 
         timer.sleep(Duration::milliseconds(1));
     }
index 86fa68d63ac899ac1db577153a3915fce49bc415..c0254a3e7a205a01382c9e9c649f79822348de10 100644 (file)
@@ -59,7 +59,7 @@ fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
 impl<R: Buffer> Buffer for LimitReader<R> {
     fn fill_buf<'a>(&'a mut self) -> io::IoResult<&'a [u8]> {
         let amt = try!(self.inner.fill_buf());
-        let buf = amt[..cmp::min(amt.len(), self.limit)];
+        let buf = amt.index(&(0..cmp::min(amt.len(), self.limit)));
         if buf.len() == 0 {
             Err(io::standard_error(io::EndOfFile))
         } else {
@@ -220,7 +220,7 @@ pub fn into_inner(self) -> (R, W) {
 impl<R: Reader, W: Writer> Reader for TeeReader<R, W> {
     fn read(&mut self, buf: &mut [u8]) -> io::IoResult<uint> {
         self.reader.read(buf).and_then(|len| {
-            self.writer.write(buf[mut ..len]).map(|()| len)
+            self.writer.write(buf.index_mut(&(0..len))).map(|()| len)
         })
     }
 }
@@ -234,7 +234,7 @@ pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> {
             Err(ref e) if e.kind == io::EndOfFile => return Ok(()),
             Err(e) => return Err(e),
         };
-        try!(w.write(buf[..len]));
+        try!(w.write(buf.index(&(0..len))));
     }
 }
 
index b9f226c5aca73e83a227f4fc81b1116bc4cf5a0d..eef5bdb60eeaae2fe7cc6f448c9739c8237b5165 100644 (file)
@@ -18,7 +18,7 @@
 //!
 //! The [`ptr`](ptr/index.html) and [`mem`](mem/index.html)
 //! modules deal with unsafe pointers and memory manipulation.
-//! [`kinds`](kinds/index.html) defines the special built-in traits,
+//! [`markers`](markers/index.html) defines the special built-in traits,
 //! and [`raw`](raw/index.html) the runtime representation of Rust types.
 //! These are some of the lowest-level building blocks in Rust.
 //!
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![allow(unknown_features)]
-#![feature(macro_rules, globs, linkage, thread_local, asm)]
-#![feature(default_type_params, phase, lang_items, unsafe_destructor)]
+#![feature(linkage, thread_local, asm)]
+#![feature(lang_items, unsafe_destructor)]
 #![feature(slicing_syntax, unboxed_closures)]
-#![feature(old_orphan_check)]
-#![feature(associated_types)]
+#![feature(old_impl_check)]
+#![cfg_attr(stage0, allow(unused_attributes))]
 
 // Don't link to std. We are std.
 #![no_std]
 
 #![deny(missing_docs)]
 
-#![reexport_test_harness_main = "test_main"]
-
-#[cfg(all(test, stage0))]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(all(test, not(stage0)))]
+#[cfg(test)]
 #[macro_use]
 extern crate log;
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate core;
-
-#[cfg(not(stage0))]
 #[macro_use]
 #[macro_reexport(assert, assert_eq, debug_assert, debug_assert_eq,
-    unreachable, unimplemented, write, writeln)]
+                 unreachable, unimplemented, write, writeln)]
 extern crate core;
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate "collections" as core_collections;
-
-#[cfg(not(stage0))]
 #[macro_use]
 #[macro_reexport(vec)]
 extern crate "collections" as core_collections;
 
 // Make std testable by not duplicating lang items. See #2912
 #[cfg(test)] extern crate "std" as realstd;
-#[cfg(test)] pub use realstd::kinds;
+#[cfg(test)] pub use realstd::marker;
 #[cfg(test)] pub use realstd::ops;
 #[cfg(test)] pub use realstd::cmp;
 #[cfg(test)] pub use realstd::boxed;
 pub use core::finally;
 pub use core::intrinsics;
 pub use core::iter;
-#[cfg(not(test))] pub use core::kinds;
+#[cfg(stage0)] #[cfg(not(test))] pub use core::marker as kinds;
+#[cfg(not(test))] pub use core::marker;
 pub use core::mem;
 #[cfg(not(test))] pub use core::ops;
 pub use core::ptr;
 
 /* Exported macros */
 
-#[cfg(stage0)]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
-pub mod macros_stage0;
-
-#[cfg(not(stage0))]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod macros;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod bitflags;
 
 mod rtdeps;
 /* Primitive types */
 
 #[path = "num/float_macros.rs"]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod float_macros;
 
 #[path = "num/int_macros.rs"]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod int_macros;
 
 #[path = "num/uint_macros.rs"]
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod uint_macros;
 
 #[path = "num/int.rs"]  pub mod int;
 
 /* Runtime and platform support */
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod thread_local;
 
 pub mod dynamic_lib;
@@ -311,7 +284,9 @@ mod std {
     pub use vec; // used for vec![]
     pub use cell; // used for tls!
     pub use thread_local; // used for thread_local!
-    pub use kinds; // used for tls!
+    #[cfg(stage0)]
+    pub use marker as kinds;
+    pub use marker;  // used for tls!
     pub use ops; // used for bitflags!
 
     // The test runner calls ::std::os::args() but really wants realstd
index d96441e09a813efa82ee5c66384c11074d90416c..befdc156094d18406d32d754c5e36966c21254f7 100644 (file)
@@ -111,7 +111,7 @@ macro_rules! assert_eq {
                 if !((*left_val == *right_val) &&
                      (*right_val == *left_val)) {
                     panic!("assertion failed: `(left == right) && (right == left)` \
-                           (left: `{}`, right: `{}`)", *left_val, *right_val)
+                           (left: `{:?}`, right: `{:?}`)", *left_val, *right_val)
                 }
             }
         }
@@ -303,8 +303,8 @@ macro_rules! try {
 /// # fn long_running_task() {}
 /// # fn calculate_the_answer() -> int { 42i }
 ///
-/// Thread::spawn(move|| { long_running_task(); tx1.send(()) }).detach();
-/// Thread::spawn(move|| { tx2.send(calculate_the_answer()) }).detach();
+/// Thread::spawn(move|| { long_running_task(); tx1.send(()).unwrap(); });
+/// Thread::spawn(move|| { tx2.send(calculate_the_answer()).unwrap(); });
 ///
 /// select! (
 ///     _ = rx1.recv() => println!("the long running task finished first"),
@@ -371,7 +371,7 @@ pub mod builtin {
     ///
     /// ```
     #[macro_export]
-    macro_rules! format_args { ($fmt:expr $($args:tt)*) => ({
+    macro_rules! format_args { ($fmt:expr, $($args:tt)*) => ({
         /* compiler built-in */
     }) }
 
@@ -407,7 +407,7 @@ macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }
     ///
     /// ```rust
     /// let key: Option<&'static str> = option_env!("SECRET_KEY");
-    /// println!("the secret key might be: {}", key);
+    /// println!("the secret key might be: {:?}", key);
     /// ```
     #[macro_export]
     macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
diff --git a/src/libstd/macros_stage0.rs b/src/libstd/macros_stage0.rs
deleted file mode 100644 (file)
index 48d62e7..0000000
+++ /dev/null
@@ -1,648 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// 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.
-
-//! Standard library macros
-//!
-//! This modules contains a set of macros which are exported from the standard
-//! library. Each macro is available for use when linking against the standard
-//! library.
-
-#![experimental]
-
-/// The entry point for panic of Rust tasks.
-///
-/// This macro is used to inject panic into a Rust task, causing the task to
-/// unwind and panic entirely. Each task's panic can be reaped as the
-/// `Box<Any>` type, and the single-argument form of the `panic!` macro will be
-/// the value which is transmitted.
-///
-/// The multi-argument form of this macro panics with a string and has the
-/// `format!` syntax for building a string.
-///
-/// # Example
-///
-/// ```should_fail
-/// # #![allow(unreachable_code)]
-/// panic!();
-/// panic!("this is a terrible mistake!");
-/// panic!(4i); // panic with the value of 4 to be collected elsewhere
-/// panic!("this is a {} {message}", "fancy", message = "message");
-/// ```
-#[macro_export]
-macro_rules! panic {
-    () => ({
-        panic!("explicit panic")
-    });
-    ($msg:expr) => ({
-        // static requires less code at runtime, more constant data
-        static _FILE_LINE: (&'static str, uint) = (file!(), line!());
-        ::std::rt::begin_unwind($msg, &_FILE_LINE)
-    });
-    ($fmt:expr, $($arg:tt)*) => ({
-        // The leading _'s are to avoid dead code warnings if this is
-        // used inside a dead function. Just `#[allow(dead_code)]` is
-        // insufficient, since the user may have
-        // `#[forbid(dead_code)]` and which cannot be overridden.
-        static _FILE_LINE: (&'static str, uint) = (file!(), line!());
-        ::std::rt::begin_unwind_fmt(format_args!($fmt, $($arg)*), &_FILE_LINE)
-
-    });
-}
-
-/// Ensure that a boolean expression is `true` at runtime.
-///
-/// This will invoke the `panic!` macro if the provided expression cannot be
-/// evaluated to `true` at runtime.
-///
-/// # Example
-///
-/// ```
-/// // the panic message for these assertions is the stringified value of the
-/// // expression given.
-/// assert!(true);
-/// # fn some_computation() -> bool { true }
-/// assert!(some_computation());
-///
-/// // assert with a custom message
-/// # let x = true;
-/// assert!(x, "x wasn't true!");
-/// # let a = 3i; let b = 27i;
-/// assert!(a + b == 30, "a = {}, b = {}", a, b);
-/// ```
-#[macro_export]
-macro_rules! assert {
-    ($cond:expr) => (
-        if !$cond {
-            panic!(concat!("assertion failed: ", stringify!($cond)))
-        }
-    );
-    ($cond:expr, $($arg:expr),+) => (
-        if !$cond {
-            panic!($($arg),+)
-        }
-    );
-}
-
-/// Asserts that two expressions are equal to each other, testing equality in
-/// both directions.
-///
-/// On panic, this macro will print the values of the expressions.
-///
-/// # Example
-///
-/// ```
-/// let a = 3i;
-/// let b = 1i + 2i;
-/// assert_eq!(a, b);
-/// ```
-#[macro_export]
-macro_rules! assert_eq {
-    ($left:expr , $right:expr) => ({
-        match (&($left), &($right)) {
-            (left_val, right_val) => {
-                // check both directions of equality....
-                if !((*left_val == *right_val) &&
-                     (*right_val == *left_val)) {
-                    panic!("assertion failed: `(left == right) && (right == left)` \
-                           (left: `{}`, right: `{}`)", *left_val, *right_val)
-                }
-            }
-        }
-    })
-}
-
-/// Ensure that a boolean expression is `true` at runtime.
-///
-/// This will invoke the `panic!` macro if the provided expression cannot be
-/// evaluated to `true` at runtime.
-///
-/// Unlike `assert!`, `debug_assert!` statements can be disabled by passing
-/// `--cfg ndebug` to the compiler. This makes `debug_assert!` useful for
-/// checks that are too expensive to be present in a release build but may be
-/// helpful during development.
-///
-/// # Example
-///
-/// ```
-/// // the panic message for these assertions is the stringified value of the
-/// // expression given.
-/// debug_assert!(true);
-/// # fn some_expensive_computation() -> bool { true }
-/// debug_assert!(some_expensive_computation());
-///
-/// // assert with a custom message
-/// # let x = true;
-/// debug_assert!(x, "x wasn't true!");
-/// # let a = 3i; let b = 27i;
-/// debug_assert!(a + b == 30, "a = {}, b = {}", a, b);
-/// ```
-#[macro_export]
-macro_rules! debug_assert {
-    ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert!($($arg)*); })
-}
-
-/// Asserts that two expressions are equal to each other, testing equality in
-/// both directions.
-///
-/// On panic, this macro will print the values of the expressions.
-///
-/// Unlike `assert_eq!`, `debug_assert_eq!` statements can be disabled by
-/// passing `--cfg ndebug` to the compiler. This makes `debug_assert_eq!`
-/// useful for checks that are too expensive to be present in a release build
-/// but may be helpful during development.
-///
-/// # Example
-///
-/// ```
-/// let a = 3i;
-/// let b = 1i + 2i;
-/// debug_assert_eq!(a, b);
-/// ```
-#[macro_export]
-macro_rules! debug_assert_eq {
-    ($($arg:tt)*) => (if cfg!(not(ndebug)) { assert_eq!($($arg)*); })
-}
-
-/// A utility macro for indicating unreachable code.
-///
-/// This is useful any time that the compiler can't determine that some code is unreachable. For
-/// example:
-///
-/// * Match arms with guard conditions.
-/// * Loops that dynamically terminate.
-/// * Iterators that dynamically terminate.
-///
-/// # Panics
-///
-/// This will always panic.
-///
-/// # Examples
-///
-/// Match arms:
-///
-/// ```rust
-/// fn foo(x: Option<int>) {
-///     match x {
-///         Some(n) if n >= 0 => println!("Some(Non-negative)"),
-///         Some(n) if n <  0 => println!("Some(Negative)"),
-///         Some(_)           => unreachable!(), // compile error if commented out
-///         None              => println!("None")
-///     }
-/// }
-/// ```
-///
-/// Iterators:
-///
-/// ```rust
-/// fn divide_by_three(x: u32) -> u32 { // one of the poorest implementations of x/3
-///     for i in std::iter::count(0_u32, 1) {
-///         if 3*i < i { panic!("u32 overflow"); }
-///         if x < 3*i { return i-1; }
-///     }
-///     unreachable!();
-/// }
-/// ```
-#[macro_export]
-macro_rules! unreachable {
-    () => ({
-        panic!("internal error: entered unreachable code")
-    });
-    ($msg:expr) => ({
-        unreachable!("{}", $msg)
-    });
-    ($fmt:expr, $($arg:tt)*) => ({
-        panic!(concat!("internal error: entered unreachable code: ", $fmt), $($arg)*)
-    });
-}
-
-/// A standardised placeholder for marking unfinished code. It panics with the
-/// message `"not yet implemented"` when executed.
-#[macro_export]
-macro_rules! unimplemented {
-    () => (panic!("not yet implemented"))
-}
-
-/// Use the syntax described in `std::fmt` to create a value of type `String`.
-/// See `std::fmt` for more information.
-///
-/// # Example
-///
-/// ```
-/// format!("test");
-/// format!("hello {}", "world!");
-/// format!("x = {}, y = {y}", 10i, y = 30i);
-/// ```
-#[macro_export]
-#[stable]
-macro_rules! format {
-    ($($arg:tt)*) => (::std::fmt::format(format_args!($($arg)*)))
-}
-
-/// Use the `format!` syntax to write data into a buffer of type `&mut Writer`.
-/// See `std::fmt` for more information.
-///
-/// # Example
-///
-/// ```
-/// # #![allow(unused_must_use)]
-///
-/// let mut w = Vec::new();
-/// write!(&mut w, "test");
-/// write!(&mut w, "formatted {}", "arguments");
-/// ```
-#[macro_export]
-#[stable]
-macro_rules! write {
-    ($dst:expr, $($arg:tt)*) => ((&mut *$dst).write_fmt(format_args!($($arg)*)))
-}
-
-/// Equivalent to the `write!` macro, except that a newline is appended after
-/// the message is written.
-#[macro_export]
-#[stable]
-macro_rules! writeln {
-    ($dst:expr, $fmt:expr $($arg:tt)*) => (
-        write!($dst, concat!($fmt, "\n") $($arg)*)
-    )
-}
-
-/// Equivalent to the `println!` macro except that a newline is not printed at
-/// the end of the message.
-#[macro_export]
-#[stable]
-macro_rules! print {
-    ($($arg:tt)*) => (::std::io::stdio::print_args(format_args!($($arg)*)))
-}
-
-/// Macro for printing to a task's stdout handle.
-///
-/// Each task can override its stdout handle via `std::io::stdio::set_stdout`.
-/// The syntax of this macro is the same as that used for `format!`. For more
-/// information, see `std::fmt` and `std::io::stdio`.
-///
-/// # Example
-///
-/// ```
-/// println!("hello there!");
-/// println!("format {} arguments", "some");
-/// ```
-#[macro_export]
-#[stable]
-macro_rules! println {
-    ($($arg:tt)*) => (::std::io::stdio::println_args(format_args!($($arg)*)))
-}
-
-/// Helper macro for unwrapping `Result` values while returning early with an
-/// error if the value of the expression is `Err`. For more information, see
-/// `std::io`.
-#[macro_export]
-macro_rules! try {
-    ($expr:expr) => ({
-        match $expr {
-            Ok(val) => val,
-            Err(err) => return Err(::std::error::FromError::from_error(err))
-        }
-    })
-}
-
-/// Create a `std::vec::Vec` containing the arguments.
-#[macro_export]
-macro_rules! vec {
-    ($($x:expr),*) => ({
-        let xs: ::std::boxed::Box<[_]> = box [$($x),*];
-        ::std::slice::SliceExt::into_vec(xs)
-    });
-    ($($x:expr,)*) => (vec![$($x),*])
-}
-
-/// A macro to select an event from a number of receivers.
-///
-/// This macro is used to wait for the first event to occur on a number of
-/// receivers. It places no restrictions on the types of receivers given to
-/// this macro, this can be viewed as a heterogeneous select.
-///
-/// # Example
-///
-/// ```
-/// use std::thread::Thread;
-/// use std::sync::mpsc::channel;
-///
-/// let (tx1, rx1) = channel();
-/// let (tx2, rx2) = channel();
-/// # fn long_running_task() {}
-/// # fn calculate_the_answer() -> int { 42i }
-///
-/// Thread::spawn(move|| { long_running_task(); tx1.send(()) }).detach();
-/// Thread::spawn(move|| { tx2.send(calculate_the_answer()) }).detach();
-///
-/// select! (
-///     _ = rx1.recv() => println!("the long running task finished first"),
-///     answer = rx2.recv() => {
-///         println!("the answer was: {}", answer.unwrap());
-///     }
-/// )
-/// ```
-///
-/// For more information about select, see the `std::sync::mpsc::Select` structure.
-#[macro_export]
-#[experimental]
-macro_rules! select {
-    (
-        $($name:pat = $rx:ident.$meth:ident() => $code:expr),+
-    ) => ({
-        use std::sync::mpsc::Select;
-        let sel = Select::new();
-        $( let mut $rx = sel.handle(&$rx); )+
-        unsafe {
-            $( $rx.add(); )+
-        }
-        let ret = sel.wait();
-        $( if ret == $rx.id() { let $name = $rx.$meth(); $code } else )+
-        { unreachable!() }
-    })
-}
-
-// When testing the standard library, we link to the liblog crate to get the
-// logging macros. In doing so, the liblog crate was linked against the real
-// version of libstd, and uses a different std::fmt module than the test crate
-// uses. To get around this difference, we redefine the log!() macro here to be
-// just a dumb version of what it should be.
-#[cfg(test)]
-macro_rules! log {
-    ($lvl:expr, $($args:tt)*) => (
-        if log_enabled!($lvl) { println!($($args)*) }
-    )
-}
-
-/// Built-in macros to the compiler itself.
-///
-/// These macros do not have any corresponding definition with a `macro_rules!`
-/// macro, but are documented here. Their implementations can be found hardcoded
-/// into libsyntax itself.
-#[cfg(dox)]
-pub mod builtin {
-    /// The core macro for formatted string creation & output.
-    ///
-    /// This macro produces a value of type `fmt::Arguments`. This value can be
-    /// passed to the functions in `std::fmt` for performing useful functions.
-    /// All other formatting macros (`format!`, `write!`, `println!`, etc) are
-    /// proxied through this one.
-    ///
-    /// For more information, see the documentation in `std::fmt`.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// use std::fmt;
-    ///
-    /// let s = fmt::format(format_args!("hello {}", "world"));
-    /// assert_eq!(s, format!("hello {}", "world"));
-    ///
-    /// ```
-    #[macro_export]
-    macro_rules! format_args { ($fmt:expr $($args:tt)*) => ({
-        /* compiler built-in */
-    }) }
-
-    /// Inspect an environment variable at compile time.
-    ///
-    /// This macro will expand to the value of the named environment variable at
-    /// compile time, yielding an expression of type `&'static str`.
-    ///
-    /// If the environment variable is not defined, then a compilation error
-    /// will be emitted.  To not emit a compile error, use the `option_env!`
-    /// macro instead.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let path: &'static str = env!("PATH");
-    /// println!("the $PATH variable at the time of compiling was: {}", path);
-    /// ```
-    #[macro_export]
-    macro_rules! env { ($name:expr) => ({ /* compiler built-in */ }) }
-
-    /// Optionally inspect an environment variable at compile time.
-    ///
-    /// If the named environment variable is present at compile time, this will
-    /// expand into an expression of type `Option<&'static str>` whose value is
-    /// `Some` of the value of the environment variable. If the environment
-    /// variable is not present, then this will expand to `None`.
-    ///
-    /// A compile time error is never emitted when using this macro regardless
-    /// of whether the environment variable is present or not.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let key: Option<&'static str> = option_env!("SECRET_KEY");
-    /// println!("the secret key might be: {}", key);
-    /// ```
-    #[macro_export]
-    macro_rules! option_env { ($name:expr) => ({ /* compiler built-in */ }) }
-
-    /// Concatenate literals into a static byte slice.
-    ///
-    /// This macro takes any number of comma-separated literal expressions,
-    /// yielding an expression of type `&'static [u8]` which is the
-    /// concatenation (left to right) of all the literals in their byte format.
-    ///
-    /// This extension currently only supports string literals, character
-    /// literals, and integers less than 256. The byte slice returned is the
-    /// utf8-encoding of strings and characters.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let rust = bytes!("r", 'u', "st", 255);
-    /// assert_eq!(rust[1], b'u');
-    /// assert_eq!(rust[4], 255);
-    /// ```
-    #[macro_export]
-    macro_rules! bytes { ($($e:expr),*) => ({ /* compiler built-in */ }) }
-
-    /// Concatenate identifiers into one identifier.
-    ///
-    /// This macro takes any number of comma-separated identifiers, and
-    /// concatenates them all into one, yielding an expression which is a new
-    /// identifier. Note that hygiene makes it such that this macro cannot
-    /// capture local variables, and macros are only allowed in item,
-    /// statement or expression position, meaning this macro may be difficult to
-    /// use in some situations.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// #![feature(concat_idents)]
-    ///
-    /// # fn main() {
-    /// fn foobar() -> int { 23 }
-    ///
-    /// let f = concat_idents!(foo, bar);
-    /// println!("{}", f());
-    /// # }
-    /// ```
-    #[macro_export]
-    macro_rules! concat_idents {
-        ($($e:ident),*) => ({ /* compiler built-in */ })
-    }
-
-    /// Concatenates literals into a static string slice.
-    ///
-    /// This macro takes any number of comma-separated literals, yielding an
-    /// expression of type `&'static str` which represents all of the literals
-    /// concatenated left-to-right.
-    ///
-    /// Integer and floating point literals are stringified in order to be
-    /// concatenated.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let s = concat!("test", 10i, 'b', true);
-    /// assert_eq!(s, "test10btrue");
-    /// ```
-    #[macro_export]
-    macro_rules! concat { ($($e:expr),*) => ({ /* compiler built-in */ }) }
-
-    /// A macro which expands to the line number on which it was invoked.
-    ///
-    /// The expanded expression has type `uint`, and the returned line is not
-    /// the invocation of the `line!()` macro itself, but rather the first macro
-    /// invocation leading up to the invocation of the `line!()` macro.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let current_line = line!();
-    /// println!("defined on line: {}", current_line);
-    /// ```
-    #[macro_export]
-    macro_rules! line { () => ({ /* compiler built-in */ }) }
-
-    /// A macro which expands to the column number on which it was invoked.
-    ///
-    /// The expanded expression has type `uint`, and the returned column is not
-    /// the invocation of the `column!()` macro itself, but rather the first macro
-    /// invocation leading up to the invocation of the `column!()` macro.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let current_col = column!();
-    /// println!("defined on column: {}", current_col);
-    /// ```
-    #[macro_export]
-    macro_rules! column { () => ({ /* compiler built-in */ }) }
-
-    /// A macro which expands to the file name from which it was invoked.
-    ///
-    /// The expanded expression has type `&'static str`, and the returned file
-    /// is not the invocation of the `file!()` macro itself, but rather the
-    /// first macro invocation leading up to the invocation of the `file!()`
-    /// macro.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let this_file = file!();
-    /// println!("defined in file: {}", this_file);
-    /// ```
-    #[macro_export]
-    macro_rules! file { () => ({ /* compiler built-in */ }) }
-
-    /// A macro which stringifies its argument.
-    ///
-    /// This macro will yield an expression of type `&'static str` which is the
-    /// stringification of all the tokens passed to the macro. No restrictions
-    /// are placed on the syntax of the macro invocation itself.
-    ///
-    /// # Example
-    ///
-    /// ```
-    /// let one_plus_one = stringify!(1 + 1);
-    /// assert_eq!(one_plus_one, "1 + 1");
-    /// ```
-    #[macro_export]
-    macro_rules! stringify { ($t:tt) => ({ /* compiler built-in */ }) }
-
-    /// Includes a utf8-encoded file as a string.
-    ///
-    /// This macro will yield an expression of type `&'static str` which is the
-    /// contents of the filename specified. The file is located relative to the
-    /// current file (similarly to how modules are found),
-    ///
-    /// # Example
-    ///
-    /// ```rust,ignore
-    /// let secret_key = include_str!("secret-key.ascii");
-    /// ```
-    #[macro_export]
-    macro_rules! include_str { ($file:expr) => ({ /* compiler built-in */ }) }
-
-    /// Includes a file as a byte slice.
-    ///
-    /// This macro will yield an expression of type `&'static [u8]` which is
-    /// the contents of the filename specified. The file is located relative to
-    /// the current file (similarly to how modules are found),
-    ///
-    /// # Example
-    ///
-    /// ```rust,ignore
-    /// let secret_key = include_bytes!("secret-key.bin");
-    /// ```
-    #[macro_export]
-    macro_rules! include_bytes { ($file:expr) => ({ /* compiler built-in */ }) }
-
-    /// Deprecated alias for `include_bytes!()`.
-    #[macro_export]
-    macro_rules! include_bin { ($file:expr) => ({ /* compiler built-in */}) }
-
-    /// Expands to a string that represents the current module path.
-    ///
-    /// The current module path can be thought of as the hierarchy of modules
-    /// leading back up to the crate root. The first component of the path
-    /// returned is the name of the crate currently being compiled.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// mod test {
-    ///     pub fn foo() {
-    ///         assert!(module_path!().ends_with("test"));
-    ///     }
-    /// }
-    ///
-    /// test::foo();
-    /// ```
-    #[macro_export]
-    macro_rules! module_path { () => ({ /* compiler built-in */ }) }
-
-    /// Boolean evaluation of configuration flags.
-    ///
-    /// In addition to the `#[cfg]` attribute, this macro is provided to allow
-    /// boolean expression evaluation of configuration flags. This frequently
-    /// leads to less duplicated code.
-    ///
-    /// The syntax given to this macro is the same syntax as the `cfg`
-    /// attribute.
-    ///
-    /// # Example
-    ///
-    /// ```rust
-    /// let my_directory = if cfg!(windows) {
-    ///     "windows-specific-directory"
-    /// } else {
-    ///     "unix-directory"
-    /// };
-    /// ```
-    #[macro_export]
-    macro_rules! cfg { ($cfg:tt) => ({ /* compiler built-in */ }) }
-}
index e3402984ae5053a98bf6028ea46e1e4a67d46f69..f433cd1e664811947fd6b771e08962a53e7306cc 100644 (file)
@@ -19,7 +19,7 @@
 #[cfg(test)] use fmt::Show;
 use ops::{Add, Sub, Mul, Div, Rem, Neg};
 
-use kinds::Copy;
+use marker::Copy;
 use clone::Clone;
 use cmp::{PartialOrd, PartialEq};
 
index 72ad16e0a5d5fec123d59b70f9b4b1286756ac28..cef85c260a7e570d1a5908b18e8e7482374fc685 100644 (file)
@@ -37,7 +37,7 @@
 use fmt;
 use io::{IoResult, IoError};
 use iter::{Iterator, IteratorExt};
-use kinds::Copy;
+use marker::Copy;
 use libc::{c_void, c_int, c_char};
 use libc;
 use boxed::Box;
@@ -93,7 +93,7 @@ pub fn num_cpus() -> uint {
 ///
 /// // We assume that we are in a valid directory.
 /// let current_working_directory = os::getcwd().unwrap();
-/// println!("The current directory is {}", current_working_directory.display());
+/// println!("The current directory is {:?}", current_working_directory.display());
 /// ```
 pub fn getcwd() -> IoResult<Path> {
     sys::os::getcwd()
@@ -934,7 +934,7 @@ fn fmt(&self, out: &mut fmt::Formatter) -> fmt::Result {
 
 impl Error for MapError {
     fn description(&self) -> &str { "memory map error" }
-    fn detail(&self) -> Option<String> { Some(self.to_string()) }
+    fn detail(&self) -> Option<String> { Some(format!("{:?}", self)) }
 }
 
 impl FromError<MapError> for Box<Error> {
@@ -1622,7 +1622,7 @@ fn memory_map_rw() {
             os::MapOption::MapWritable
         ]) {
             Ok(chunk) => chunk,
-            Err(msg) => panic!("{}", msg)
+            Err(msg) => panic!("{:?}", msg)
         };
         assert!(chunk.len >= 16);
 
index b020164158cff2d5d2e876b58403cc3016b7d244..581969e98fb8bec5d905f8534fd5bb62a8335599 100644 (file)
 
 #![experimental]
 
-use core::kinds::Sized;
+use core::marker::Sized;
 use ffi::CString;
 use clone::Clone;
 use fmt;
 use iter::IteratorExt;
 use option::Option;
 use option::Option::{None, Some};
+use ops::{FullRange, Index};
 use str;
 use str::StrExt;
 use string::{String, CowString};
@@ -351,7 +352,7 @@ fn filestem<'a>(&'a self) -> Option<&'a [u8]> {
                 match name.rposition_elem(&dot) {
                     None | Some(0) => name,
                     Some(1) if name == b".." => name,
-                    Some(pos) => name[..pos]
+                    Some(pos) => name.index(&(0..pos))
                 }
             })
         }
@@ -398,7 +399,7 @@ fn extension<'a>(&'a self) -> Option<&'a [u8]> {
                 match name.rposition_elem(&dot) {
                     None | Some(0) => None,
                     Some(1) if name == b".." => None,
-                    Some(pos) => Some(name[pos+1..])
+                    Some(pos) => Some(name.index(&((pos+1)..)))
                 }
             }
         }
@@ -459,7 +460,7 @@ fn set_filename<T: BytesContainer>(&mut self, filename: T) {
     /// # #[cfg(unix)] fn foo() {
     /// let mut p = Path::new("abc/def.txt");
     /// p.set_extension("csv");
-    /// assert!(p == Path::new("abc/def.csv"));
+    /// assert_eq!(p, Path::new("abc/def.csv"));
     /// # }
     /// ```
     ///
@@ -474,7 +475,7 @@ fn set_extension<T: BytesContainer>(&mut self, extension: T) {
             let extlen = extension.container_as_bytes().len();
             match (name.rposition_elem(&dot), extlen) {
                 (None, 0) | (Some(0), 0) => None,
-                (Some(idx), 0) => Some(name[..idx].to_vec()),
+                (Some(idx), 0) => Some(name.index(&(0..idx)).to_vec()),
                 (idx, extlen) => {
                     let idx = match idx {
                         None | Some(0) => name.len(),
@@ -483,7 +484,7 @@ fn set_extension<T: BytesContainer>(&mut self, extension: T) {
 
                     let mut v;
                     v = Vec::with_capacity(idx + extlen + 1);
-                    v.push_all(name[..idx]);
+                    v.push_all(name.index(&(0..idx)));
                     v.push(dot);
                     v.push_all(extension.container_as_bytes());
                     Some(v)
@@ -508,7 +509,7 @@ fn set_extension<T: BytesContainer>(&mut self, extension: T) {
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
     /// let mut p = Path::new("abc/def.txt");
-    /// assert!(p.with_filename("foo.dat") == Path::new("abc/foo.dat"));
+    /// assert_eq!(p.with_filename("foo.dat"), Path::new("abc/foo.dat"));
     /// # }
     /// ```
     ///
@@ -533,7 +534,7 @@ fn with_filename<T: BytesContainer>(&self, filename: T) -> Self {
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
     /// let mut p = Path::new("abc/def.txt");
-    /// assert!(p.with_extension("csv") == Path::new("abc/def.csv"));
+    /// assert_eq!(p.with_extension("csv"), Path::new("abc/def.csv"));
     /// # }
     /// ```
     ///
@@ -557,7 +558,7 @@ fn with_extension<T: BytesContainer>(&self, extension: T) -> Self {
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
     /// let p = Path::new("abc/def/ghi");
-    /// assert!(p.dir_path() == Path::new("abc/def"));
+    /// assert_eq!(p.dir_path(), Path::new("abc/def"));
     /// # }
     /// ```
     fn dir_path(&self) -> Self {
@@ -575,8 +576,8 @@ fn dir_path(&self) -> Self {
     /// # foo();
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
-    /// assert!(Path::new("abc/def").root_path() == None);
-    /// assert!(Path::new("/abc/def").root_path() == Some(Path::new("/")));
+    /// assert_eq!(Path::new("abc/def").root_path(), None);
+    /// assert_eq!(Path::new("/abc/def").root_path(), Some(Path::new("/")));
     /// # }
     /// ```
     fn root_path(&self) -> Option<Self>;
@@ -592,7 +593,7 @@ fn dir_path(&self) -> Self {
     /// # #[cfg(unix)] fn foo() {
     /// let mut p = Path::new("foo/bar");
     /// p.push("baz.txt");
-    /// assert!(p == Path::new("foo/bar/baz.txt"));
+    /// assert_eq!(p, Path::new("foo/bar/baz.txt"));
     /// # }
     /// ```
     ///
@@ -616,7 +617,7 @@ fn push<T: BytesContainer>(&mut self, path: T) {
     /// # #[cfg(unix)] fn foo() {
     /// let mut p = Path::new("foo");
     /// p.push_many(&["bar", "baz.txt"]);
-    /// assert!(p == Path::new("foo/bar/baz.txt"));
+    /// assert_eq!(p, Path::new("foo/bar/baz.txt"));
     /// # }
     /// ```
     #[inline]
@@ -645,7 +646,7 @@ fn push_many<T: BytesContainer>(&mut self, paths: &[T]) {
     /// # #[cfg(unix)] fn foo() {
     /// let mut p = Path::new("foo/bar/baz.txt");
     /// p.pop();
-    /// assert!(p == Path::new("foo/bar"));
+    /// assert_eq!(p, Path::new("foo/bar"));
     /// # }
     /// ```
     fn pop(&mut self) -> bool;
@@ -661,7 +662,7 @@ fn push_many<T: BytesContainer>(&mut self, paths: &[T]) {
     /// # #[cfg(windows)] fn foo() {}
     /// # #[cfg(unix)] fn foo() {
     /// let p = Path::new("/foo");
-    /// assert!(p.join("bar.txt") == Path::new("/foo/bar.txt"));
+    /// assert_eq!(p.join("bar.txt"), Path::new("/foo/bar.txt"));
     /// # }
     /// ```
     ///
@@ -687,7 +688,7 @@ fn join<T: BytesContainer>(&self, path: T) -> Self {
     /// # #[cfg(unix)] fn foo() {
     /// let p = Path::new("foo");
     /// let fbbq = Path::new("foo/bar/baz/quux.txt");
-    /// assert!(p.join_many(&["bar", "baz", "quux.txt"]) == fbbq);
+    /// assert_eq!(p.join_many(&["bar", "baz", "quux.txt"]), fbbq);
     /// # }
     /// ```
     #[inline]
@@ -764,7 +765,7 @@ fn is_relative(&self) -> bool {
     /// let p = Path::new("foo/bar/baz/quux.txt");
     /// let fb = Path::new("foo/bar");
     /// let bq = Path::new("baz/quux.txt");
-    /// assert!(p.path_relative_from(&fb) == Some(bq));
+    /// assert_eq!(p.path_relative_from(&fb), Some(bq));
     /// # }
     /// ```
     fn path_relative_from(&self, base: &Self) -> Option<Self>;
@@ -822,7 +823,14 @@ pub struct Display<'a, P:'a> {
     filename: bool
 }
 
+//NOTE(stage0): replace with deriving(Show) after snapshot
 impl<'a, P: GenericPath> fmt::Show for Display<'a, P> {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl<'a, P: GenericPath> fmt::String for Display<'a, P> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         self.as_cow().fmt(f)
     }
@@ -869,7 +877,7 @@ fn container_as_bytes(&self) -> &[u8] {
     }
     #[inline]
     fn container_as_str(&self) -> Option<&str> {
-        Some(self[])
+        Some(self.index(&FullRange))
     }
     #[inline]
     fn is_str(_: Option<&String>) -> bool { true }
@@ -885,7 +893,7 @@ fn container_as_bytes(&self) -> &[u8] {
 impl BytesContainer for Vec<u8> {
     #[inline]
     fn container_as_bytes(&self) -> &[u8] {
-        self[]
+        self.index(&FullRange)
     }
 }
 
index d9981ace0301ec52b40ae8453951b392fe99df2d..0b7dc19fcab4e0be31d6d57be9c64db670368ef7 100644 (file)
 
 use clone::Clone;
 use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd};
+use fmt;
 use hash;
 use io::Writer;
 use iter::{AdditiveIterator, Extend};
 use iter::{Iterator, IteratorExt, Map};
-use kinds::Sized;
+use ops::Index;
+use marker::Sized;
 use option::Option::{self, Some, None};
 use slice::{AsSlice, Split, SliceExt, SliceConcatExt};
 use str::{self, FromStr, StrExt};
@@ -56,6 +58,12 @@ pub fn is_sep(c: char) -> bool {
     c == SEP
 }
 
+impl fmt::Show for Path {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "Path {{ {} }}", self.display())
+    }
+}
+
 impl PartialEq for Path {
     #[inline]
     fn eq(&self, other: &Path) -> bool {
@@ -119,7 +127,7 @@ unsafe fn set_filename_unchecked<T: BytesContainer>(&mut self, filename: T) {
             None => {
                 self.repr = Path::normalize(filename);
             }
-            Some(idx) if self.repr[idx+1..] == b".." => {
+            Some(idx) if self.repr.index(&((idx+1)..)) == b".." => {
                 let mut v = Vec::with_capacity(self.repr.len() + 1 + filename.len());
                 v.push_all(self.repr.as_slice());
                 v.push(SEP_BYTE);
@@ -129,7 +137,7 @@ unsafe fn set_filename_unchecked<T: BytesContainer>(&mut self, filename: T) {
             }
             Some(idx) => {
                 let mut v = Vec::with_capacity(idx + 1 + filename.len());
-                v.push_all(self.repr[..idx+1]);
+                v.push_all(self.repr.index(&(0..(idx+1))));
                 v.push_all(filename);
                 // FIXME: this is slow
                 self.repr = Path::normalize(v.as_slice());
@@ -170,9 +178,9 @@ fn dirname<'a>(&'a self) -> &'a [u8] {
         match self.sepidx {
             None if b".." == self.repr => self.repr.as_slice(),
             None => dot_static,
-            Some(0) => self.repr[..1],
-            Some(idx) if self.repr[idx+1..] == b".." => self.repr.as_slice(),
-            Some(idx) => self.repr[..idx]
+            Some(0) => self.repr.index(&(0..1)),
+            Some(idx) if self.repr.index(&((idx+1)..)) == b".." => self.repr.as_slice(),
+            Some(idx) => self.repr.index(&(0..idx))
         }
     }
 
@@ -181,9 +189,9 @@ fn filename<'a>(&'a self) -> Option<&'a [u8]> {
             None if b"." == self.repr ||
                 b".." == self.repr => None,
             None => Some(self.repr.as_slice()),
-            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..])
+            Some(idx) if self.repr.index(&((idx+1)..)) == b".." => None,
+            Some(0) if self.repr.index(&(1..)).is_empty() => None,
+            Some(idx) => Some(self.repr.index(&((idx+1)..)))
         }
     }
 
@@ -325,7 +333,7 @@ fn normalize<V: ?Sized + AsSlice<u8>>(v: &V) -> Vec<u8> {
         // borrowck is being very picky
         let val = {
             let is_abs = !v.as_slice().is_empty() && v.as_slice()[0] == SEP_BYTE;
-            let v_ = if is_abs { v.as_slice()[1..] } else { v.as_slice() };
+            let v_ = if is_abs { v.as_slice().index(&(1..)) } else { v.as_slice() };
             let comps = normalize_helper(v_, is_abs);
             match comps {
                 None => None,
@@ -364,7 +372,7 @@ fn normalize<V: ?Sized + AsSlice<u8>>(v: &V) -> Vec<u8> {
     /// A path of "/" yields no components. A path of "." yields one component.
     pub fn components<'a>(&'a self) -> Components<'a> {
         let v = if self.repr[0] == SEP_BYTE {
-            self.repr[1..]
+            self.repr.index(&(1..))
         } else { self.repr.as_slice() };
         let is_sep_byte: fn(&u8) -> bool = is_sep_byte; // coerce to fn ptr
         let mut ret = v.split(is_sep_byte);
@@ -438,13 +446,13 @@ macro_rules! t {
         (s: $path:expr, $exp:expr) => (
             {
                 let path = $path;
-                assert!(path.as_str() == Some($exp));
+                assert_eq!(path.as_str(), Some($exp));
             }
         );
         (v: $path:expr, $exp:expr) => (
             {
                 let path = $path;
-                assert!(path.as_vec() == $exp);
+                assert_eq!(path.as_vec(), $exp);
             }
         )
     }
@@ -458,7 +466,7 @@ fn test_paths() {
         t!(v: Path::new(b"a/b/c\xFF"), b"a/b/c\xFF");
         t!(v: Path::new(b"\xFF/../foo\x80"), b"foo\x80");
         let p = Path::new(b"a/b/c\xFF");
-        assert!(p.as_str() == None);
+        assert!(p.as_str().is_none());
 
         t!(s: Path::new(""), ".");
         t!(s: Path::new("/"), "/");
@@ -488,31 +496,31 @@ fn test_paths() {
                    b"/bar");
 
         let p = Path::new(b"foo/bar\x80");
-        assert!(p.as_str() == None);
+        assert!(p.as_str().is_none());
     }
 
     #[test]
     fn test_opt_paths() {
-        assert!(Path::new_opt(b"foo/bar\0") == None);
+        assert!(Path::new_opt(b"foo/bar\0").is_none());
         t!(v: Path::new_opt(b"foo/bar").unwrap(), b"foo/bar");
-        assert!(Path::new_opt("foo/bar\0") == None);
+        assert!(Path::new_opt("foo/bar\0").is_none());
         t!(s: Path::new_opt("foo/bar").unwrap(), "foo/bar");
     }
 
     #[test]
     fn test_null_byte() {
         use thread::Thread;
-        let result = Thread::spawn(move|| {
+        let result = Thread::scoped(move|| {
             Path::new(b"foo/bar\0")
         }).join();
         assert!(result.is_err());
 
-        let result = Thread::spawn(move|| {
+        let result = Thread::scoped(move|| {
             Path::new("test").set_filename(b"f\0o")
         }).join();
         assert!(result.is_err());
 
-        let result = Thread::spawn(move|| {
+        let result = Thread::scoped(move|| {
             Path::new("test").push(b"f\0o");
         }).join();
         assert!(result.is_err());
@@ -524,7 +532,7 @@ macro_rules! t {
             ($path:expr, $disp:ident, $exp:expr) => (
                 {
                     let path = Path::new($path);
-                    assert!(path.$disp().to_string() == $exp);
+                    assert_eq!(path.$disp().to_string(), $exp);
                 }
             )
         }
@@ -540,14 +548,14 @@ macro_rules! t {
                 {
                     let path = Path::new($path);
                     let mo = path.display().as_cow();
-                    assert!(mo.as_slice() == $exp);
+                    assert_eq!(mo.as_slice(), $exp);
                 }
             );
             ($path:expr, $exp:expr, filename) => (
                 {
                     let path = Path::new($path);
                     let mo = path.filename_display().as_cow();
-                    assert!(mo.as_slice() == $exp);
+                    assert_eq!(mo.as_slice(), $exp);
                 }
             )
         }
@@ -567,9 +575,9 @@ macro_rules! t {
                 {
                     let path = Path::new($path);
                     let f = format!("{}", path.display());
-                    assert!(f == $exp);
+                    assert_eq!(f, $exp);
                     let f = format!("{}", path.filename_display());
-                    assert!(f == $expf);
+                    assert_eq!(f, $expf);
                 }
             )
         }
@@ -589,21 +597,21 @@ macro_rules! t {
             (s: $path:expr, $op:ident, $exp:expr) => (
                 {
                     let path = Path::new($path);
-                    assert!(path.$op() == ($exp).as_bytes());
+                    assert_eq!(path.$op(), ($exp).as_bytes());
                 }
             );
             (s: $path:expr, $op:ident, $exp:expr, opt) => (
                 {
                     let path = Path::new($path);
                     let left = path.$op().map(|x| str::from_utf8(x).unwrap());
-                    assert!(left == $exp);
+                    assert_eq!(left, $exp);
                 }
             );
             (v: $path:expr, $op:ident, $exp:expr) => (
                 {
                     let arg = $path;
                     let path = Path::new(arg);
-                    assert!(path.$op() == $exp);
+                    assert_eq!(path.$op(), $exp);
                 }
             );
         }
@@ -677,7 +685,7 @@ macro_rules! t {
                     let mut p1 = Path::new(path);
                     let p2 = p1.clone();
                     p1.push(join);
-                    assert!(p1 == p2.join(join));
+                    assert_eq!(p1, p2.join(join));
                 }
             )
         }
@@ -696,7 +704,7 @@ macro_rules! t {
                     let mut p = Path::new($path);
                     let push = Path::new($push);
                     p.push(&push);
-                    assert!(p.as_str() == Some($exp));
+                    assert_eq!(p.as_str(), Some($exp));
                 }
             )
         }
@@ -716,14 +724,14 @@ macro_rules! t {
                 {
                     let mut p = Path::new($path);
                     p.push_many(&$push);
-                    assert!(p.as_str() == Some($exp));
+                    assert_eq!(p.as_str(), Some($exp));
                 }
             );
             (v: $path:expr, $push:expr, $exp:expr) => (
                 {
                     let mut p = Path::new($path);
                     p.push_many(&$push);
-                    assert!(p.as_vec() == $exp);
+                    assert_eq!(p.as_vec(), $exp);
                 }
             )
         }
@@ -744,16 +752,16 @@ macro_rules! t {
                 {
                     let mut p = Path::new($path);
                     let result = p.pop();
-                    assert!(p.as_str() == Some($left));
-                    assert!(result == $right);
+                    assert_eq!(p.as_str(), Some($left));
+                    assert_eq!(result, $right);
                 }
             );
             (b: $path:expr, $left:expr, $right:expr) => (
                 {
                     let mut p = Path::new($path);
                     let result = p.pop();
-                    assert!(p.as_vec() == $left);
-                    assert!(result == $right);
+                    assert_eq!(p.as_vec(), $left);
+                    assert_eq!(result, $right);
                 }
             )
         }
@@ -776,8 +784,8 @@ macro_rules! t {
 
     #[test]
     fn test_root_path() {
-        assert!(Path::new(b"a/b/c").root_path() == None);
-        assert!(Path::new(b"/a/b/c").root_path() == Some(Path::new("/")));
+        assert_eq!(Path::new(b"a/b/c").root_path(), None);
+        assert_eq!(Path::new(b"/a/b/c").root_path(), Some(Path::new("/")));
     }
 
     #[test]
@@ -801,7 +809,7 @@ macro_rules! t {
                     let path = Path::new($path);
                     let join = Path::new($join);
                     let res = path.join(&join);
-                    assert!(res.as_str() == Some($exp));
+                    assert_eq!(res.as_str(), Some($exp));
                 }
             )
         }
@@ -821,14 +829,14 @@ macro_rules! t {
                 {
                     let path = Path::new($path);
                     let res = path.join_many(&$join);
-                    assert!(res.as_str() == Some($exp));
+                    assert_eq!(res.as_str(), Some($exp));
                 }
             );
             (v: $path:expr, $join:expr, $exp:expr) => (
                 {
                     let path = Path::new($path);
                     let res = path.join_many(&$join);
-                    assert!(res.as_vec() == $exp);
+                    assert_eq!(res.as_vec(), $exp);
                 }
             )
         }
@@ -902,7 +910,7 @@ macro_rules! t {
                     let mut p1 = Path::new(path);
                     p1.$set(arg);
                     let p2 = Path::new(path);
-                    assert!(p1 == p2.$with(arg));
+                    assert_eq!(p1, p2.$with(arg));
                 }
             );
             (v: $path:expr, $set:ident, $with:ident, $arg:expr) => (
@@ -912,7 +920,7 @@ macro_rules! t {
                     let mut p1 = Path::new(path);
                     p1.$set(arg);
                     let p2 = Path::new(path);
-                    assert!(p1 == p2.$with(arg));
+                    assert_eq!(p1, p2.$with(arg));
                 }
             )
         }
@@ -942,31 +950,19 @@ macro_rules! t {
             (s: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => (
                 {
                     let path = $path;
-                    let filename = $filename;
-                    assert!(path.filename_str() == filename,
-                            "{}.filename_str(): Expected `{}`, found {}",
-                            path.as_str().unwrap(), filename, path.filename_str());
-                    let dirname = $dirname;
-                    assert!(path.dirname_str() == dirname,
-                            "`{}`.dirname_str(): Expected `{}`, found `{}`",
-                            path.as_str().unwrap(), dirname, path.dirname_str());
-                    let filestem = $filestem;
-                    assert!(path.filestem_str() == filestem,
-                            "`{}`.filestem_str(): Expected `{}`, found `{}`",
-                            path.as_str().unwrap(), filestem, path.filestem_str());
-                    let ext = $ext;
-                    assert!(path.extension_str() == ext,
-                            "`{}`.extension_str(): Expected `{}`, found `{}`",
-                            path.as_str().unwrap(), ext, path.extension_str());
-                }
+                    assert_eq!(path.filename_str(), $filename);
+                    assert_eq!(path.dirname_str(), $dirname);
+                    assert_eq!(path.filestem_str(), $filestem);
+                    assert_eq!(path.extension_str(), $ext);
+               }
             );
             (v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => (
                 {
                     let path = $path;
-                    assert!(path.filename() == $filename);
-                    assert!(path.dirname() == $dirname);
-                    assert!(path.filestem() == $filestem);
-                    assert!(path.extension() == $ext);
+                    assert_eq!(path.filename(), $filename);
+                    assert_eq!(path.dirname(), $dirname);
+                    assert_eq!(path.filestem(), $filestem);
+                    assert_eq!(path.extension(), $ext);
                 }
             )
         }
@@ -1154,12 +1150,10 @@ macro_rules! t {
                     let comps = path.components().collect::<Vec<&[u8]>>();
                     let exp: &[&str] = &$exp;
                     let exps = exp.iter().map(|x| x.as_bytes()).collect::<Vec<&[u8]>>();
-                    assert!(comps == exps, "components: Expected {}, found {}",
-                            comps, exps);
+                    assert_eq!(comps, exps);
                     let comps = path.components().rev().collect::<Vec<&[u8]>>();
                     let exps = exps.into_iter().rev().collect::<Vec<&[u8]>>();
-                    assert!(comps == exps, "rev_components: Expected {}, found {}",
-                            comps, exps);
+                    assert_eq!(comps, exps);
                 }
             );
             (b: $arg:expr, [$($exp:expr),*]) => (
index 4b5d793355b60137fabd2b321f25efb458076cb0..5c4e7aa9ac27b6fe4b6224c53cdc433d487498fa 100644 (file)
 use char::CharExt;
 use clone::Clone;
 use cmp::{Ordering, Eq, Ord, PartialEq, PartialOrd};
+use fmt;
 use hash;
 use io::Writer;
 use iter::{AdditiveIterator, Extend};
 use iter::{Iterator, IteratorExt, Map, repeat};
 use mem;
 use option::Option::{self, Some, None};
+use ops::{FullRange, Index};
 use slice::{SliceExt, SliceConcatExt};
 use str::{SplitTerminator, FromStr, StrExt};
 use string::{String, ToString};
@@ -83,6 +85,12 @@ pub struct Path {
     sepidx: Option<uint> // index of the final separator in the non-prefix portion of repr
 }
 
+impl fmt::Show for Path {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "Path {{ {} }}", self.display())
+    }
+}
+
 impl PartialEq for Path {
     #[inline]
     fn eq(&self, other: &Path) -> bool {
@@ -165,30 +173,30 @@ unsafe fn set_filename_unchecked<T: BytesContainer>(&mut self, filename: T) {
                 s.push_str("..");
                 s.push(SEP);
                 s.push_str(filename);
-                self.update_normalized(s[]);
+                self.update_normalized(s.index(&FullRange));
             }
             None => {
                 self.update_normalized(filename);
             }
-            Some((_,idxa,end)) if self.repr[idxa..end] == ".." => {
+            Some((_,idxa,end)) if self.repr.index(&(idxa..end)) == ".." => {
                 let mut s = String::with_capacity(end + 1 + filename.len());
-                s.push_str(self.repr[0..end]);
+                s.push_str(self.repr.index(&(0..end)));
                 s.push(SEP);
                 s.push_str(filename);
-                self.update_normalized(s[]);
+                self.update_normalized(s.index(&FullRange));
             }
             Some((idxb,idxa,_)) if self.prefix == Some(DiskPrefix) && idxa == self.prefix_len() => {
                 let mut s = String::with_capacity(idxb + filename.len());
-                s.push_str(self.repr[0..idxb]);
+                s.push_str(self.repr.index(&(0..idxb)));
                 s.push_str(filename);
-                self.update_normalized(s[]);
+                self.update_normalized(s.index(&FullRange));
             }
             Some((idxb,_,_)) => {
                 let mut s = String::with_capacity(idxb + 1 + filename.len());
-                s.push_str(self.repr[0..idxb]);
+                s.push_str(self.repr.index(&(0..idxb)));
                 s.push(SEP);
                 s.push_str(filename);
-                self.update_normalized(s[]);
+                self.update_normalized(s.index(&FullRange));
             }
         }
     }
@@ -207,12 +215,12 @@ unsafe fn push_unchecked<T: BytesContainer>(&mut self, path: T) {
         let path = path.container_as_str().unwrap();
         fn is_vol_abs(path: &str, prefix: Option<PathPrefix>) -> bool {
             // assume prefix is Some(DiskPrefix)
-            let rest = path[prefix_len(prefix)..];
+            let rest = path.index(&(prefix_len(prefix)..));
             !rest.is_empty() && rest.as_bytes()[0].is_ascii() && is_sep(rest.as_bytes()[0] as char)
         }
         fn shares_volume(me: &Path, path: &str) -> bool {
             // path is assumed to have a prefix of Some(DiskPrefix)
-            let repr = me.repr[];
+            let repr = me.repr.index(&FullRange);
             match me.prefix {
                 Some(DiskPrefix) => {
                     repr.as_bytes()[0] == path.as_bytes()[0].to_ascii_uppercase()
@@ -244,7 +252,7 @@ fn append_path(me: &mut Path, path: &str) {
                         else { None };
             let pathlen = path_.as_ref().map_or(path.len(), |p| p.len());
             let mut s = String::with_capacity(me.repr.len() + 1 + pathlen);
-            s.push_str(me.repr[]);
+            s.push_str(me.repr.index(&FullRange));
             let plen = me.prefix_len();
             // if me is "C:" we don't want to add a path separator
             match me.prefix {
@@ -256,9 +264,9 @@ fn append_path(me: &mut Path, path: &str) {
             }
             match path_ {
                 None => s.push_str(path),
-                Some(p) => s.push_str(p[]),
+                Some(p) => s.push_str(p.index(&FullRange)),
             };
-            me.update_normalized(s[])
+            me.update_normalized(s.index(&FullRange))
         }
 
         if !path.is_empty() {
@@ -266,7 +274,7 @@ fn append_path(me: &mut Path, path: &str) {
             match prefix {
                 Some(DiskPrefix) if !is_vol_abs(path, prefix) && shares_volume(self, path) => {
                     // cwd-relative path, self is on the same volume
-                    append_path(self, path[prefix_len(prefix)..]);
+                    append_path(self, path.index(&(prefix_len(prefix)..)));
                 }
                 Some(_) => {
                     // absolute path, or cwd-relative and self is not same volume
@@ -312,7 +320,7 @@ fn new_opt<T: BytesContainer>(path: T) -> Option<Path> {
     /// Always returns a `Some` value.
     #[inline]
     fn as_str<'a>(&'a self) -> Option<&'a str> {
-        Some(self.repr[])
+        Some(self.repr.index(&FullRange))
     }
 
     #[inline]
@@ -334,17 +342,21 @@ fn dirname<'a>(&'a self) -> &'a [u8] {
     /// Always returns a `Some` value.
     fn dirname_str<'a>(&'a self) -> Option<&'a str> {
         Some(match self.sepidx_or_prefix_len() {
-            None if ".." == self.repr => self.repr[],
+            None if ".." == self.repr => self.repr.index(&FullRange),
             None => ".",
-            Some((_,idxa,end)) if self.repr[idxa..end] == ".." => self.repr[],
-            Some((idxb,_,end)) if self.repr[idxb..end] == "\\" => self.repr[],
-            Some((0,idxa,_)) => self.repr[0..idxa],
+            Some((_,idxa,end)) if self.repr.index(&(idxa..end)) == ".." => {
+                self.repr.index(&FullRange)
+            }
+            Some((idxb,_,end)) if self.repr.index(&(idxb..end)) == "\\" => {
+                self.repr.index(&FullRange)
+            }
+            Some((0,idxa,_)) => self.repr.index(&(0..idxa)),
             Some((idxb,idxa,_)) => {
                 match self.prefix {
                     Some(DiskPrefix) | Some(VerbatimDiskPrefix) if idxb == self.prefix_len() => {
-                        self.repr[0..idxa]
+                        self.repr.index(&(0..idxa))
                     }
-                    _ => self.repr[0..idxb]
+                    _ => self.repr.index(&(0..idxb))
                 }
             }
         })
@@ -358,13 +370,13 @@ fn filename<'a>(&'a self) -> Option<&'a [u8]> {
     /// See `GenericPath::filename_str` for info.
     /// Always returns a `Some` value if `filename` returns a `Some` value.
     fn filename_str<'a>(&'a self) -> Option<&'a str> {
-        let repr = self.repr[];
+        let repr = self.repr.index(&FullRange);
         match self.sepidx_or_prefix_len() {
             None if "." == repr || ".." == repr => None,
             None => Some(repr),
-            Some((_,idxa,end)) if repr[idxa..end] == ".." => None,
+            Some((_,idxa,end)) if repr.index(&(idxa..end)) == ".." => None,
             Some((_,idxa,end)) if idxa == end => None,
-            Some((_,idxa,end)) => Some(repr[idxa..end])
+            Some((_,idxa,end)) => Some(repr.index(&(idxa..end)))
         }
     }
 
@@ -396,7 +408,7 @@ fn pop(&mut self) -> bool {
                 true
             }
             Some((idxb,idxa,end)) if idxb == idxa && idxb == end => false,
-            Some((idxb,_,end)) if self.repr[idxb..end] == "\\" => false,
+            Some((idxb,_,end)) if self.repr.index(&(idxb..end)) == "\\" => false,
             Some((idxb,idxa,_)) => {
                 let trunc = match self.prefix {
                     Some(DiskPrefix) | Some(VerbatimDiskPrefix) | None => {
@@ -416,15 +428,15 @@ fn root_path(&self) -> Option<Path> {
         if self.prefix.is_some() {
             Some(Path::new(match self.prefix {
                 Some(DiskPrefix) if self.is_absolute() => {
-                    self.repr[0..self.prefix_len()+1]
+                    self.repr.index(&(0..(self.prefix_len()+1)))
                 }
                 Some(VerbatimDiskPrefix) => {
-                    self.repr[0..self.prefix_len()+1]
+                    self.repr.index(&(0..(self.prefix_len()+1)))
                 }
-                _ => self.repr[0..self.prefix_len()]
+                _ => self.repr.index(&(0..self.prefix_len()))
             }))
         } else if is_vol_relative(self) {
-            Some(Path::new(self.repr[0..1]))
+            Some(Path::new(self.repr.index(&(0..1))))
         } else {
             None
         }
@@ -443,7 +455,7 @@ fn root_path(&self) -> Option<Path> {
     fn is_absolute(&self) -> bool {
         match self.prefix {
             Some(DiskPrefix) => {
-                let rest = self.repr[self.prefix_len()..];
+                let rest = self.repr.index(&(self.prefix_len()..));
                 rest.len() > 0 && rest.as_bytes()[0] == SEP_BYTE
             }
             Some(_) => true,
@@ -618,15 +630,15 @@ pub fn new_opt<T: BytesContainer>(path: T) -> Option<Path> {
     /// Does not distinguish between absolute and cwd-relative paths, e.g.
     /// C:\foo and C:foo.
     pub fn str_components<'a>(&'a self) -> StrComponents<'a> {
-        let repr = self.repr[];
+        let repr = self.repr.index(&FullRange);
         let s = match self.prefix {
             Some(_) => {
                 let plen = self.prefix_len();
                 if repr.len() > plen && repr.as_bytes()[plen] == SEP_BYTE {
-                    repr[plen+1..]
-                } else { repr[plen..] }
+                    repr.index(&((plen+1)..))
+                } else { repr.index(&(plen..)) }
             }
-            None if repr.as_bytes()[0] == SEP_BYTE => repr[1..],
+            None if repr.as_bytes()[0] == SEP_BYTE => repr.index(&(1..)),
             None => repr
         };
         let some: fn(&'a str) -> Option<&'a str> = Some; // coerce to fn ptr
@@ -646,8 +658,8 @@ fn convert<'a>(x: Option<&'a str>) -> &'a [u8] {
     }
 
     fn equiv_prefix(&self, other: &Path) -> bool {
-        let s_repr = self.repr[];
-        let o_repr = other.repr[];
+        let s_repr = self.repr.index(&FullRange);
+        let o_repr = other.repr.index(&FullRange);
         match (self.prefix, other.prefix) {
             (Some(DiskPrefix), Some(VerbatimDiskPrefix)) => {
                 self.is_absolute() &&
@@ -664,14 +676,14 @@ fn equiv_prefix(&self, other: &Path) -> bool {
                     o_repr.as_bytes()[4].to_ascii_lowercase()
             }
             (Some(UNCPrefix(_,_)), Some(VerbatimUNCPrefix(_,_))) => {
-                s_repr[2..self.prefix_len()] == o_repr[8..other.prefix_len()]
+                s_repr.index(&(2..self.prefix_len())) == o_repr.index(&(8..other.prefix_len()))
             }
             (Some(VerbatimUNCPrefix(_,_)), Some(UNCPrefix(_,_))) => {
-                s_repr[8..self.prefix_len()] == o_repr[2..other.prefix_len()]
+                s_repr.index(&(8..self.prefix_len())) == o_repr.index(&(2..other.prefix_len()))
             }
             (None, None) => true,
             (a, b) if a == b => {
-                s_repr[0..self.prefix_len()] == o_repr[0..other.prefix_len()]
+                s_repr.index(&(0..self.prefix_len())) == o_repr.index(&(0..other.prefix_len()))
             }
             _ => false
         }
@@ -725,7 +737,7 @@ fn normalize__(s: &str, prefix: Option<PathPrefix>) -> Option<String> {
                         match prefix.unwrap() {
                             DiskPrefix => {
                                 let len = prefix_len(prefix) + is_abs as uint;
-                                let mut s = String::from_str(s[0..len]);
+                                let mut s = String::from_str(s.index(&(0..len)));
                                 unsafe {
                                     let v = s.as_mut_vec();
                                     v[0] = (*v)[0].to_ascii_uppercase();
@@ -740,7 +752,7 @@ fn normalize__(s: &str, prefix: Option<PathPrefix>) -> Option<String> {
                             }
                             VerbatimDiskPrefix => {
                                 let len = prefix_len(prefix) + is_abs as uint;
-                                let mut s = String::from_str(s[0..len]);
+                                let mut s = String::from_str(s.index(&(0..len)));
                                 unsafe {
                                     let v = s.as_mut_vec();
                                     v[4] = (*v)[4].to_ascii_uppercase();
@@ -750,14 +762,14 @@ fn normalize__(s: &str, prefix: Option<PathPrefix>) -> Option<String> {
                             _ => {
                                 let plen = prefix_len(prefix);
                                 if s.len() > plen {
-                                    Some(String::from_str(s[0..plen]))
+                                    Some(String::from_str(s.index(&(0..plen))))
                                 } else { None }
                             }
                         }
                     } else if is_abs && comps.is_empty() {
                         Some(repeat(SEP).take(1).collect())
                     } else {
-                        let prefix_ = s[0..prefix_len(prefix)];
+                        let prefix_ = s.index(&(0..prefix_len(prefix)));
                         let n = prefix_.len() +
                                 if is_abs { comps.len() } else { comps.len() - 1} +
                                 comps.iter().map(|v| v.len()).sum();
@@ -768,15 +780,15 @@ fn normalize__(s: &str, prefix: Option<PathPrefix>) -> Option<String> {
                                 s.push(':');
                             }
                             Some(VerbatimDiskPrefix) => {
-                                s.push_str(prefix_[0..4]);
+                                s.push_str(prefix_.index(&(0..4)));
                                 s.push(prefix_.as_bytes()[4].to_ascii_uppercase() as char);
-                                s.push_str(prefix_[5..]);
+                                s.push_str(prefix_.index(&(5..)));
                             }
                             Some(UNCPrefix(a,b)) => {
                                 s.push_str("\\\\");
-                                s.push_str(prefix_[2..a+2]);
+                                s.push_str(prefix_.index(&(2..(a+2))));
                                 s.push(SEP);
-                                s.push_str(prefix_[3+a..3+a+b]);
+                                s.push_str(prefix_.index(&((3+a)..(3+a+b))));
                             }
                             Some(_) => s.push_str(prefix_),
                             None => ()
@@ -801,8 +813,8 @@ fn normalize__(s: &str, prefix: Option<PathPrefix>) -> Option<String> {
 
     fn update_sepidx(&mut self) {
         let s = if self.has_nonsemantic_trailing_slash() {
-                    self.repr[0..self.repr.len()-1]
-                } else { self.repr[] };
+                    self.repr.index(&(0..(self.repr.len()-1)))
+                } else { self.repr.index(&FullRange) };
         let sep_test: fn(char) -> bool = if !prefix_is_verbatim(self.prefix) {
             is_sep
         } else {
@@ -881,17 +893,17 @@ pub fn is_verbatim(path: &Path) -> bool {
 /// non-verbatim, the non-verbatim version is returned.
 /// Otherwise, None is returned.
 pub fn make_non_verbatim(path: &Path) -> Option<Path> {
-    let repr = path.repr[];
+    let repr = path.repr.index(&FullRange);
     let new_path = match path.prefix {
         Some(VerbatimPrefix(_)) | Some(DeviceNSPrefix(_)) => return None,
         Some(UNCPrefix(_,_)) | Some(DiskPrefix) | None => return Some(path.clone()),
         Some(VerbatimDiskPrefix) => {
             // \\?\D:\
-            Path::new(repr[4..])
+            Path::new(repr.index(&(4..)))
         }
         Some(VerbatimUNCPrefix(_,_)) => {
             // \\?\UNC\server\share
-            Path::new(format!(r"\{}", repr[7..]))
+            Path::new(format!(r"\{}", repr.index(&(7..))))
         }
     };
     if new_path.prefix.is_none() {
@@ -900,8 +912,8 @@ pub fn make_non_verbatim(path: &Path) -> Option<Path> {
         return None;
     }
     // now ensure normalization didn't change anything
-    if repr[path.prefix_len()..] ==
-        new_path.repr[new_path.prefix_len()..] {
+    if repr.index(&(path.prefix_len()..)) ==
+        new_path.repr.index(&(new_path.prefix_len()..)) {
         Some(new_path)
     } else {
         None
@@ -966,13 +978,13 @@ pub enum PathPrefix {
 fn parse_prefix<'a>(mut path: &'a str) -> Option<PathPrefix> {
     if path.starts_with("\\\\") {
         // \\
-        path = path[2..];
+        path = path.index(&(2..));
         if path.starts_with("?\\") {
             // \\?\
-            path = path[2..];
+            path = path.index(&(2..));
             if path.starts_with("UNC\\") {
                 // \\?\UNC\server\share
-                path = path[4..];
+                path = path.index(&(4..));
                 let (idx_a, idx_b) = match parse_two_comps(path, is_sep_verbatim) {
                     Some(x) => x,
                     None => (path.len(), 0)
@@ -993,7 +1005,7 @@ fn parse_prefix<'a>(mut path: &'a str) -> Option<PathPrefix> {
             }
         } else if path.starts_with(".\\") {
             // \\.\path
-            path = path[2..];
+            path = path.index(&(2..));
             let idx = path.find('\\').unwrap_or(path.len());
             return Some(DeviceNSPrefix(idx));
         }
@@ -1018,7 +1030,7 @@ fn parse_two_comps(mut path: &str, f: fn(char) -> bool) -> Option<(uint, uint)>
             None => return None,
             Some(x) => x
         };
-        path = path[idx_a+1..];
+        path = path.index(&((idx_a+1)..));
         let idx_b = path.find(f).unwrap_or(path.len());
         Some((idx_a, idx_b))
     }
@@ -1032,8 +1044,8 @@ fn normalize_helper<'a>(s: &'a str, prefix: Option<PathPrefix>) -> (bool, Option
         is_sep_verbatim
     };
     let is_abs = s.len() > prefix_len(prefix) && f(s.char_at(prefix_len(prefix)));
-    let s_ = s[prefix_len(prefix)..];
-    let s_ = if is_abs { s_[1..] } else { s_ };
+    let s_ = s.index(&(prefix_len(prefix)..));
+    let s_ = if is_abs { s_.index(&(1..)) } else { s_ };
 
     if is_abs && s_.is_empty() {
         return (is_abs, match prefix {
@@ -1114,13 +1126,13 @@ macro_rules! t {
         (s: $path:expr, $exp:expr) => (
             {
                 let path = $path;
-                assert!(path.as_str() == Some($exp));
+                assert_eq!(path.as_str(), Some($exp));
             }
         );
         (v: $path:expr, $exp:expr) => (
             {
                 let path = $path;
-                assert!(path.as_vec() == $exp);
+                assert_eq!(path.as_vec(), $exp);
             }
         )
     }
@@ -1133,8 +1145,7 @@ macro_rules! t {
                     let path = $path;
                     let exp = $exp;
                     let res = parse_prefix(path);
-                    assert!(res == exp,
-                            "parse_prefix(\"{}\"): expected {}, found {}", path, exp, res);
+                    assert_eq!(res, exp);
                 }
             )
         }
@@ -1287,17 +1298,17 @@ fn test_opt_paths() {
     #[test]
     fn test_null_byte() {
         use thread::Thread;
-        let result = Thread::spawn(move|| {
+        let result = Thread::scoped(move|| {
             Path::new(b"foo/bar\0")
         }).join();
         assert!(result.is_err());
 
-        let result = Thread::spawn(move|| {
+        let result = Thread::scoped(move|| {
             Path::new("test").set_filename(b"f\0o")
         }).join();
         assert!(result.is_err());
 
-        let result = Thread::spawn(move || {
+        let result = Thread::scoped(move || {
             Path::new("test").push(b"f\0o");
         }).join();
         assert!(result.is_err());
@@ -1350,7 +1361,7 @@ macro_rules! t {
                 {
                     let path = $path;
                     let path = Path::new(path);
-                    assert!(path.$op() == Some($exp));
+                    assert_eq!(path.$op(), Some($exp));
                 }
             );
             (s: $path:expr, $op:ident, $exp:expr, opt) => (
@@ -1358,14 +1369,14 @@ macro_rules! t {
                     let path = $path;
                     let path = Path::new(path);
                     let left = path.$op();
-                    assert!(left == $exp);
+                    assert_eq!(left, $exp);
                 }
             );
             (v: $path:expr, $op:ident, $exp:expr) => (
                 {
                     let path = $path;
                     let path = Path::new(path);
-                    assert!(path.$op() == $exp);
+                    assert_eq!(path.$op(), $exp);
                 }
             )
         }
@@ -1476,7 +1487,7 @@ macro_rules! t {
                     let mut p1 = Path::new(path);
                     let p2 = p1.clone();
                     p1.push(join);
-                    assert!(p1 == p2.join(join));
+                    assert_eq!(p1, p2.join(join));
                 }
             )
         }
@@ -1490,9 +1501,9 @@ macro_rules! t {
 
         // we do want to check one odd case though to ensure the prefix is re-parsed
         let mut p = Path::new("\\\\?\\C:");
-        assert!(prefix(&p) == Some(VerbatimPrefix(2)));
+        assert_eq!(prefix(&p), Some(VerbatimPrefix(2)));
         p.push("foo");
-        assert!(prefix(&p) == Some(VerbatimDiskPrefix));
+        assert_eq!(prefix(&p), Some(VerbatimDiskPrefix));
         assert_eq!(p.as_str(), Some("\\\\?\\C:\\foo"));
 
         // and another with verbatim non-normalized paths
@@ -1591,10 +1602,8 @@ macro_rules! t {
                     let mut p = Path::new(pstr);
                     let result = p.pop();
                     let left = $left;
-                    assert!(p.as_str() == Some(left),
-                        "`{}`.pop() failed; expected remainder `{}`, found `{}`",
-                        pstr, left, p.as_str().unwrap());
-                    assert!(result == $right);
+                    assert_eq!(p.as_str(), Some(left));
+                    assert_eq!(result, $right);
                 }
             );
             (b: $path:expr, $left:expr, $right:expr) => (
@@ -1602,7 +1611,7 @@ macro_rules! t {
                     let mut p = Path::new($path);
                     let result = p.pop();
                     assert_eq!(p.as_vec(), $left);
-                    assert!(result == $right);
+                    assert_eq!(result, $right);
                 }
             )
         }
@@ -1645,16 +1654,16 @@ macro_rules! t {
 
     #[test]
     fn test_root_path() {
-        assert!(Path::new("a\\b\\c").root_path() == None);
-        assert!(Path::new("\\a\\b\\c").root_path() == Some(Path::new("\\")));
-        assert!(Path::new("C:a").root_path() == Some(Path::new("C:")));
-        assert!(Path::new("C:\\a").root_path() == Some(Path::new("C:\\")));
-        assert!(Path::new("\\\\a\\b\\c").root_path() == Some(Path::new("\\\\a\\b")));
-        assert!(Path::new("\\\\?\\a\\b").root_path() == Some(Path::new("\\\\?\\a")));
-        assert!(Path::new("\\\\?\\C:\\a").root_path() == Some(Path::new("\\\\?\\C:\\")));
-        assert!(Path::new("\\\\?\\UNC\\a\\b\\c").root_path() ==
+        assert_eq!(Path::new("a\\b\\c").root_path(),  None);
+        assert_eq!(Path::new("\\a\\b\\c").root_path(), Some(Path::new("\\")));
+        assert_eq!(Path::new("C:a").root_path(), Some(Path::new("C:")));
+        assert_eq!(Path::new("C:\\a").root_path(), Some(Path::new("C:\\")));
+        assert_eq!(Path::new("\\\\a\\b\\c").root_path(), Some(Path::new("\\\\a\\b")));
+        assert_eq!(Path::new("\\\\?\\a\\b").root_path(), Some(Path::new("\\\\?\\a")));
+        assert_eq!(Path::new("\\\\?\\C:\\a").root_path(), Some(Path::new("\\\\?\\C:\\")));
+        assert_eq!(Path::new("\\\\?\\UNC\\a\\b\\c").root_path(),
                 Some(Path::new("\\\\?\\UNC\\a\\b")));
-        assert!(Path::new("\\\\.\\a\\b").root_path() == Some(Path::new("\\\\.\\a")));
+        assert_eq!(Path::new("\\\\.\\a\\b").root_path(), Some(Path::new("\\\\.\\a")));
     }
 
     #[test]
@@ -1731,10 +1740,8 @@ macro_rules! t {
                     let path = Path::new(pstr);
                     let arg = $arg;
                     let res = path.$op(arg);
-                    let exp = $res;
-                    assert!(res.as_str() == Some(exp),
-                            "`{}`.{}(\"{}\"): Expected `{}`, found `{}`",
-                            pstr, stringify!($op), arg, exp, res.as_str().unwrap());
+                    let exp = Path::new($res);
+                    assert_eq!(res, exp);
                 }
             )
         }
@@ -1817,7 +1824,7 @@ macro_rules! t {
                     let mut p1 = Path::new(path);
                     p1.$set(arg);
                     let p2 = Path::new(path);
-                    assert!(p1 == p2.$with(arg));
+                    assert_eq!(p1, p2.$with(arg));
                 }
             );
             (v: $path:expr, $set:ident, $with:ident, $arg:expr) => (
@@ -1827,7 +1834,7 @@ macro_rules! t {
                     let mut p1 = Path::new(path);
                     p1.$set(arg);
                     let p2 = Path::new(path);
-                    assert!(p1 == p2.$with(arg));
+                    assert_eq!(p1, p2.$with(arg));
                 }
             )
         }
@@ -1858,31 +1865,19 @@ macro_rules! t {
             (s: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => (
                 {
                     let path = $path;
-                    let filename = $filename;
-                    assert!(path.filename_str() == filename,
-                            "`{}`.filename_str(): Expected `{}`, found `{}`",
-                            path.as_str().unwrap(), filename, path.filename_str());
-                    let dirname = $dirname;
-                    assert!(path.dirname_str() == dirname,
-                            "`{}`.dirname_str(): Expected `{}`, found `{}`",
-                            path.as_str().unwrap(), dirname, path.dirname_str());
-                    let filestem = $filestem;
-                    assert!(path.filestem_str() == filestem,
-                            "`{}`.filestem_str(): Expected `{}`, found `{}`",
-                            path.as_str().unwrap(), filestem, path.filestem_str());
-                    let ext = $ext;
-                    assert!(path.extension_str() == ext,
-                            "`{}`.extension_str(): Expected `{}`, found `{}`",
-                            path.as_str().unwrap(), ext, path.extension_str());
+                    assert_eq!(path.filename_str(), $filename);
+                    assert_eq!(path.dirname_str(), $dirname);
+                    assert_eq!(path.filestem_str(), $filestem);
+                    assert_eq!(path.extension_str(), $ext);
                 }
             );
             (v: $path:expr, $filename:expr, $dirname:expr, $filestem:expr, $ext:expr) => (
                 {
                     let path = $path;
-                    assert!(path.filename() == $filename);
-                    assert!(path.dirname() == $dirname);
-                    assert!(path.filestem() == $filestem);
-                    assert!(path.extension() == $ext);
+                    assert_eq!(path.filename(), $filename);
+                    assert_eq!(path.dirname(), $dirname);
+                    assert_eq!(path.filestem(), $filestem);
+                    assert_eq!(path.extension(), $ext);
                 }
             )
         }
@@ -1925,18 +1920,10 @@ macro_rules! t {
                 {
                     let path = Path::new($path);
                     let (abs, vol, cwd, rel) = ($abs, $vol, $cwd, $rel);
-                    let b = path.is_absolute();
-                    assert!(b == abs, "Path '{}'.is_absolute(): expected {}, found {}",
-                            path.as_str().unwrap(), abs, b);
-                    let b = is_vol_relative(&path);
-                    assert!(b == vol, "is_vol_relative('{}'): expected {}, found {}",
-                            path.as_str().unwrap(), vol, b);
-                    let b = is_cwd_relative(&path);
-                    assert!(b == cwd, "is_cwd_relative('{}'): expected {}, found {}",
-                            path.as_str().unwrap(), cwd, b);
-                    let b = path.is_relative();
-                    assert!(b == rel, "Path '{}'.is_relativf(): expected {}, found {}",
-                            path.as_str().unwrap(), rel, b);
+                    assert_eq!(path.is_absolute(), abs);
+                    assert_eq!(is_vol_relative(&path), vol);
+                    assert_eq!(is_cwd_relative(&path), cwd);
+                    assert_eq!(path.is_relative(), rel);
                 }
             )
         }
@@ -1967,9 +1954,7 @@ macro_rules! t {
                     let dest = Path::new($dest);
                     let exp = $exp;
                     let res = path.is_ancestor_of(&dest);
-                    assert!(res == exp,
-                            "`{}`.is_ancestor_of(`{}`): Expected {}, found {}",
-                            path.as_str().unwrap(), dest.as_str().unwrap(), exp, res);
+                    assert_eq!(res, exp);
                 }
             )
         }
@@ -2098,14 +2083,8 @@ fn test_path_relative_from() {
         macro_rules! t {
             (s: $path:expr, $other:expr, $exp:expr) => (
                 {
-                    let path = Path::new($path);
-                    let other = Path::new($other);
-                    let res = path.path_relative_from(&other);
-                    let exp = $exp;
-                    assert!(res.as_ref().and_then(|x| x.as_str()) == exp,
-                            "`{}`.path_relative_from(`{}`): Expected {}, got {}",
-                            path.as_str().unwrap(), other.as_str().unwrap(), exp,
-                            res.as_ref().and_then(|x| x.as_str()));
+                    assert_eq!(Path::new($path).path_relative_from(&Path::new($other))
+                              .as_ref().and_then(|x| x.as_str()), $exp);
                 }
             )
         }
@@ -2314,7 +2293,7 @@ macro_rules! t {
                     let path = Path::new($path);
                     let exp: Option<&str> = $exp;
                     let exp = exp.map(|s| Path::new(s));
-                    assert!(make_non_verbatim(&path) == exp);
+                    assert_eq!(make_non_verbatim(&path), exp);
                 }
             )
         }
index 9e9a483e1a5e3f510922eb6ae9b652eda2848162..dcb342b9ca2c3dec35b06f76434c9b42fb5f8f37 100644 (file)
 #![stable]
 
 // Reexported core operators
-#[stable] #[doc(no_inline)] pub use kinds::{Copy, Send, Sized, Sync};
+#[stable] #[doc(no_inline)] pub use marker::{Copy, Send, Sized, Sync};
 #[stable] #[doc(no_inline)] pub use ops::{Drop, Fn, FnMut, FnOnce};
 
+// TEMPORARY
+#[unstable] #[doc(no_inline)] pub use ops::{Index, IndexMut, FullRange};
+
 // Reexported functions
 #[stable] #[doc(no_inline)] pub use mem::drop;
 
index 8855a7e5293ac18a04566cfc05cfccef1c6761f9..d3e6cd166ecf5e7916d736e1388b2f56c71e0308 100644 (file)
@@ -71,7 +71,7 @@
 //! use std::rand;
 //!
 //! let tuple = rand::random::<(f64, char)>();
-//! println!("{}", tuple)
+//! println!("{:?}", tuple)
 //! ```
 //!
 //! ## Monte Carlo estimation of π
@@ -303,7 +303,7 @@ fn from_seed(seed: &'a [uint]) -> StdRng {
 pub fn weak_rng() -> XorShiftRng {
     match OsRng::new() {
         Ok(mut r) => r.gen(),
-        Err(e) => panic!("weak_rng: failed to create seeded RNG: {}", e)
+        Err(e) => panic!("weak_rng: failed to create seeded RNG: {:?}", e)
     }
 }
 
@@ -490,7 +490,7 @@ fn test_gen_f64() {
         let mut r = thread_rng();
         let a = r.gen::<f64>();
         let b = r.gen::<f64>();
-        debug!("{}", (a, b));
+        debug!("{:?}", (a, b));
     }
 
     #[test]
index a79a6e35ebcfd377ff74265cba1a9ec9d842d149..18d40ecd3ebe54f6e1003f1627f236a7f4790703 100644 (file)
@@ -28,9 +28,6 @@ mod imp {
     use mem;
     use os::errno;
 
-    // NOTE: for old macros; remove after the next snapshot
-    #[cfg(stage0)] use result::Result::Err;
-
     #[cfg(all(target_os = "linux",
               any(target_arch = "x86_64",
                   target_arch = "x86",
@@ -185,7 +182,7 @@ mod imp {
     extern crate libc;
 
     use io::{IoResult};
-    use kinds::Sync;
+    use marker::Sync;
     use mem;
     use os;
     use rand::Rng;
@@ -397,7 +394,7 @@ fn test_os_rng_tasks() {
                     r.fill_bytes(&mut v);
                     Thread::yield_now();
                 }
-            }).detach();
+            });
         }
 
         // start all the tasks
index 48d7f2e7854da0421270185094414ab2a661fc87..177b7380831f2d450c4904c67aef7711c408385c 100644 (file)
@@ -67,7 +67,7 @@ fn fill_bytes(&mut self, v: &mut [u8]) {
         if v.len() == 0 { return }
         match self.reader.read_at_least(v.len(), v) {
             Ok(_) => {}
-            Err(e) => panic!("ReaderRng.fill_bytes error: {}", e)
+            Err(e) => panic!("ReaderRng.fill_bytes error: {:?}", e)
         }
     }
 }
index bbc96d0b19f125fa91ee2297e062e905ed937c76..1e3ab6d34dab9daecb05e14357c99ce7413e7a6b 100644 (file)
 //! they aren't defined anywhere outside of the `rt` module.
 
 macro_rules! rterrln {
-    ($fmt:expr $($arg:tt)*) => ( {
-        ::rt::util::dumb_print(format_args!(concat!($fmt, "\n") $($arg)*))
+    ($fmt:expr) => ( {
+        ::rt::util::dumb_print(format_args!(concat!($fmt, "\n")))
+    } );
+    ($fmt:expr, $($arg:expr),*) => ( {
+        ::rt::util::dumb_print(format_args!(concat!($fmt, "\n"), $($arg)*))
     } )
 }
 
 // Some basic logging. Enabled by passing `--cfg rtdebug` to the libstd build.
 macro_rules! rtdebug {
-    ($($arg:tt)*) => ( {
+    ($arg:expr) => ( {
         if cfg!(rtdebug) {
-            rterrln!($($arg)*)
+            rterrln!($arg)
+        }
+    } );
+    ($str:expr, $($arg:expr),*) => ( {
+        if cfg!(rtdebug) {
+            rterrln!($str, $($arg)*)
         }
     })
 }
index e556888a470a288b100364bf8fd29aaae1ae94bf..5ef55f5b487d0ad07563d5efe2b3485c32d1076f 100644 (file)
@@ -23,7 +23,7 @@
 
 #![allow(dead_code)]
 
-use kinds::Send;
+use marker::Send;
 use ops::FnOnce;
 use sys;
 use thunk::Thunk;
@@ -39,8 +39,7 @@
 pub mod backtrace;
 
 // Internals
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 mod macros;
 
 // These should be refactored/moved/made private over time
index 71169386c186aee9400b363232787cf25c4a64af..fd84f22094282a4a7d203c7d444e623e4f2c3ff8 100644 (file)
@@ -544,7 +544,7 @@ fn begin_unwind_inner(msg: Box<Any + Send>, file_line: &(&'static str, uint)) ->
     // MAX_CALLBACKS, so we're sure to clamp it as necessary.
     let callbacks = {
         let amt = CALLBACK_CNT.load(Ordering::SeqCst);
-        CALLBACKS[..cmp::min(amt, MAX_CALLBACKS)]
+        CALLBACKS.index(&(0..cmp::min(amt, MAX_CALLBACKS)))
     };
     for cb in callbacks.iter() {
         match cb.load(Ordering::SeqCst) {
index bc01ce926f8bc4306c43732cfdc51f8a546506af..59f654a95caa6e9f2e07fed18c3dc080e604cb5f 100644 (file)
@@ -131,7 +131,7 @@ struct BufWriter<'a> {
     impl<'a> fmt::Writer for BufWriter<'a> {
         fn write_str(&mut self, bytes: &str) -> fmt::Result {
             let left = self.buf.slice_from_mut(self.pos);
-            let to_write = bytes.as_bytes()[..cmp::min(bytes.len(), left.len())];
+            let to_write = bytes.as_bytes().index(&(0..cmp::min(bytes.len(), left.len())));
             slice::bytes::copy_memory(left, to_write);
             self.pos += to_write.len();
             Ok(())
@@ -142,7 +142,7 @@ fn write_str(&mut self, bytes: &str) -> fmt::Result {
     let mut msg = [0u8; 512];
     let mut w = BufWriter { buf: &mut msg, pos: 0 };
     let _ = write!(&mut w, "{}", args);
-    let msg = str::from_utf8(w.buf[mut ..w.pos]).unwrap_or("aborted");
+    let msg = str::from_utf8(w.buf.index_mut(&(0..w.pos))).unwrap_or("aborted");
     let msg = if msg.is_empty() {"aborted"} else {msg};
 
     // Give some context to the message
index bf5da3e7cbae018b18381d6899fd894fcee6a379..709398794003869abb034616fdc6fa793d98b64b 100644 (file)
@@ -26,7 +26,7 @@
 ///         println!("before wait");
 ///         c.wait();
 ///         println!("after wait");
-///     }).detach();
+///     });
 /// }
 /// ```
 #[stable]
@@ -126,7 +126,7 @@ fn test_barrier() {
             let tx = tx.clone();
             Thread::spawn(move|| {
                 tx.send(c.wait().is_leader()).unwrap();
-            }).detach();
+            });
         }
 
         // At this point, all spawned tasks should be blocked,
index e97be51fdbc25af6ccc56aec377ee00aee43173a..3c0ae71255dbe39632a8485ee04836e793bf832d 100644 (file)
@@ -48,7 +48,7 @@
 ///     let mut started = lock.lock().unwrap();
 ///     *started = true;
 ///     cvar.notify_one();
-/// }).detach();
+/// });
 ///
 /// // wait for the thread to start up
 /// let &(ref lock, ref cvar) = &*pair;
@@ -338,7 +338,7 @@ fn notify_all() {
                     cnt = cond.wait(cnt).unwrap();
                 }
                 tx.send(()).unwrap();
-            }).detach();
+            });
         }
         drop(tx);
 
index 4c6adcc04f67cc33da0b404aa97a7d46eb4e9a56..568c24446e7a34d9c9059fa302689054913ce221 100644 (file)
@@ -141,7 +141,7 @@ pub fn spawn<F>(blk: F) -> Future<A>
         Thread::spawn(move |:| {
             // Don't panic if the other end has hung up
             let _ = tx.send(blk());
-        }).detach();
+        });
 
         Future::from_receiver(rx)
     }
index faff5f09f81e118c2928585f94654a8471842427..f174771a3e011527a03f052b4252c8705549cdbc 100644 (file)
@@ -13,8 +13,8 @@
 use thread::Thread;
 use sync::atomic::{AtomicBool, ATOMIC_BOOL_INIT, Ordering};
 use sync::Arc;
-use kinds::{Sync, Send};
-use kinds::marker::{NoSend, NoSync};
+use marker::{Sync, Send};
+use marker::{NoSend, NoSync};
 use mem;
 use clone::Clone;
 
index 7c18b8a43faad827cbff96a4f577e61d2b8fc19a..eca7d3155b18be2983b1682d4922ec347267a98e 100644 (file)
@@ -60,7 +60,7 @@
 //! let (tx, rx) = channel();
 //! Thread::spawn(move|| {
 //!     tx.send(10i).unwrap();
-//! }).detach();
+//! });
 //! assert_eq!(rx.recv().unwrap(), 10i);
 //! ```
 //!
@@ -78,7 +78,7 @@
 //!     let tx = tx.clone();
 //!     Thread::spawn(move|| {
 //!         tx.send(i).unwrap();
-//!     }).detach()
+//!     });
 //! }
 //!
 //! for _ in range(0i, 10i) {
 //! Thread::spawn(move|| {
 //!     // This will wait for the parent task to start receiving
 //!     tx.send(53).unwrap();
-//! }).detach();
+//! });
 //! rx.recv().unwrap();
 //! ```
 //!
 
 use sync::Arc;
 use fmt;
-use kinds::marker;
+use marker;
 use mem;
 use cell::UnsafeCell;
 
@@ -476,12 +476,12 @@ fn inner_unsafe<'a>(&'a self) -> &'a UnsafeCell<Flavor<T>> {
 /// Thread::spawn(move|| {
 /// #   fn expensive_computation() {}
 ///     tx.send(expensive_computation()).unwrap();
-/// }).detach();
+/// });
 ///
 /// // Do some useful work for awhile
 ///
 /// // Let's see what that answer was
-/// println!("{}", rx.recv().unwrap());
+/// println!("{:?}", rx.recv().unwrap());
 /// ```
 #[stable]
 pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
@@ -518,7 +518,7 @@ pub fn channel<T: Send>() -> (Sender<T>, Receiver<T>) {
 /// Thread::spawn(move|| {
 ///     // this will block until the previous message has been received
 ///     tx.send(2i).unwrap();
-/// }).detach();
+/// });
 ///
 /// assert_eq!(rx.recv().unwrap(), 1i);
 /// assert_eq!(rx.recv().unwrap(), 2i);
@@ -1144,7 +1144,7 @@ fn chan_gone_concurrent() {
     #[test]
     fn stress() {
         let (tx, rx) = channel::<int>();
-        let t = Thread::spawn(move|| {
+        let t = Thread::scoped(move|| {
             for _ in range(0u, 10000) { tx.send(1i).unwrap(); }
         });
         for _ in range(0u, 10000) {
@@ -1159,7 +1159,7 @@ fn stress_shared() {
         static NTHREADS: uint = 8;
         let (tx, rx) = channel::<int>();
 
-        let t = Thread::spawn(move|| {
+        let t = Thread::scoped(move|| {
             for _ in range(0, AMT * NTHREADS) {
                 assert_eq!(rx.recv().unwrap(), 1);
             }
@@ -1173,7 +1173,7 @@ fn stress_shared() {
             let tx = tx.clone();
             Thread::spawn(move|| {
                 for _ in range(0, AMT) { tx.send(1).unwrap(); }
-            }).detach();
+            });
         }
         drop(tx);
         t.join().ok().unwrap();
@@ -1183,14 +1183,14 @@ fn stress_shared() {
     fn send_from_outside_runtime() {
         let (tx1, rx1) = channel::<()>();
         let (tx2, rx2) = channel::<int>();
-        let t1 = Thread::spawn(move|| {
+        let t1 = Thread::scoped(move|| {
             tx1.send(()).unwrap();
             for _ in range(0i, 40) {
                 assert_eq!(rx2.recv().unwrap(), 1);
             }
         });
         rx1.recv().unwrap();
-        let t2 = Thread::spawn(move|| {
+        let t2 = Thread::scoped(move|| {
             for _ in range(0i, 40) {
                 tx2.send(1).unwrap();
             }
@@ -1202,7 +1202,7 @@ fn send_from_outside_runtime() {
     #[test]
     fn recv_from_outside_runtime() {
         let (tx, rx) = channel::<int>();
-        let t = Thread::spawn(move|| {
+        let t = Thread::scoped(move|| {
             for _ in range(0i, 40) {
                 assert_eq!(rx.recv().unwrap(), 1);
             }
@@ -1217,11 +1217,11 @@ fn recv_from_outside_runtime() {
     fn no_runtime() {
         let (tx1, rx1) = channel::<int>();
         let (tx2, rx2) = channel::<int>();
-        let t1 = Thread::spawn(move|| {
+        let t1 = Thread::scoped(move|| {
             assert_eq!(rx1.recv().unwrap(), 1);
             tx2.send(2).unwrap();
         });
-        let t2 = Thread::spawn(move|| {
+        let t2 = Thread::scoped(move|| {
             tx1.send(1).unwrap();
             assert_eq!(rx2.recv().unwrap(), 2);
         });
@@ -1254,7 +1254,7 @@ fn oneshot_single_thread_send_port_close() {
     #[test]
     fn oneshot_single_thread_recv_chan_close() {
         // Receiving on a closed chan will panic
-        let res = Thread::spawn(move|| {
+        let res = Thread::scoped(move|| {
             let (tx, rx) = channel::<int>();
             drop(tx);
             rx.recv().unwrap();
@@ -1336,7 +1336,7 @@ fn oneshot_multi_task_recv_then_close() {
         let _t = Thread::spawn(move|| {
             drop(tx);
         });
-        let res = Thread::spawn(move|| {
+        let res = Thread::scoped(move|| {
             assert!(rx.recv().unwrap() == box 10);
         }).join();
         assert!(res.is_err());
@@ -1360,7 +1360,7 @@ fn oneshot_multi_thread_send_close_stress() {
             let _t = Thread::spawn(move|| {
                 drop(rx);
             });
-            let _ = Thread::spawn(move|| {
+            let _ = Thread::scoped(move|| {
                 tx.send(1).unwrap();
             }).join();
         }
@@ -1371,15 +1371,15 @@ fn oneshot_multi_thread_recv_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = channel::<int>();
             Thread::spawn(move|| {
-                let res = Thread::spawn(move|| {
+                let res = Thread::scoped(move|| {
                     rx.recv().unwrap();
                 }).join();
                 assert!(res.is_err());
-            }).detach();
+            });
             let _t = Thread::spawn(move|| {
                 Thread::spawn(move|| {
                     drop(tx);
-                }).detach();
+                });
             });
         }
     }
@@ -1409,7 +1409,7 @@ fn send(tx: Sender<Box<int>>, i: int) {
                 Thread::spawn(move|| {
                     tx.send(box i).unwrap();
                     send(tx, i + 1);
-                }).detach();
+                });
             }
 
             fn recv(rx: Receiver<Box<int>>, i: int) {
@@ -1418,7 +1418,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
                 Thread::spawn(move|| {
                     assert!(rx.recv().unwrap() == box i);
                     recv(rx, i + 1);
-                }).detach();
+                });
             }
         }
     }
@@ -1439,7 +1439,7 @@ fn shared_chan_stress() {
             let tx = tx.clone();
             Thread::spawn(move|| {
                 tx.send(()).unwrap();
-            }).detach();
+            });
         }
 
         for _ in range(0, total) {
@@ -1644,7 +1644,7 @@ fn chan_gone_concurrent() {
         Thread::spawn(move|| {
             tx.send(1).unwrap();
             tx.send(1).unwrap();
-        }).detach();
+        });
         while rx.recv().is_ok() {}
     }
 
@@ -1653,7 +1653,7 @@ fn stress() {
         let (tx, rx) = sync_channel::<int>(0);
         Thread::spawn(move|| {
             for _ in range(0u, 10000) { tx.send(1).unwrap(); }
-        }).detach();
+        });
         for _ in range(0u, 10000) {
             assert_eq!(rx.recv().unwrap(), 1);
         }
@@ -1675,13 +1675,13 @@ fn stress_shared() {
                 _ => {}
             }
             dtx.send(()).unwrap();
-        }).detach();
+        });
 
         for _ in range(0, NTHREADS) {
             let tx = tx.clone();
             Thread::spawn(move|| {
                 for _ in range(0, AMT) { tx.send(1).unwrap(); }
-            }).detach();
+            });
         }
         drop(tx);
         drx.recv().unwrap();
@@ -1712,7 +1712,7 @@ fn oneshot_single_thread_send_port_close() {
     #[test]
     fn oneshot_single_thread_recv_chan_close() {
         // Receiving on a closed chan will panic
-        let res = Thread::spawn(move|| {
+        let res = Thread::scoped(move|| {
             let (tx, rx) = sync_channel::<int>(0);
             drop(tx);
             rx.recv().unwrap();
@@ -1800,7 +1800,7 @@ fn oneshot_multi_task_recv_then_close() {
         let _t = Thread::spawn(move|| {
             drop(tx);
         });
-        let res = Thread::spawn(move|| {
+        let res = Thread::scoped(move|| {
             assert!(rx.recv().unwrap() == box 10);
         }).join();
         assert!(res.is_err());
@@ -1824,7 +1824,7 @@ fn oneshot_multi_thread_send_close_stress() {
             let _t = Thread::spawn(move|| {
                 drop(rx);
             });
-            let _ = Thread::spawn(move || {
+            let _ = Thread::scoped(move || {
                 tx.send(1).unwrap();
             }).join();
         }
@@ -1835,7 +1835,7 @@ fn oneshot_multi_thread_recv_close_stress() {
         for _ in range(0, stress_factor()) {
             let (tx, rx) = sync_channel::<int>(0);
             let _t = Thread::spawn(move|| {
-                let res = Thread::spawn(move|| {
+                let res = Thread::scoped(move|| {
                     rx.recv().unwrap();
                 }).join();
                 assert!(res.is_err());
@@ -1843,7 +1843,7 @@ fn oneshot_multi_thread_recv_close_stress() {
             let _t = Thread::spawn(move|| {
                 Thread::spawn(move|| {
                     drop(tx);
-                }).detach();
+                });
             });
         }
     }
@@ -1873,7 +1873,7 @@ fn send(tx: SyncSender<Box<int>>, i: int) {
                 Thread::spawn(move|| {
                     tx.send(box i).unwrap();
                     send(tx, i + 1);
-                }).detach();
+                });
             }
 
             fn recv(rx: Receiver<Box<int>>, i: int) {
@@ -1882,7 +1882,7 @@ fn recv(rx: Receiver<Box<int>>, i: int) {
                 Thread::spawn(move|| {
                     assert!(rx.recv().unwrap() == box i);
                     recv(rx, i + 1);
-                }).detach();
+                });
             }
         }
     }
@@ -1903,7 +1903,7 @@ fn shared_chan_stress() {
             let tx = tx.clone();
             Thread::spawn(move|| {
                 tx.send(()).unwrap();
-            }).detach();
+            });
         }
 
         for _ in range(0, total) {
index 9ad24a5a11ec5dfb61080a507b4d4a61920a8198..f8eae1322bf1f7b9bbeb5e2c6b38d870d6c1a018 100644 (file)
@@ -188,7 +188,7 @@ fn test() {
                     q.push(i);
                 }
                 tx.send(()).unwrap();
-            }).detach();
+            });
         }
 
         let mut i = 0u;
index 16adbf5aa4f69a24f6905ddeec193aa676b6feec..b7bb22b3ef3147ea94304e90554b1752ae8643da 100644 (file)
@@ -57,7 +57,7 @@
 use core::prelude::*;
 
 use core::cell::Cell;
-use core::kinds::marker;
+use core::marker;
 use core::mem;
 use core::uint;
 
index 6836888e67e5528c3136268974a5ba05070e6b09..b2cc807eb111d51879b19067a357de57ce01b462 100644 (file)
@@ -437,7 +437,8 @@ fn dequeue(&mut self) -> T {
         let start = self.start;
         self.size -= 1;
         self.start = (self.start + 1) % self.buf.len();
-        self.buf[start].take().unwrap()
+        let result = &mut self.buf[start];
+        result.take().unwrap()
     }
 
     fn size(&self) -> uint { self.size }
index 6b3dd89f33b07fcc71cc4a4a02cdfd7c4072ec2a..c1b55c6ff78db3b3f91bc0201f7994f8e428b29c 100644 (file)
@@ -11,7 +11,7 @@
 use prelude::v1::*;
 
 use cell::UnsafeCell;
-use kinds::marker;
+use marker;
 use ops::{Deref, DerefMut};
 use sync::poison::{self, TryLockError, TryLockResult, LockResult};
 use sys_common::mutex as sys;
@@ -75,7 +75,7 @@
 ///             tx.send(()).unwrap();
 ///         }
 ///         // the lock is unlocked here when `data` goes out of scope.
-///     }).detach();
+///     });
 /// }
 ///
 /// rx.recv().unwrap();
@@ -90,7 +90,7 @@
 /// let lock = Arc::new(Mutex::new(0u));
 /// let lock2 = lock.clone();
 ///
-/// let _ = Thread::spawn(move || -> () {
+/// let _ = Thread::scoped(move || -> () {
 ///     // This thread will acquire the mutex first, unwrapping the result of
 ///     // `lock` because the lock has not been poisoned.
 ///     let _lock = lock2.lock().unwrap();
@@ -376,9 +376,9 @@ fn inc() {
         let (tx, rx) = channel();
         for _ in range(0, K) {
             let tx2 = tx.clone();
-            Thread::spawn(move|| { inc(); tx2.send(()).unwrap(); }).detach();
+            Thread::spawn(move|| { inc(); tx2.send(()).unwrap(); });
             let tx2 = tx.clone();
-            Thread::spawn(move|| { inc(); tx2.send(()).unwrap(); }).detach();
+            Thread::spawn(move|| { inc(); tx2.send(()).unwrap(); });
         }
 
         drop(tx);
@@ -453,7 +453,7 @@ fn test_arc_condvar_poison() {
     fn test_mutex_arc_poison() {
         let arc = Arc::new(Mutex::new(1i));
         let arc2 = arc.clone();
-        let _ = Thread::spawn(move|| {
+        let _ = Thread::scoped(move|| {
             let lock = arc2.lock().unwrap();
             assert_eq!(*lock, 2);
         }).join();
@@ -480,7 +480,7 @@ fn test_mutex_arc_nested() {
     fn test_mutex_arc_access_in_unwind() {
         let arc = Arc::new(Mutex::new(1i));
         let arc2 = arc.clone();
-        let _ = Thread::spawn(move|| -> () {
+        let _ = Thread::scoped(move|| -> () {
             struct Unwinder {
                 i: Arc<Mutex<int>>,
             }
index aa2d957a3eb5e14bb3268b2e539fcc51e31ff939..3bf2ae277e0df10f89913db4e0f48e4f14c6374f 100644 (file)
@@ -14,7 +14,7 @@
 //! example use case would be for initializing an FFI library.
 
 use int;
-use kinds::Sync;
+use marker::Sync;
 use mem::drop;
 use ops::FnOnce;
 use sync::atomic::{AtomicInt, Ordering, ATOMIC_INT_INIT};
@@ -159,7 +159,7 @@ fn stampede_once() {
                     assert!(run);
                 }
                 tx.send(()).unwrap();
-            }).detach();
+            });
         }
 
         unsafe {
index 4afd5bb63f4fec79c368880afcd2b433d23d0d48..7db2111cc4629eed04b5fa749498bf5db000305e 100644 (file)
@@ -11,7 +11,7 @@
 use prelude::v1::*;
 
 use cell::UnsafeCell;
-use kinds::marker;
+use marker;
 use ops::{Deref, DerefMut};
 use sync::poison::{self, LockResult, TryLockError, TryLockResult};
 use sys_common::rwlock as sys;
@@ -411,7 +411,7 @@ fn frob() {
                     }
                 }
                 drop(tx);
-            }).detach();
+            });
         }
         drop(tx);
         let _ = rx.recv();
@@ -422,7 +422,7 @@ fn frob() {
     fn test_rw_arc_poison_wr() {
         let arc = Arc::new(RwLock::new(1i));
         let arc2 = arc.clone();
-        let _: Result<uint, _> = Thread::spawn(move|| {
+        let _: Result<uint, _> = Thread::scoped(move|| {
             let _lock = arc2.write().unwrap();
             panic!();
         }).join();
@@ -433,7 +433,7 @@ fn test_rw_arc_poison_wr() {
     fn test_rw_arc_poison_ww() {
         let arc = Arc::new(RwLock::new(1i));
         let arc2 = arc.clone();
-        let _: Result<uint, _> = Thread::spawn(move|| {
+        let _: Result<uint, _> = Thread::scoped(move|| {
             let _lock = arc2.write().unwrap();
             panic!();
         }).join();
@@ -444,7 +444,7 @@ fn test_rw_arc_poison_ww() {
     fn test_rw_arc_no_poison_rr() {
         let arc = Arc::new(RwLock::new(1i));
         let arc2 = arc.clone();
-        let _: Result<uint, _> = Thread::spawn(move|| {
+        let _: Result<uint, _> = Thread::scoped(move|| {
             let _lock = arc2.read().unwrap();
             panic!();
         }).join();
@@ -455,7 +455,7 @@ fn test_rw_arc_no_poison_rr() {
     fn test_rw_arc_no_poison_rw() {
         let arc = Arc::new(RwLock::new(1i));
         let arc2 = arc.clone();
-        let _: Result<uint, _> = Thread::spawn(move|| {
+        let _: Result<uint, _> = Thread::scoped(move|| {
             let _lock = arc2.read().unwrap();
             panic!()
         }).join();
@@ -478,13 +478,13 @@ fn test_rw_arc() {
                 *lock = tmp + 1;
             }
             tx.send(()).unwrap();
-        }).detach();
+        });
 
         // Readers try to catch the writer in the act
         let mut children = Vec::new();
         for _ in range(0u, 5) {
             let arc3 = arc.clone();
-            children.push(Thread::spawn(move|| {
+            children.push(Thread::scoped(move|| {
                 let lock = arc3.read().unwrap();
                 assert!(*lock >= 0);
             }));
@@ -505,7 +505,7 @@ fn test_rw_arc() {
     fn test_rw_arc_access_in_unwind() {
         let arc = Arc::new(RwLock::new(1i));
         let arc2 = arc.clone();
-        let _ = Thread::spawn(move|| -> () {
+        let _ = Thread::scoped(move|| -> () {
             struct Unwinder {
                 i: Arc<RwLock<int>>,
             }
index 505819fbf8a246cf4ee618b64e89cb921dd8d8a7..8d44084671aad2c61c3a77ad42b8021ec5606aaf 100644 (file)
@@ -193,7 +193,7 @@ fn test_sem_runtime_friendly_blocking() {
                 tx.send(()).unwrap();
                 drop(s2.access());
                 tx.send(()).unwrap();
-            }).detach();
+            });
             rx.recv().unwrap(); // wait for child to come alive
         }
         rx.recv().unwrap(); // wait for child to be done
index 088827dc0842d9041d70db2f98f60dbed7904e13..278528bdb388bd711c747be4143e338104702c8b 100644 (file)
@@ -132,7 +132,7 @@ fn spawn_in_pool(jobs: Arc<Mutex<Receiver<Thunk>>>) {
         }
 
         sentinel.cancel();
-    }).detach();
+    });
 }
 
 #[cfg(test)]
index d4039fd96ff204c92ae087e0014e3c79cfb8b3fd..be44aa99f49d764aca3b65f8dc8baa2d375081da 100644 (file)
@@ -88,7 +88,7 @@ pub fn demangle(writer: &mut Writer, s: &str) -> IoResult<()> {
             while rest.len() > 0 {
                 if rest.starts_with("$") {
                     macro_rules! demangle {
-                        ($($pat:expr => $demangled:expr),*) => ({
+                        ($($pat:expr, => $demangled:expr),*) => ({
                             $(if rest.starts_with($pat) {
                                 try!(writer.write_str($demangled));
                                 rest = rest.slice_from($pat.len());
@@ -103,22 +103,22 @@ macro_rules! demangle {
 
                     // see src/librustc/back/link.rs for these mappings
                     demangle! (
-                        "$SP$" => "@",
-                        "$UP$" => "Box",
-                        "$RP$" => "*",
-                        "$BP$" => "&",
-                        "$LT$" => "<",
-                        "$GT$" => ">",
-                        "$LP$" => "(",
-                        "$RP$" => ")",
-                        "$C$"  => ",",
+                        "$SP$", => "@",
+                        "$UP$", => "Box",
+                        "$RP$", => "*",
+                        "$BP$", => "&",
+                        "$LT$", => "<",
+                        "$GT$", => ">",
+                        "$LP$", => "(",
+                        "$RP$", => ")",
+                        "$C$", => ",",
 
                         // in theory we can demangle any Unicode code point, but
                         // for simplicity we just catch the common ones.
-                        "$u{20}" => " ",
-                        "$u{27}" => "'",
-                        "$u{5b}" => "[",
-                        "$u{5d}" => "]"
+                        "$u{20}", => " ",
+                        "$u{27}", => "'",
+                        "$u{5b}", => "[",
+                        "$u{5d}", => "]"
                     )
                 } else {
                     let idx = match rest.find('$') {
index bdf1bf3dfd02ceca099d0be7d70e2cc3324be749..f940b6ed3682e5253257d5fbd433cfc5e894b4a0 100644 (file)
@@ -99,7 +99,7 @@ pub fn boot<T, F>(&'static self, f: F, helper: fn(helper_signal::signal, Receive
                     let _g = self.lock.lock().unwrap();
                     *self.shutdown.get() = true;
                     self.cond.notify_one()
-                }).detach();
+                });
 
                 rt::at_exit(move|:| { self.shutdown() });
                 *self.initialized.get() = true;
index 567c26956efe94f6c3a1e62d440b7e75b9d46035..9aea0fb3b31725f8743949065b48cc1c333ab8d5 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use kinds::Sync;
+use marker::Sync;
 use sys::mutex as imp;
 
 /// An OS-based mutual exclusion lock.
index 4cf891ac4985eba360859a1cff038719ce3ca9a8..902942d7244f7687b248098d00b700c4ab86f0f6 100644 (file)
@@ -469,7 +469,7 @@ pub fn write<T, L, W>(fd: sock_t,
             // Also as with read(), we use MSG_DONTWAIT to guard ourselves
             // against unforeseen circumstances.
             let _guard = lock();
-            let ptr = buf[written..].as_ptr();
+            let ptr = buf.index(&(written..)).as_ptr();
             let len = buf.len() - written;
             match retry(|| write(deadline.is_some(), ptr, len)) {
                 -1 if wouldblock() => {}
index ca268a8f27ff34680a915eff95255b7f4acd2093..7164931c55acd0fea51d1ae90705753707282380 100644 (file)
@@ -370,7 +370,7 @@ unsafe fn init_state() -> *mut backtrace_state {
 // Finally, after all that work above, we can emit a symbol.
 fn output(w: &mut Writer, idx: int, addr: *mut libc::c_void,
           s: Option<&[u8]>) -> IoResult<()> {
-    try!(write!(w, "  {:2}: {:2$} - ", idx, addr, HEX_WIDTH));
+    try!(write!(w, "  {:2}: {:2$?} - ", idx, addr, HEX_WIDTH));
     match s.and_then(|s| str::from_utf8(s).ok()) {
         Some(string) => try!(demangle(w, string)),
         None => try!(write!(w, "<unknown>")),
index ca419d1c7f436044f90c5dd2a1c17787c5db2f39..cc661877bc01e4c5847d744a06662542ef47fb90 100644 (file)
@@ -165,8 +165,8 @@ pub struct sigaction {
         sa_restorer: *mut libc::c_void,
     }
 
-    unsafe impl ::kinds::Send for sigaction { }
-    unsafe impl ::kinds::Sync for sigaction { }
+    unsafe impl ::marker::Send for sigaction { }
+    unsafe impl ::marker::Sync for sigaction { }
 
     #[repr(C)]
     #[cfg(target_word_size = "32")]
@@ -217,8 +217,8 @@ pub struct sigaction {
         sa_resv: [libc::c_int; 1],
     }
 
-    unsafe impl ::kinds::Send for sigaction { }
-    unsafe impl ::kinds::Sync for sigaction { }
+    unsafe impl ::marker::Send for sigaction { }
+    unsafe impl ::marker::Sync for sigaction { }
 
     #[repr(C)]
     pub struct sigset_t {
index 1ad775517bba714aac62f8ea639ed31660d1d935..c53f9d22790dd44de154e192b33d872bbd287ec6 100644 (file)
@@ -381,7 +381,7 @@ fn test_file_desc() {
                 assert_eq!(buf[2], 's' as u8);
                 assert_eq!(buf[3], 't' as u8);
             }
-            r => panic!("invalid read: {}", r),
+            r => panic!("invalid read: {:?}", r),
         }
 
         assert!(writer.read(&mut buf).is_err());
index 81f8659d6ae08b87c79c247655ab1c68a668a1ba..ada8a7f2349bb6992de620e3c35bbc1cfbb31407 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 use cell::UnsafeCell;
-use kinds::Sync;
+use marker::Sync;
 use sys::sync as ffi;
 use sys_common::mutex;
 
index 5bc6b0c703b1c9c90057820cb37f2880bec164aa..1357bbdd5a3710dfb8fb7e3e126909ffdafc71f3 100644 (file)
@@ -125,7 +125,7 @@ fn combine(arr: &[u8]) -> i32 {
                     return match input.read(&mut bytes) {
                         Ok(8) => {
                             assert!(combine(CLOEXEC_MSG_FOOTER) == combine(bytes.slice(4, 8)),
-                                "Validation on the CLOEXEC pipe failed: {}", bytes);
+                                "Validation on the CLOEXEC pipe failed: {:?}", bytes);
                             let errno = combine(bytes.slice(0, 4));
                             assert!(p.wait(0).is_ok(), "wait(0) should either return Ok or panic");
                             Err(super::decode_error(errno))
@@ -133,7 +133,7 @@ fn combine(arr: &[u8]) -> i32 {
                         Err(ref e) if e.kind == EndOfFile => Ok(p),
                         Err(e) => {
                             assert!(p.wait(0).is_ok(), "wait(0) should either return Ok or panic");
-                            panic!("the CLOEXEC pipe failed: {}", e)
+                            panic!("the CLOEXEC pipe failed: {:?}", e)
                         },
                         Ok(..) => { // pipe I/O up to PIPE_BUF bytes should be atomic
                             assert!(p.wait(0).is_ok(), "wait(0) should either return Ok or panic");
@@ -285,7 +285,7 @@ pub fn wait(&self, deadline: u64) -> IoResult<ProcessExit> {
         let mut status = 0 as c_int;
         if deadline == 0 {
             return match retry(|| unsafe { c::waitpid(self.pid, &mut status, 0) }) {
-                -1 => panic!("unknown waitpid error: {}", super::last_error()),
+                -1 => panic!("unknown waitpid error: {:?}", super::last_error()),
                 _ => Ok(translate_status(status)),
             }
         }
@@ -410,7 +410,7 @@ fn waitpid_helper(input: libc::c_int,
                         continue
                     }
 
-                    n => panic!("error in select {} ({})", os::errno(), n),
+                    n => panic!("error in select {:?} ({:?})", os::errno(), n),
                 }
 
                 // Process any pending messages
@@ -491,7 +491,7 @@ fn drain(fd: libc::c_int) -> bool {
                     n if n > 0 => { ret = true; }
                     0 => return true,
                     -1 if wouldblock() => return ret,
-                    n => panic!("bad read {} ({})", os::last_os_error(), n),
+                    n => panic!("bad read {:?} ({:?})", os::last_os_error(), n),
                 }
             }
         }
@@ -514,7 +514,7 @@ fn drain(fd: libc::c_int) -> bool {
             } {
                 1 => {}
                 -1 if wouldblock() => {} // see above comments
-                n => panic!("bad error on write fd: {} {}", n, os::errno()),
+                n => panic!("bad error on write fd: {:?} {:?}", n, os::errno()),
             }
         }
     }
@@ -526,7 +526,7 @@ pub fn try_wait(&self) -> Option<ProcessExit> {
         }) {
             n if n == self.pid => Some(translate_status(status)),
             0 => None,
-            n => panic!("unknown waitpid error `{}`: {}", n,
+            n => panic!("unknown waitpid error `{:?}`: {:?}", n,
                        super::last_error()),
         }
     }
index e507377a8fcdd880a01c5b98ee53145a7463cfaa..ea1e9c261fecfbb4279c3e228d5f3512d62b16f5 100644 (file)
@@ -37,10 +37,18 @@ pub unsafe fn destroy(key: Key) {
     debug_assert_eq!(r, 0);
 }
 
-#[cfg(target_os = "macos")]
+#[cfg(any(target_os = "macos",
+          target_os = "ios"))]
 type pthread_key_t = ::libc::c_ulong;
 
-#[cfg(not(target_os = "macos"))]
+#[cfg(any(target_os = "freebsd",
+          target_os = "dragonfly"))]
+type pthread_key_t = ::libc::c_int;
+
+#[cfg(not(any(target_os = "macos",
+              target_os = "ios",
+              target_os = "freebsd",
+              target_os = "dragonfly")))]
 type pthread_key_t = ::libc::c_uint;
 
 extern {
index 4ccecfd1f5f2e6cc35f754cbe7049dcd23181388..eb76f13afe72167112570df8e31c92acf0574674 100644 (file)
@@ -23,6 +23,7 @@
 
 use dynamic_lib::DynamicLibrary;
 use ffi;
+use core::ops::Index;
 use intrinsics;
 use io::{IoResult, Writer};
 use libc;
@@ -361,7 +362,7 @@ macro_rules! sym{ ($e:expr, $t:ident) => (unsafe {
             let bytes = unsafe { ffi::c_str_to_bytes(&ptr) };
             match str::from_utf8(bytes) {
                 Ok(s) => try!(demangle(w, s)),
-                Err(..) => try!(w.write(bytes[..bytes.len()-1])),
+                Err(..) => try!(w.write(bytes.index(&(..(bytes.len()-1))))),
             }
         }
         try!(w.write(&['\n' as u8]));
index 945c2e8e7d156ce501ca029f5b54483123a3acd5..37ed32fa36773918981d5f4dc20598ec35456114 100644 (file)
@@ -84,6 +84,32 @@ pub fn fd_set(set: &mut fd_set, s: libc::SOCKET) {
     set.fd_count += 1;
 }
 
+pub type SHORT = libc::c_short;
+
+#[repr(C)]
+pub struct COORD {
+    pub X: SHORT,
+    pub Y: SHORT,
+}
+
+#[repr(C)]
+pub struct SMALL_RECT {
+    pub Left: SHORT,
+    pub Top: SHORT,
+    pub Right: SHORT,
+    pub Bottom: SHORT,
+}
+
+#[repr(C)]
+pub struct CONSOLE_SCREEN_BUFFER_INFO {
+    pub dwSize: COORD,
+    pub dwCursorPosition: COORD,
+    pub wAttributes: libc::WORD,
+    pub srWindow: SMALL_RECT,
+    pub dwMaximumWindowSize: COORD,
+}
+pub type PCONSOLE_SCREEN_BUFFER_INFO = *mut CONSOLE_SCREEN_BUFFER_INFO;
+
 #[link(name = "ws2_32")]
 extern "system" {
     pub fn WSAStartup(wVersionRequested: libc::WORD,
@@ -170,7 +196,7 @@ unsafe fn store_func(ptr: *mut uint, module: &str, symbol: &str, fallback: uint)
     /// they are used to be passed to the real function if available.
     macro_rules! compat_fn {
         ($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*)
-                                      -> $rettype:ty $fallback:block) => (
+                                      -> $rettype:ty { $fallback:expr }) => (
             #[inline(always)]
             pub unsafe fn $symbol($($argname: $argtype),*) -> $rettype {
                 static mut ptr: extern "system" fn($($argname: $argtype),*) -> $rettype = thunk;
@@ -185,14 +211,11 @@ extern "system" fn thunk($($argname: $argtype),*) -> $rettype {
                     }
                 }
 
-                extern "system" fn fallback($($argname: $argtype),*) -> $rettype $fallback
+                extern "system" fn fallback($($argname: $argtype),*)
+                                            -> $rettype { $fallback }
 
                 ::intrinsics::atomic_load_relaxed(&ptr)($($argname),*)
             }
-        );
-
-        ($module:ident::$symbol:ident($($argname:ident: $argtype:ty),*) $fallback:block) => (
-            compat_fn!($module::$symbol($($argname: $argtype),*) -> () $fallback)
         )
     }
 
@@ -210,20 +233,22 @@ pub mod kernel32 {
             fn SetLastError(dwErrCode: DWORD);
         }
 
-        compat_fn! { kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR,
-                                                 _lpTargetFileName: LPCWSTR,
-                                                 _dwFlags: DWORD) -> BOOLEAN {
-            unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); }
-            0
-        } }
-
-        compat_fn! { kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE,
-                                                       _lpszFilePath: LPCWSTR,
-                                                       _cchFilePath: DWORD,
-                                                       _dwFlags: DWORD) -> DWORD {
-            unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); }
-            0
-        } }
+        compat_fn! {
+            kernel32::CreateSymbolicLinkW(_lpSymlinkFileName: LPCWSTR,
+                                          _lpTargetFileName: LPCWSTR,
+                                          _dwFlags: DWORD) -> BOOLEAN {
+                unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 }
+            }
+        }
+
+        compat_fn! {
+            kernel32::GetFinalPathNameByHandleW(_hFile: HANDLE,
+                                                _lpszFilePath: LPCWSTR,
+                                                _cchFilePath: DWORD,
+                                                _dwFlags: DWORD) -> DWORD {
+                unsafe { SetLastError(ERROR_CALL_NOT_IMPLEMENTED as DWORD); 0 }
+            }
+        }
     }
 }
 
@@ -246,4 +271,8 @@ pub fn GetConsoleMode(hConsoleHandle: libc::HANDLE,
 
     pub fn SetConsoleMode(hConsoleHandle: libc::HANDLE,
                           lpMode: libc::DWORD) -> libc::BOOL;
+    pub fn GetConsoleScreenBufferInfo(
+        hConsoleOutput: libc::HANDLE,
+        lpConsoleScreenBufferInfo: PCONSOLE_SCREEN_BUFFER_INFO,
+    ) -> libc::BOOL;
 }
index dfdee0e0385c5c121ee2db90ea5acc7b694cc909..fcde5c01080fd363afa3b2617ad45713315aeeb1 100644 (file)
@@ -36,7 +36,7 @@
 pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] {
     match v.iter().position(|c| *c == 0) {
         // don't include the 0
-        Some(i) => v[..i],
+        Some(i) => v.index(&(0..i)),
         None => v
     }
 }
index 9996909f2f5bbc18a9781018bd4dd4aaaf952fd1..016757ef63e7d9410c6a16e01448e5fdd62e5302 100644 (file)
@@ -453,7 +453,7 @@ pub fn write(&mut self, buf: &[u8]) -> IoResult<()> {
             }
             let ret = unsafe {
                 libc::WriteFile(self.handle(),
-                                buf[offset..].as_ptr() as libc::LPVOID,
+                                buf.index(&(offset..)).as_ptr() as libc::LPVOID,
                                 (buf.len() - offset) as libc::DWORD,
                                 &mut bytes_written,
                                 &mut overlapped)
index 7b667416b171418f0dedaaedaf6694a8de70da59..8e1f169b5cdcc05864d79a05fb26e6198fda9a41 100644 (file)
@@ -25,6 +25,8 @@
 use ptr;
 use str;
 use sys::fs::FileDesc;
+use sync::{StaticMutex, MUTEX_INIT};
+
 use sys::fs;
 use sys::{self, retry, c, wouldblock, set_nonblocking, ms_to_timeval, timer};
 use sys_common::helper_thread::Helper;
 
 pub use sys_common::ProcessConfig;
 
+// `CreateProcess` is racy!
+// http://support.microsoft.com/kb/315939
+static CREATE_PROCESS_LOCK: StaticMutex = MUTEX_INIT;
+
 /// A value representing a child process.
 ///
 /// The lifetime of this value is linked to the lifetime of the actual
@@ -224,6 +230,7 @@ pub fn spawn<K, V, C, P>(cfg: &C, in_fd: Option<P>,
                 with_dirp(cfg.cwd(), |dirp| {
                     let mut cmd_str: Vec<u16> = cmd_str.utf16_units().collect();
                     cmd_str.push(0);
+                    let _lock = CREATE_PROCESS_LOCK.lock().unwrap();
                     let created = CreateProcessW(ptr::null(),
                                                  cmd_str.as_mut_ptr(),
                                                  ptr::null_mut(),
index 4498f56c00a1e4adcefdc3e1b21885e1bc4587dd..30707488b30ee9e7535535ab930705a260f85cbd 100644 (file)
@@ -62,7 +62,7 @@ pub unsafe fn create(stack: uint, p: Thunk) -> rust_thread {
     if ret as uint == 0 {
         // be sure to not leak the closure
         let _p: Box<Thunk> = mem::transmute(arg);
-        panic!("failed to spawn native thread: {}", ret);
+        panic!("failed to spawn native thread: {:?}", ret);
     }
     return ret;
 }
index 4305f7743b56411e8224572f97a8e7bec6c7516c..f9e1f0d3ed0aa42d9e934c8d94842318d54dadab 100644 (file)
 use libc::types::os::arch::extra::LPCVOID;
 use libc::{c_int, HANDLE, LPDWORD, DWORD, LPVOID};
 use libc::{get_osfhandle, CloseHandle};
+use mem;
 use ptr;
 use str::from_utf8;
 use super::c::{ENABLE_ECHO_INPUT, ENABLE_EXTENDED_FLAGS};
 use super::c::{ENABLE_INSERT_MODE, ENABLE_LINE_INPUT};
 use super::c::{ENABLE_PROCESSED_INPUT, ENABLE_QUICK_EDIT_MODE};
-use super::c::{ERROR_ILLEGAL_CHARACTER};
+use super::c::{ERROR_ILLEGAL_CHARACTER, CONSOLE_SCREEN_BUFFER_INFO};
 use super::c::{ReadConsoleW, WriteConsoleW, GetConsoleMode, SetConsoleMode};
+use super::c::{GetConsoleScreenBufferInfo};
 
 fn invalid_encoding() -> IoError {
     IoError {
@@ -146,12 +148,12 @@ pub fn set_raw(&mut self, raw: bool) -> IoResult<()> {
     }
 
     pub fn get_winsize(&mut self) -> IoResult<(int, int)> {
-        // FIXME
-        // Get console buffer via CreateFile with CONOUT$
-        // Make a CONSOLE_SCREEN_BUFFER_INFO
-        // Call GetConsoleScreenBufferInfo
-        // Maybe call GetLargestConsoleWindowSize instead?
-        Err(super::unimpl())
+        let mut info: CONSOLE_SCREEN_BUFFER_INFO = unsafe { mem::zeroed() };
+        match unsafe { GetConsoleScreenBufferInfo(self.handle, &mut info as *mut _) } {
+            0 => Err(super::last_error()),
+            _ => Ok(((info.srWindow.Right + 1 - info.srWindow.Left) as int,
+                     (info.srWindow.Bottom + 1 - info.srWindow.Top) as int)),
+        }
     }
 
     // Let us magically declare this as a TTY
index d7f30207273d57d5afa670eef4f3a1660a5d5df6..c103365745cd612207f2112322a3c21f9c70b0f7 100644 (file)
@@ -16,7 +16,7 @@
 //! each with their own stack and local state.
 //!
 //! Communication between threads can be done through
-//! [channels](../../std/comm/index.html), Rust's message-passing
+//! [channels](../../std/sync/mpsc/index.html), Rust's message-passing
 //! types, along with [other forms of thread
 //! synchronization](../../std/sync/index.html) and shared-memory data
 //! structures. In particular, types that are guaranteed to be
 //! ```rust
 //! use std::thread::Thread;
 //!
-//! let guard = Thread::spawn(move || {
+//! let thread = Thread::spawn(move || {
 //!     println!("Hello, World!");
 //!     // some computation here
 //! });
-//! let result = guard.join();
 //! ```
 //!
-//! The `spawn` function doesn't return a `Thread` directly; instead, it returns
-//! a *join guard* from which a `Thread` can be extracted. The join guard is an
-//! RAII-style guard that will automatically join the child thread (block until
-//! it terminates) when it is dropped. You can join the child thread in advance
-//! by calling the `join` method on the guard, which will also return the result
-//! produced by the thread.
+//! The spawned thread is "detached" from the current thread, meaning that it
+//! can outlive the thread that spawned it. (Note, however, that when the main
+//! thread terminates all detached threads are terminated as well.) The returned
+//! `Thread` handle can be used for low-level synchronization as described below.
+//!
+//! ## Scoped threads
 //!
-//! If you instead wish to *detach* the child thread, allowing it to outlive its
-//! parent, you can use the `detach` method on the guard,
+//! Often a parent thread uses a child thread to perform some particular task,
+//! and at some point must wait for the child to complete before continuing.
+//! For this scenario, use the `scoped` constructor:
 //!
-//! A handle to the thread itself is available via the `thread` method on the
-//! join guard.
+//! ```rust
+//! use std::thread::Thread;
+//!
+//! let guard = Thread::scoped(move || {
+//!     println!("Hello, World!");
+//!     // some computation here
+//! });
+//! // do some other work in the meantime
+//! let result = guard.join();
+//! ```
+//!
+//! The `scoped` function doesn't return a `Thread` directly; instead, it
+//! returns a *join guard* from which a `Thread` can be extracted. The join
+//! guard is an RAII-style guard that will automatically join the child thread
+//! (block until it terminates) when it is dropped. You can join the child
+//! thread in advance by calling the `join` method on the guard, which will also
+//! return the result produced by the thread.  A handle to the thread itself is
+//! available via the `thread` method on the join guard.
+//!
+//! (Note: eventually, the `scoped` constructor will allow the parent and child
+//! threads to data that lives on the parent thread's stack, but some language
+//! changes are needed before this is possible.)
 //!
 //! ## Configuring threads
 //!
 //!
 //! thread::Builder::new().name("child1".to_string()).spawn(move || {
 //!     println!("Hello, world!")
-//! }).detach();
+//! });
 //! ```
 //!
 //! ## Blocking support: park and unpark
 //!
 //! * It can be implemented highly efficiently on many platforms.
 
+#![stable]
+
 use any::Any;
 use boxed::Box;
 use cell::UnsafeCell;
 use clone::Clone;
-use kinds::{Send, Sync};
+use marker::{Send, Sync};
 use ops::{Drop, FnOnce};
 use option::Option::{self, Some, None};
 use result::Result::{Err, Ok};
 
 /// Thread configuration. Provides detailed control over the properties
 /// and behavior of new threads.
+#[stable]
 pub struct Builder {
     // A name for the thread-to-be, for identification in panic messages
     name: Option<String>,
@@ -158,6 +181,7 @@ pub struct Builder {
 impl Builder {
     /// Generate the base configuration for spawning a thread, from which
     /// configuration methods can be chained.
+    #[stable]
     pub fn new() -> Builder {
         Builder {
             name: None,
@@ -169,12 +193,14 @@ pub fn new() -> Builder {
 
     /// Name the thread-to-be. Currently the name is used for identification
     /// only in panic messages.
+    #[stable]
     pub fn name(mut self, name: String) -> Builder {
         self.name = Some(name);
         self
     }
 
     /// Set the size of the stack for the new thread.
+    #[stable]
     pub fn stack_size(mut self, size: uint) -> Builder {
         self.stack_size = Some(size);
         self
@@ -194,19 +220,41 @@ pub fn stderr(mut self, stderr: Box<Writer + Send>) -> Builder {
         self
     }
 
-    /// Spawn a new joinable thread, and return a JoinGuard guard for it.
+    /// Spawn a new detached thread, and return a handle to it.
     ///
     /// See `Thead::spawn` and the module doc for more details.
-    pub fn spawn<T, F>(self, f: F) -> JoinGuard<T> where
-        T: Send, F: FnOnce() -> T, F: Send
-    {
-        self.spawn_inner(Thunk::new(f))
+    #[unstable = "may change with specifics of new Send semantics"]
+    pub fn spawn<F>(self, f: F) -> Thread where F: FnOnce(), F: Send + 'static {
+        let (native, thread) = self.spawn_inner(Thunk::new(f), Thunk::with_arg(|_| {}));
+        unsafe { imp::detach(native) };
+        thread
     }
 
-    fn spawn_inner<T: Send>(self, f: Thunk<(), T>) -> JoinGuard<T> {
+    /// Spawn a new child thread that must be joined within a given
+    /// scope, and return a `JoinGuard`.
+    ///
+    /// See `Thead::scoped` and the module doc for more details.
+    #[unstable = "may change with specifics of new Send semantics"]
+    pub fn scoped<'a, T, F>(self, f: F) -> JoinGuard<'a, T> where
+        T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
+    {
         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 {
+            *their_packet.0.get() = Some(ret);
+        }));
 
+        JoinGuard {
+            native: native,
+            joined: false,
+            packet: my_packet,
+            thread: thread,
+        }
+    }
+
+    fn spawn_inner<T: Send>(self, f: Thunk<(), T>, finish: Thunk<Result<T>, ()>)
+                      -> (imp::rust_thread, Thread)
+    {
         let Builder { name, stack_size, stdout, stderr } = self;
 
         let stack_size = stack_size.unwrap_or(rt::min_stack());
@@ -258,21 +306,14 @@ fn spawn_inner<T: Send>(self, f: Thunk<(), T>) -> JoinGuard<T> {
                     unwind::try(move || *ptr = Some(f.invoke(())))
                 }
             };
-            unsafe {
-                *their_packet.0.get() = Some(match (output, try_result) {
-                    (Some(data), Ok(_)) => Ok(data),
-                    (None, Err(cause)) => Err(cause),
-                    _ => unreachable!()
-                });
-            }
+            finish.invoke(match (output, try_result) {
+                (Some(data), Ok(_)) => Ok(data),
+                (None, Err(cause)) => Err(cause),
+                _ => unreachable!()
+            });
         };
 
-        JoinGuard {
-            native: unsafe { imp::create(stack_size, Thunk::new(main)) },
-            joined: false,
-            packet: my_packet,
-            thread: my_thread,
-        }
+        (unsafe { imp::create(stack_size, Thunk::new(main)) }, my_thread)
     }
 }
 
@@ -285,13 +326,12 @@ struct Inner {
 unsafe impl Sync for Inner {}
 
 #[derive(Clone)]
+#[stable]
 /// A handle to a thread.
 pub struct Thread {
     inner: Arc<Inner>,
 }
 
-unsafe impl Sync for Thread {}
-
 impl Thread {
     // Used only internally to construct a thread object without spawning
     fn new(name: Option<String>) -> Thread {
@@ -304,30 +344,47 @@ fn new(name: Option<String>) -> Thread {
         }
     }
 
-    /// Spawn a new joinable thread, returning a `JoinGuard` for it.
+    /// Spawn a new detached thread, returning a handle to it.
+    ///
+    /// The child thread may outlive the parent (unless the parent thread is the
+    /// main thread; the whole process is terminated when the main thread
+    /// finishes.) The thread handle can be used for low-level
+    /// synchronization. See the module documentation for additional details.
+    #[unstable = "may change with specifics of new Send semantics"]
+    pub fn spawn<F>(f: F) -> Thread where F: FnOnce(), F: Send + 'static {
+        Builder::new().spawn(f)
+    }
+
+    /// Spawn a new *scoped* thread, returning a `JoinGuard` for it.
     ///
     /// The join guard can be used to explicitly join the child thread (via
     /// `join`), returning `Result<T>`, or it will implicitly join the child
-    /// upon being dropped. To detach the child, allowing it to outlive the
-    /// current thread, use `detach`.  See the module documentation for additional details.
-    pub fn spawn<T, F>(f: F) -> JoinGuard<T> where
-        T: Send, F: FnOnce() -> T, F: Send
+    /// upon being dropped. Because the child thread may refer to data on the
+    /// current thread's stack (hence the "scoped" name), it cannot be detached;
+    /// it *must* be joined before the relevant stack frame is popped. See the
+    /// module documentation for additional details.
+    #[unstable = "may change with specifics of new Send semantics"]
+    pub fn scoped<'a, T, F>(f: F) -> JoinGuard<'a, T> where
+        T: Send + 'a, F: FnOnce() -> T, F: Send + 'a
     {
-        Builder::new().spawn(f)
+        Builder::new().scoped(f)
     }
 
     /// Gets a handle to the thread that invokes it.
+    #[stable]
     pub fn current() -> Thread {
         thread_info::current_thread()
     }
 
     /// Cooperatively give up a timeslice to the OS scheduler.
+    #[unstable = "name may change"]
     pub fn yield_now() {
         unsafe { imp::yield_now() }
     }
 
     /// Determines whether the current thread is panicking.
     #[inline]
+    #[stable]
     pub fn panicking() -> bool {
         unwind::panicking()
     }
@@ -341,6 +398,7 @@ pub fn panicking() -> bool {
     // future, this will be implemented in a more efficient way, perhaps along the lines of
     //   http://cr.openjdk.java.net/~stefank/6989984.1/raw_files/new/src/os/linux/vm/os_linux.cpp
     // or futuxes, and in either case may allow spurious wakeups.
+    #[unstable = "recently introduced"]
     pub fn park() {
         let thread = Thread::current();
         let mut guard = thread.inner.lock.lock().unwrap();
@@ -353,6 +411,7 @@ pub fn park() {
     /// Atomically makes the handle's token available if it is not already.
     ///
     /// See the module doc for more detail.
+    #[unstable = "recently introduced"]
     pub fn unpark(&self) {
         let mut guard = self.inner.lock.lock().unwrap();
         if !*guard {
@@ -362,6 +421,7 @@ pub fn unpark(&self) {
     }
 
     /// Get the thread's name.
+    #[stable]
     pub fn name(&self) -> Option<&str> {
         self.inner.name.as_ref().map(|s| s.as_slice())
     }
@@ -375,6 +435,7 @@ fn new(name: Option<String>) -> Thread { Thread::new(name) }
 /// Indicates the manner in which a thread exited.
 ///
 /// A thread that completes without panicking is considered to exit successfully.
+#[stable]
 pub type Result<T> = ::result::Result<T, Box<Any + Send>>;
 
 struct Packet<T>(Arc<UnsafeCell<Option<Result<T>>>>);
@@ -382,21 +443,24 @@ fn new(name: Option<String>) -> Thread { Thread::new(name) }
 unsafe impl<T:'static+Send> Send for Packet<T> {}
 unsafe impl<T> Sync for Packet<T> {}
 
-#[must_use]
 /// An RAII-style guard that will block until thread termination when dropped.
 ///
 /// The type `T` is the return type for the thread's main function.
-pub struct JoinGuard<T> {
+#[must_use]
+#[unstable = "may change with specifics of new Send semantics"]
+pub struct JoinGuard<'a, T: 'a> {
     native: imp::rust_thread,
     thread: Thread,
     joined: bool,
     packet: Packet<T>,
 }
 
-unsafe impl<T: Send> Sync for JoinGuard<T> {}
+#[stable]
+unsafe impl<'a, T: Send + 'a> Sync for JoinGuard<'a, T> {}
 
-impl<T: Send> JoinGuard<T> {
+impl<'a, T: Send + 'a> JoinGuard<'a, T> {
     /// Extract a handle to the thread this guard will join on.
+    #[stable]
     pub fn thread(&self) -> &Thread {
         &self.thread
     }
@@ -406,6 +470,7 @@ pub fn thread(&self) -> &Thread {
     ///
     /// If the child thread panics, `Err` is returned with the parameter given
     /// to `panic`.
+    #[stable]
     pub fn join(mut self) -> Result<T> {
         assert!(!self.joined);
         unsafe { imp::join(self.native) };
@@ -414,8 +479,11 @@ pub fn join(mut self) -> Result<T> {
             (*self.packet.0.get()).take().unwrap()
         }
     }
+}
 
+impl<T: Send> JoinGuard<'static, T> {
     /// Detaches the child thread, allowing it to outlive its parent.
+    #[experimental = "unsure whether this API imposes limitations elsewhere"]
     pub fn detach(mut self) {
         unsafe { imp::detach(self.native) };
         self.joined = true; // avoid joining in the destructor
@@ -424,7 +492,7 @@ pub fn detach(mut self) {
 
 #[unsafe_destructor]
 #[stable]
-impl<T: Send> Drop for JoinGuard<T> {
+impl<'a, T: Send + 'a> Drop for JoinGuard<'a, T> {
     fn drop(&mut self) {
         if !self.joined {
             unsafe { imp::join(self.native) };
@@ -449,14 +517,14 @@ mod test {
 
     #[test]
     fn test_unnamed_thread() {
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             assert!(Thread::current().name().is_none());
         }).join().map_err(|_| ()).unwrap();
     }
 
     #[test]
     fn test_named_thread() {
-        Builder::new().name("ada lovelace".to_string()).spawn(move|| {
+        Builder::new().name("ada lovelace".to_string()).scoped(move|| {
             assert!(Thread::current().name().unwrap() == "ada lovelace".to_string());
         }).join().map_err(|_| ()).unwrap();
     }
@@ -466,13 +534,13 @@ fn test_run_basic() {
         let (tx, rx) = channel();
         Thread::spawn(move|| {
             tx.send(()).unwrap();
-        }).detach();
+        });
         rx.recv().unwrap();
     }
 
     #[test]
     fn test_join_success() {
-        match Thread::spawn(move|| -> String {
+        match Thread::scoped(move|| -> String {
             "Success!".to_string()
         }).join().as_ref().map(|s| s.as_slice()) {
             result::Result::Ok("Success!") => (),
@@ -482,7 +550,7 @@ fn test_join_success() {
 
     #[test]
     fn test_join_panic() {
-        match Thread::spawn(move|| {
+        match Thread::scoped(move|| {
             panic!()
         }).join() {
             result::Result::Err(_) => (),
@@ -504,7 +572,7 @@ fn f(i: int, tx: Sender<()>) {
                 } else {
                     f(i - 1, tx);
                 }
-            }).detach();
+            });
 
         }
         f(10, tx);
@@ -518,8 +586,8 @@ fn test_spawn_sched_childs_on_default_sched() {
         Thread::spawn(move|| {
             Thread::spawn(move|| {
                 tx.send(()).unwrap();
-            }).detach();
-        }).detach();
+            });
+        });
 
         rx.recv().unwrap();
     }
@@ -542,7 +610,7 @@ fn avoid_copying_the_body<F>(spawnfn: F) where F: FnOnce(Thunk) {
     #[test]
     fn test_avoid_copying_the_body_spawn() {
         avoid_copying_the_body(|v| {
-            Thread::spawn(move || v.invoke(())).detach();
+            Thread::spawn(move || v.invoke(()));
         });
     }
 
@@ -551,14 +619,14 @@ fn test_avoid_copying_the_body_thread_spawn() {
         avoid_copying_the_body(|f| {
             Thread::spawn(move|| {
                 f.invoke(());
-            }).detach();
+            });
         })
     }
 
     #[test]
     fn test_avoid_copying_the_body_join() {
         avoid_copying_the_body(|f| {
-            let _ = Thread::spawn(move|| {
+            let _ = Thread::scoped(move|| {
                 f.invoke(())
             }).join();
         })
@@ -574,21 +642,21 @@ fn test_child_doesnt_ref_parent() {
         fn child_no(x: uint) -> Thunk {
             return Thunk::new(move|| {
                 if x < GENERATIONS {
-                    Thread::spawn(move|| child_no(x+1).invoke(())).detach();
+                    Thread::spawn(move|| child_no(x+1).invoke(()));
                 }
             });
         }
-        Thread::spawn(|| child_no(0).invoke(())).detach();
+        Thread::spawn(|| child_no(0).invoke(()));
     }
 
     #[test]
     fn test_simple_newsched_spawn() {
-        Thread::spawn(move || {}).detach();
+        Thread::spawn(move || {});
     }
 
     #[test]
     fn test_try_panic_message_static_str() {
-        match Thread::spawn(move|| {
+        match Thread::scoped(move|| {
             panic!("static string");
         }).join() {
             Err(e) => {
@@ -602,7 +670,7 @@ fn test_try_panic_message_static_str() {
 
     #[test]
     fn test_try_panic_message_owned_str() {
-        match Thread::spawn(move|| {
+        match Thread::scoped(move|| {
             panic!("owned string".to_string());
         }).join() {
             Err(e) => {
@@ -616,7 +684,7 @@ fn test_try_panic_message_owned_str() {
 
     #[test]
     fn test_try_panic_message_any() {
-        match Thread::spawn(move|| {
+        match Thread::scoped(move|| {
             panic!(box 413u16 as Box<Any + Send>);
         }).join() {
             Err(e) => {
@@ -634,7 +702,7 @@ fn test_try_panic_message_any() {
     fn test_try_panic_message_unit_struct() {
         struct Juju;
 
-        match Thread::spawn(move|| {
+        match Thread::scoped(move|| {
             panic!(Juju)
         }).join() {
             Err(ref e) if e.is::<Juju>() => {}
@@ -648,7 +716,7 @@ fn test_stdout() {
         let mut reader = ChanReader::new(rx);
         let stdout = ChanWriter::new(tx);
 
-        let r = Builder::new().stdout(box stdout as Box<Writer + Send>).spawn(move|| {
+        let r = Builder::new().stdout(box stdout as Box<Writer + Send>).scoped(move|| {
             print!("Hello, world!");
         }).join();
         assert!(r.is_ok());
index e0cbaa8ca50edbbb99c63a147445d1951f8551a7..e7c4e4ccdfb88d0abd6e19daec1a0eff9d7dea9c 100644 (file)
@@ -40,8 +40,7 @@
 
 use cell::UnsafeCell;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod scoped;
 
 // Sure wish we had macro hygiene, no?
@@ -87,7 +86,7 @@ pub mod __impl {
 ///         assert_eq!(*f.borrow(), 1);
 ///         *f.borrow_mut() = 3;
 ///     });
-/// }).detach();
+/// });
 ///
 /// // we retain our original value of 2 despite the child thread
 /// FOO.with(|f| {
@@ -346,7 +345,7 @@ pub struct Key<T> {
         pub dtor_running: UnsafeCell<bool>, // should be Cell
     }
 
-    unsafe impl<T> ::kinds::Sync for Key<T> { }
+    unsafe impl<T> ::marker::Sync for Key<T> { }
 
     #[doc(hidden)]
     impl<T> Key<T> {
@@ -472,7 +471,7 @@ pub struct Key<T> {
         pub os: OsStaticKey,
     }
 
-    unsafe impl<T> ::kinds::Sync for Key<T> { }
+    unsafe impl<T> ::marker::Sync for Key<T> { }
 
     struct Value<T: 'static> {
         key: &'static Key<T>,
@@ -581,7 +580,7 @@ fn foo() -> Foo {
         }
         thread_local!(static FOO: Foo = foo());
 
-        Thread::spawn(|| {
+        Thread::scoped(|| {
             assert!(FOO.state() == State::Uninitialized);
             FOO.with(|_| {
                 assert!(FOO.state() == State::Valid);
@@ -645,7 +644,7 @@ fn drop(&mut self) {
             }
         }
 
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             drop(S1);
         }).join().ok().unwrap();
     }
@@ -663,7 +662,7 @@ fn drop(&mut self) {
             }
         }
 
-        Thread::spawn(move|| unsafe {
+        Thread::scoped(move|| unsafe {
             K1.with(|s| *s.get() = Some(S1));
         }).join().ok().unwrap();
     }
index 714b71d5dbd4e75364c4ee165a32dc8b8eafc10b..1fb5652bc0ca4c082e0b754a37d8046a10523a0e 100644 (file)
@@ -108,7 +108,7 @@ macro_rules! __scoped_thread_local_inner {
         const _INIT: __Key<$t> = __Key {
             inner: ::std::thread_local::scoped::__impl::KeyInner {
                 inner: ::std::thread_local::scoped::__impl::OS_INIT,
-                marker: ::std::kinds::marker::InvariantType,
+                marker: ::std::marker::InvariantType,
             }
         };
 
@@ -211,7 +211,7 @@ mod imp {
     #[doc(hidden)]
     pub struct KeyInner<T> { pub inner: UnsafeCell<*mut T> }
 
-    unsafe impl<T> ::kinds::Sync for KeyInner<T> { }
+    unsafe impl<T> ::marker::Sync for KeyInner<T> { }
 
     #[doc(hidden)]
     impl<T> KeyInner<T> {
@@ -224,7 +224,7 @@ pub unsafe fn get(&self) -> *mut T { *self.inner.get() }
 
 #[cfg(any(windows, target_os = "android", target_os = "ios", target_arch = "aarch64"))]
 mod imp {
-    use kinds::marker;
+    use marker;
     use sys_common::thread_local::StaticKey as OsStaticKey;
 
     #[doc(hidden)]
@@ -233,7 +233,7 @@ pub struct KeyInner<T> {
         pub marker: marker::InvariantType<T>,
     }
 
-    unsafe impl<T> ::kinds::Sync for KeyInner<T> { }
+    unsafe impl<T> ::marker::Sync for KeyInner<T> { }
 
     #[doc(hidden)]
     impl<T> KeyInner<T> {
index 067926042f121ba38c6c77e30ba3d449a9638323..1830a4df54aab8c9b12baadc4e770ee37439aaf1 100644 (file)
@@ -12,7 +12,7 @@
 #![allow(missing_docs)]
 
 use alloc::boxed::Box;
-use core::kinds::Send;
+use core::marker::Send;
 use core::ops::FnOnce;
 
 pub struct Thunk<A=(),R=()> {
index ac1f0c5d803ac6a5b5b1e37a0a5fa7c51644c198..a651d927c1431fd601caedb5d73f566104accbfc 100644 (file)
@@ -19,9 +19,6 @@
 use num::Int;
 use result::Result::Ok;
 
-// NOTE: for old macros; remove after the next snapshot
-#[cfg(stage0)] use result::Result::Err;
-
 /// The number of nanoseconds in a microsecond.
 const NANOS_PER_MICRO: i32 = 1000;
 /// The number of nanoseconds in a millisecond.
@@ -48,7 +45,7 @@ macro_rules! try_opt {
 
 /// ISO 8601 time duration with nanosecond precision.
 /// This also allows for the negative duration; see individual methods for details.
-#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
+#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Show)]
 pub struct Duration {
     secs: i64,
     nanos: i32, // Always 0 <= nanos < NANOS_PER_SEC
@@ -337,7 +334,7 @@ fn div(self, rhs: i32) -> Duration {
     }
 }
 
-impl fmt::Show for Duration {
+impl fmt::String for Duration {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         // technically speaking, negative duration is not valid ISO 8601,
         // but we need to print it anyway.
index c366ced58b2a8c5d067bf51461b58ff1ab2545f3..09235ee209c46e4eb67efa49cfe33f0c62e2af51 100644 (file)
@@ -47,7 +47,7 @@ pub enum Abi {
 }
 
 #[allow(non_camel_case_types)]
-#[derive(Copy, PartialEq)]
+#[derive(Copy, PartialEq, Show)]
 pub enum Architecture {
     X86,
     X86_64,
@@ -120,12 +120,24 @@ pub fn name(&self) -> &'static str {
 }
 
 impl fmt::Show for Abi {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for Abi {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "\"{}\"", self.name())
     }
 }
 
 impl fmt::Show for Os {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for Os {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         match *self {
             OsLinux => "linux".fmt(f),
index 7aa7c4fcfb3019be51d900134fb6adab37a0c81a..6766127a5f1e45c9f851d58ca7a502485fe70557 100644 (file)
@@ -100,16 +100,29 @@ pub fn encode_with_hygiene(&self) -> String {
     }
 }
 
-impl Show for Ident {
+//NOTE(stage0): remove after snapshot
+impl fmt::Show for Ident {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}#{}", self.name, self.ctxt)
     }
 }
 
-impl Show for Name {
+impl fmt::String for Ident {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(&self.name, f)
+    }
+}
+
+impl fmt::Show for Name {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let Name(nm) = *self;
-        write!(f, "\"{}\"({})", token::get_name(*self).get(), nm)
+        write!(f, "{:?}({})", token::get_name(*self).get(), nm)
+    }
+}
+
+impl fmt::String for Name {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(token::get_name(*self).get(), f)
     }
 }
 
@@ -182,31 +195,15 @@ pub fn ident(&self) -> Ident {
 /// A mark represents a unique id associated with a macro expansion
 pub type Mrk = u32;
 
-#[cfg(stage0)]
-impl<S: Encoder<E>, E> Encodable<S, E> for Ident {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_str(token::get_ident(*self).get())
-    }
-}
-
-#[cfg(not(stage0))]
 impl Encodable for Ident {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
         s.emit_str(token::get_ident(*self).get())
     }
 }
 
-#[cfg(stage0)]
-impl<D: Decoder<E>, E> Decodable<D, E> for Ident {
-    fn decode(d: &mut D) -> Result<Ident, E> {
-        Ok(str_to_ident(try!(d.read_str())[]))
-    }
-}
-
-#[cfg(not(stage0))]
 impl Decodable for Ident {
     fn decode<D: Decoder>(d: &mut D) -> Result<Ident, D::Error> {
-        Ok(str_to_ident(try!(d.read_str())[]))
+        Ok(str_to_ident(try!(d.read_str()).index(&FullRange)))
     }
 }
 
@@ -883,7 +880,6 @@ impl TokenTree {
     pub fn len(&self) -> uint {
         match *self {
             TtToken(_, token::DocComment(_)) => 2,
-            TtToken(_, token::SubstNt(..)) => 2,
             TtToken(_, token::SpecialVarNt(..)) => 2,
             TtToken(_, token::MatchNt(..)) => 3,
             TtDelimited(_, ref delimed) => {
@@ -921,11 +917,6 @@ pub fn get_tt(&self, index: uint) -> TokenTree {
                 }
                 delimed.tts[index - 1].clone()
             }
-            (&TtToken(sp, token::SubstNt(name, name_st)), _) => {
-                let v = [TtToken(sp, token::Dollar),
-                         TtToken(sp, token::Ident(name, name_st))];
-                v[index]
-            }
             (&TtToken(sp, token::SpecialVarNt(var)), _) => {
                 let v = [TtToken(sp, token::Dollar),
                          TtToken(sp, token::Ident(token::str_to_ident(var.as_str()),
@@ -982,8 +973,8 @@ pub enum Sign {
     Plus
 }
 
-impl<T> Sign where T: Int {
-    pub fn new(n: T) -> Sign {
+impl Sign {
+    pub fn new<T:Int>(n: T) -> Sign {
         if n < Int::zero() {
             Minus
         } else {
@@ -1087,14 +1078,21 @@ pub struct Typedef {
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
 pub enum IntTy {
-    TyI,
+    TyIs,
     TyI8,
     TyI16,
     TyI32,
     TyI64,
 }
 
+//NOTE(stage0): remove after snapshot
 impl fmt::Show for IntTy {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for IntTy {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}", ast_util::int_ty_to_string(*self, None))
     }
@@ -1103,7 +1101,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
 impl IntTy {
     pub fn suffix_len(&self) -> uint {
         match *self {
-            TyI => 1,
+            TyIs => 1,
             TyI8 => 2,
             TyI16 | TyI32 | TyI64  => 3,
         }
@@ -1112,7 +1110,7 @@ pub fn suffix_len(&self) -> uint {
 
 #[derive(Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Copy)]
 pub enum UintTy {
-    TyU,
+    TyUs,
     TyU8,
     TyU16,
     TyU32,
@@ -1122,14 +1120,21 @@ pub enum UintTy {
 impl UintTy {
     pub fn suffix_len(&self) -> uint {
         match *self {
-            TyU => 1,
+            TyUs => 1,
             TyU8 => 2,
             TyU16 | TyU32 | TyU64  => 3,
         }
     }
 }
 
+//NOTE(stage0): remove after snapshot
 impl fmt::Show for UintTy {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for UintTy {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}", ast_util::uint_ty_to_string(*self, None))
     }
@@ -1141,7 +1146,14 @@ pub enum FloatTy {
     TyF64,
 }
 
+//NOTE(stage0): remove after snapshot
 impl fmt::Show for FloatTy {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for FloatTy {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}", ast_util::float_ty_to_string(*self))
     }
@@ -1192,10 +1204,19 @@ pub enum Onceness {
 
 impl fmt::Show for Onceness {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match *self {
-            Once => "once".fmt(f),
-            Many => "many".fmt(f),
-        }
+        fmt::String::fmt(match *self {
+            Once => "once",
+            Many => "many",
+        }, f)
+    }
+}
+
+impl fmt::String for Onceness {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(match *self {
+            Once => "once",
+            Many => "many",
+        }, f)
     }
 }
 
@@ -1305,18 +1326,18 @@ pub struct FnDecl {
     pub variadic: bool
 }
 
-#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash)]
+#[derive(Copy, Clone, PartialEq, Eq, RustcEncodable, RustcDecodable, Hash, Show)]
 pub enum Unsafety {
     Unsafe,
     Normal,
 }
 
-impl fmt::Show for Unsafety {
+impl fmt::String for Unsafety {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        match *self {
-            Unsafety::Normal => "normal".fmt(f),
-            Unsafety::Unsafe => "unsafe".fmt(f),
-        }
+        fmt::String::fmt(match *self {
+            Unsafety::Normal => "normal",
+            Unsafety::Unsafe => "unsafe",
+        }, f)
     }
 }
 
index cf09e2777f7c69a0410d7e33275e42e1c37e5d11..7496a0f9f26db1a5097eaa99aeb9db15bf48d744 100644 (file)
@@ -46,7 +46,14 @@ pub fn name(&self) -> Name {
     }
 }
 
+//NOTE(stage0): replace with deriving(Show) after snapshot
 impl fmt::Show for PathElem {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for PathElem {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         let slot = token::get_name(self.name());
         write!(f, "{}", slot)
@@ -99,7 +106,7 @@ pub fn path_to_string<PI: Iterator<Item=PathElem>>(path: PI) -> String {
         if !s.is_empty() {
             s.push_str("::");
         }
-        s.push_str(e[]);
+        s.push_str(e.index(&FullRange));
         s
     }).to_string()
 }
@@ -396,7 +403,7 @@ pub fn get_path_elem(&self, id: NodeId) -> PathElem {
                                 PathName(ident.name)
                             }
                             MethMac(_) => {
-                                panic!("no path elem for {}", node)
+                                panic!("no path elem for {:?}", node)
                             }
                         }
                     }
@@ -410,7 +417,7 @@ pub fn get_path_elem(&self, id: NodeId) -> PathElem {
                         MethDecl(ident, _, _, _, _, _, _, _) => {
                             PathName(ident.name)
                         }
-                        MethMac(_) => panic!("no path elem for {}", node),
+                        MethMac(_) => panic!("no path elem for {:?}", node),
                     }
                 }
                 TypeTraitItem(ref m) => {
@@ -418,7 +425,7 @@ pub fn get_path_elem(&self, id: NodeId) -> PathElem {
                 }
             },
             NodeVariant(v) => PathName(v.node.name.name),
-            _ => panic!("no path elem for {}", node)
+            _ => panic!("no path elem for {:?}", node)
         }
     }
 
@@ -476,20 +483,20 @@ pub fn with_attrs<T, F>(&self, id: NodeId, f: F) -> T where
         F: FnOnce(Option<&[Attribute]>) -> T,
     {
         let attrs = match self.get(id) {
-            NodeItem(i) => Some(i.attrs[]),
-            NodeForeignItem(fi) => Some(fi.attrs[]),
+            NodeItem(i) => Some(i.attrs.index(&FullRange)),
+            NodeForeignItem(fi) => Some(fi.attrs.index(&FullRange)),
             NodeTraitItem(ref tm) => match **tm {
-                RequiredMethod(ref type_m) => Some(type_m.attrs[]),
-                ProvidedMethod(ref m) => Some(m.attrs[]),
-                TypeTraitItem(ref typ) => Some(typ.attrs[]),
+                RequiredMethod(ref type_m) => Some(type_m.attrs.index(&FullRange)),
+                ProvidedMethod(ref m) => Some(m.attrs.index(&FullRange)),
+                TypeTraitItem(ref typ) => Some(typ.attrs.index(&FullRange)),
             },
             NodeImplItem(ref ii) => {
                 match **ii {
-                    MethodImplItem(ref m) => Some(m.attrs[]),
-                    TypeImplItem(ref t) => Some(t.attrs[]),
+                    MethodImplItem(ref m) => Some(m.attrs.index(&FullRange)),
+                    TypeImplItem(ref t) => Some(t.attrs.index(&FullRange)),
                 }
             }
-            NodeVariant(ref v) => Some(v.node.attrs[]),
+            NodeVariant(ref v) => Some(v.node.attrs.index(&FullRange)),
             // unit/tuple structs take the attributes straight from
             // the struct definition.
             // FIXME(eddyb) make this work again (requires access to the map).
@@ -513,7 +520,7 @@ pub fn nodes_matching_suffix<'a>(&'a self, parts: &'a [String])
         NodesMatchingSuffix {
             map: self,
             item_name: parts.last().unwrap(),
-            in_which: parts[..parts.len() - 1],
+            in_which: parts.index(&(0..(parts.len() - 1))),
             idx: 0,
         }
     }
@@ -549,7 +556,7 @@ pub fn opt_span(&self, id: NodeId) -> Option<Span> {
 
     pub fn span(&self, id: NodeId) -> Span {
         self.opt_span(id)
-            .unwrap_or_else(|| panic!("AstMap.span: could not find span for id {}", id))
+            .unwrap_or_else(|| panic!("AstMap.span: could not find span for id {:?}", id))
     }
 
     pub fn def_id_span(&self, def_id: DefId, fallback: Span) -> Span {
@@ -590,7 +597,7 @@ fn suffix_matches(&self, parent: NodeId) -> bool {
                 None => return false,
                 Some((node_id, name)) => (node_id, name),
             };
-            if part[] != mod_name.as_str() {
+            if part.index(&FullRange) != mod_name.as_str() {
                 return false;
             }
             cursor = self.map.get_parent(mod_id);
@@ -628,7 +635,7 @@ fn item_is_mod(item: &Item) -> bool {
     // We are looking at some node `n` with a given name and parent
     // id; do their names match what I am seeking?
     fn matches_names(&self, parent_of_n: NodeId, name: Name) -> bool {
-        name.as_str() == self.item_name[] &&
+        name.as_str() == self.item_name.index(&FullRange) &&
             self.suffix_matches(parent_of_n)
     }
 }
@@ -729,7 +736,7 @@ struct NodeCollector<'ast> {
 
 impl<'ast> NodeCollector<'ast> {
     fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) {
-        debug!("ast_map: {} => {}", id, entry);
+        debug!("ast_map: {:?} => {:?}", id, entry);
         let len = self.map.len();
         if id as uint >= len {
             self.map.extend(repeat(NotPresent).take(id as uint - len + 1));
@@ -1040,7 +1047,7 @@ fn print_node(&mut self, node: &Node) -> IoResult<()> {
 
 fn node_id_to_string(map: &Map, id: NodeId, include_id: bool) -> String {
     let id_str = format!(" (id={})", id);
-    let id_str = if include_id { id_str[] } else { "" };
+    let id_str = if include_id { id_str.index(&FullRange) } else { "" };
 
     match map.find(id) {
         Some(NodeItem(item)) => {
index 5e03afec16cf8709e1e5a92a047e87d39ef9a6b5..871f1237aee5160e148738723c4fb9dcb072e4f1 100644 (file)
@@ -120,8 +120,8 @@ pub fn is_path(e: P<Expr>) -> bool {
 /// We want to avoid "45int" and "-3int" in favor of "45" and "-3"
 pub fn int_ty_to_string(t: IntTy, val: Option<i64>) -> String {
     let s = match t {
-        TyI if val.is_some() => "i",
-        TyI => "int",
+        TyIs if val.is_some() => "is",
+        TyIs => "isize",
         TyI8 => "i8",
         TyI16 => "i16",
         TyI32 => "i32",
@@ -141,7 +141,7 @@ pub fn int_ty_max(t: IntTy) -> u64 {
     match t {
         TyI8 => 0x80u64,
         TyI16 => 0x8000u64,
-        TyI | TyI32 => 0x80000000u64, // actually ni about TyI
+        TyIs | TyI32 => 0x80000000u64, // actually ni about TyIs
         TyI64 => 0x8000000000000000u64
     }
 }
@@ -150,8 +150,8 @@ pub fn int_ty_max(t: IntTy) -> u64 {
 /// We want to avoid "42uint" in favor of "42u"
 pub fn uint_ty_to_string(t: UintTy, val: Option<u64>) -> String {
     let s = match t {
-        TyU if val.is_some() => "u",
-        TyU => "uint",
+        TyUs if val.is_some() => "us",
+        TyUs => "usize",
         TyU8 => "u8",
         TyU16 => "u16",
         TyU32 => "u32",
@@ -168,7 +168,7 @@ pub fn uint_ty_max(t: UintTy) -> u64 {
     match t {
         TyU8 => 0xffu64,
         TyU16 => 0xffffu64,
-        TyU | TyU32 => 0xffffffffu64, // actually ni about TyU
+        TyUs | TyU32 => 0xffffffffu64, // actually ni about TyUs
         TyU64 => 0xffffffffffffffffu64
     }
 }
@@ -238,11 +238,11 @@ pub fn impl_pretty_name(trait_ref: &Option<TraitRef>, ty: &Ty) -> Ident {
     match *trait_ref {
         Some(ref trait_ref) => {
             pretty.push('.');
-            pretty.push_str(pprust::path_to_string(&trait_ref.path)[]);
+            pretty.push_str(pprust::path_to_string(&trait_ref.path).index(&FullRange));
         }
         None => {}
     }
-    token::gensym_ident(pretty[])
+    token::gensym_ident(pretty.index(&FullRange))
 }
 
 pub fn trait_method_to_ty_method(method: &Method) -> TypeMethod {
@@ -704,7 +704,7 @@ pub fn pat_is_ident(pat: P<ast::Pat>) -> bool {
 pub fn path_name_eq(a : &ast::Path, b : &ast::Path) -> bool {
     (a.span == b.span)
     && (a.global == b.global)
-    && (segments_name_eq(a.segments[], b.segments[]))
+    && (segments_name_eq(a.segments.index(&FullRange), b.segments.index(&FullRange)))
 }
 
 // are two arrays of segments equal when compared unhygienically?
@@ -792,13 +792,13 @@ fn ident_to_segment(id : &Ident) -> PathSegment {
     #[test] fn idents_name_eq_test() {
         assert!(segments_name_eq(
             [Ident{name:Name(3),ctxt:4}, Ident{name:Name(78),ctxt:82}]
-                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>()[],
+                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().index(&FullRange),
             [Ident{name:Name(3),ctxt:104}, Ident{name:Name(78),ctxt:182}]
-                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>()[]));
+                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().index(&FullRange)));
         assert!(!segments_name_eq(
             [Ident{name:Name(3),ctxt:4}, Ident{name:Name(78),ctxt:82}]
-                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>()[],
+                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().index(&FullRange),
             [Ident{name:Name(3),ctxt:104}, Ident{name:Name(77),ctxt:182}]
-                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>()[]));
+                .iter().map(ident_to_segment).collect::<Vec<PathSegment>>().index(&FullRange)));
     }
 }
index 43e23f26e930e8155d7cc8b634cbb3a18eefce57..416fc8c2278a0947cbd03d76f934e8b888048ffa 100644 (file)
@@ -28,6 +28,7 @@
 use std::cell::{RefCell, Cell};
 use std::collections::BitvSet;
 use std::collections::HashSet;
+use std::fmt;
 
 thread_local! { static USED_ATTRS: RefCell<BitvSet> = RefCell::new(BitvSet::new()) }
 
@@ -97,7 +98,7 @@ fn value_str(&self) -> Option<InternedString> {
 
     fn meta_item_list<'a>(&'a self) -> Option<&'a [P<MetaItem>]> {
         match self.node {
-            MetaList(_, ref l) => Some(l[]),
+            MetaList(_, ref l) => Some(l.index(&FullRange)),
             _ => None
         }
     }
@@ -136,7 +137,7 @@ fn with_desugared_doc<T, F>(&self, f: F) -> T where
             let meta = mk_name_value_item_str(
                 InternedString::new("doc"),
                 token::intern_and_get_ident(strip_doc_comment_decoration(
-                        comment.get())[]));
+                        comment.get()).index(&FullRange)));
             if self.node.style == ast::AttrOuter {
                 f(&mk_attr_outer(self.node.id, meta))
             } else {
@@ -296,9 +297,9 @@ pub fn find_inline_attr(attrs: &[Attribute]) -> InlineAttr {
             }
             MetaList(ref n, ref items) if *n == "inline" => {
                 mark_used(attr);
-                if contains_name(items[], "always") {
+                if contains_name(items.index(&FullRange), "always") {
                     InlineAlways
-                } else if contains_name(items[], "never") {
+                } else if contains_name(items.index(&FullRange), "never") {
                     InlineNever
                 } else {
                     InlineHint
@@ -332,7 +333,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)[]);
+            diagnostic.span_err(cfg.span, format!("invalid predicate `{}`", pred).as_slice());
             false
         },
         ast::MetaWord(_) | ast::MetaNameValue(..) => contains(cfgs, cfg),
@@ -357,6 +358,12 @@ pub enum StabilityLevel {
     Locked
 }
 
+impl fmt::String for StabilityLevel {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        fmt::Show::fmt(self, f)
+    }
+}
+
 pub fn find_stability_generic<'a,
                               AM: AttrMetaMethods,
                               I: Iterator<Item=&'a AM>>
@@ -396,7 +403,7 @@ pub fn require_unique_names(diagnostic: &SpanHandler, metas: &[P<MetaItem>]) {
 
         if !set.insert(name.clone()) {
             diagnostic.span_fatal(meta.span,
-                                  format!("duplicate meta item `{}`", name)[]);
+                                  format!("duplicate meta item `{}`", name).index(&FullRange));
         }
     }
 }
@@ -457,8 +464,10 @@ fn int_type_of_word(s: &str) -> Option<IntType> {
         "u32" => Some(UnsignedInt(ast::TyU32)),
         "i64" => Some(SignedInt(ast::TyI64)),
         "u64" => Some(UnsignedInt(ast::TyU64)),
-        "int" => Some(SignedInt(ast::TyI)),
-        "uint" => Some(UnsignedInt(ast::TyU)),
+        "int" => Some(SignedInt(ast::TyIs)),
+        "uint" => Some(UnsignedInt(ast::TyUs)),
+        "isize" => Some(SignedInt(ast::TyIs)),
+        "usize" => Some(UnsignedInt(ast::TyUs)),
         _ => None
     }
 }
@@ -502,7 +511,7 @@ fn is_ffi_safe(self) -> bool {
             SignedInt(ast::TyI16) | UnsignedInt(ast::TyU16) |
             SignedInt(ast::TyI32) | UnsignedInt(ast::TyU32) |
             SignedInt(ast::TyI64) | UnsignedInt(ast::TyU64) => true,
-            SignedInt(ast::TyI) | UnsignedInt(ast::TyU) => false
+            SignedInt(ast::TyIs) | UnsignedInt(ast::TyUs) => false
         }
     }
 }
index a49f2614cd7871f1d8eef024bdd677c07fba9b43..31fe23847d9a8c412820ca399637f42c8d24d6a3 100644 (file)
@@ -120,15 +120,6 @@ fn ne(&self, other: &Span) -> bool { !(*self).eq(other) }
 
 impl Eq for Span {}
 
-#[cfg(stage0)]
-impl<S:Encoder<E>, E> Encodable<S, E> for Span {
-    /* Note #1972 -- spans are encoded but not decoded */
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_nil()
-    }
-}
-
-#[cfg(not(stage0))]
 impl Encodable for Span {
     /* Note #1972 -- spans are encoded but not decoded */
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
@@ -136,14 +127,6 @@ fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
     }
 }
 
-#[cfg(stage0)]
-impl<D:Decoder<E>, E> Decodable<D, E> for Span {
-    fn decode(_d: &mut D) -> Result<Span, E> {
-        Ok(DUMMY_SP)
-    }
-}
-
-#[cfg(not(stage0))]
 impl Decodable for Span {
     fn decode<D: Decoder>(_d: &mut D) -> Result<Span, D::Error> {
         Ok(DUMMY_SP)
@@ -321,9 +304,9 @@ pub fn get_line(&self, line_number: uint) -> Option<String> {
         lines.get(line_number).map(|&line| {
             let begin: BytePos = line - self.start_pos;
             let begin = begin.to_uint();
-            let slice = self.src[begin..];
+            let slice = self.src.index(&(begin..));
             match slice.find('\n') {
-                Some(e) => slice[0..e],
+                Some(e) => slice.index(&(0..e)),
                 None => slice
             }.to_string()
         })
@@ -368,9 +351,9 @@ pub fn new_filemap(&self, filename: FileName, src: String) -> Rc<FileMap> {
         // FIXME #12884: no efficient/safe way to remove from the start of a string
         // and reuse the allocation.
         let mut src = if src.starts_with("\u{feff}") {
-            String::from_str(src[3..])
+            String::from_str(src.index(&(3..)))
         } else {
-            String::from_str(src[])
+            String::from_str(src.index(&FullRange))
         };
 
         // Append '\n' in case it's not already there.
@@ -457,8 +440,8 @@ pub fn span_to_snippet(&self, sp: Span) -> Option<String> {
         if begin.fm.start_pos != end.fm.start_pos {
             None
         } else {
-            Some(begin.fm.src[begin.pos.to_uint()..
-                              end.pos.to_uint()].to_string())
+            Some(begin.fm.src.index(&(begin.pos.to_uint()..
+                                      end.pos.to_uint())).to_string())
         }
     }
 
@@ -488,7 +471,7 @@ pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos {
         let mut total_extra_bytes = 0;
 
         for mbc in map.multibyte_chars.borrow().iter() {
-            debug!("{}-byte char at {}", mbc.bytes, mbc.pos);
+            debug!("{}-byte char at {:?}", mbc.bytes, mbc.pos);
             if mbc.pos < bpos {
                 // every character is at least one byte, so we only
                 // count the actual extra bytes.
@@ -566,9 +549,9 @@ fn lookup_pos(&self, pos: BytePos) -> Loc {
         let chpos = self.bytepos_to_file_charpos(pos);
         let linebpos = (*f.lines.borrow())[a];
         let linechpos = self.bytepos_to_file_charpos(linebpos);
-        debug!("byte pos {} is on the line at byte pos {}",
+        debug!("byte pos {:?} is on the line at byte pos {:?}",
                pos, linebpos);
-        debug!("char pos {} is on the line at char pos {}",
+        debug!("char pos {:?} is on the line at char pos {:?}",
                chpos, linechpos);
         debug!("byte is on line: {}", line);
         assert!(chpos >= linechpos);
index c19c06c3155876d3e0d8d3a3e593c2564e3b0d4d..fde2fdb3c558c476a84d835664fc5d2462074007 100644 (file)
@@ -123,7 +123,7 @@ pub fn span_bug(&self, sp: Span, msg: &str) -> ! {
         panic!(ExplicitBug);
     }
     pub fn span_unimpl(&self, sp: Span, msg: &str) -> ! {
-        self.span_bug(sp, format!("unimplemented {}", msg)[]);
+        self.span_bug(sp, format!("unimplemented {}", msg).index(&FullRange));
     }
     pub fn handler<'a>(&'a self) -> &'a Handler {
         &self.handler
@@ -166,7 +166,7 @@ pub fn abort_if_errors(&self) {
                         self.err_count.get());
           }
         }
-        self.fatal(s[]);
+        self.fatal(s.index(&FullRange));
     }
     pub fn warn(&self, msg: &str) {
         self.emit.borrow_mut().emit(None, msg, None, Warning);
@@ -182,7 +182,7 @@ pub fn bug(&self, msg: &str) -> ! {
         panic!(ExplicitBug);
     }
     pub fn unimpl(&self, msg: &str) -> ! {
-        self.bug(format!("unimplemented {}", msg)[]);
+        self.bug(format!("unimplemented {}", msg).index(&FullRange));
     }
     pub fn emit(&self,
                 cmsp: Option<(&codemap::CodeMap, Span)>,
@@ -222,7 +222,7 @@ pub fn mk_handler(e: Box<Emitter + Send>) -> Handler {
     }
 }
 
-#[derive(Copy, PartialEq, Clone)]
+#[derive(Copy, PartialEq, Clone, Show)]
 pub enum Level {
     Bug,
     Fatal,
@@ -232,9 +232,9 @@ pub enum Level {
     Help,
 }
 
-impl fmt::Show for Level {
+impl fmt::String for Level {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        use std::fmt::Show;
+        use std::fmt::String;
 
         match *self {
             Bug => "error: internal compiler error".fmt(f),
@@ -277,7 +277,7 @@ fn print_maybe_styled(w: &mut EmitterWriter,
             // to be miscolored. We assume this is rare enough that we don't
             // have to worry about it.
             if msg.ends_with("\n") {
-                try!(t.write_str(msg[0..msg.len()-1]));
+                try!(t.write_str(msg.index(&(0..(msg.len()-1)))));
                 try!(t.reset());
                 try!(t.write_str("\n"));
             } else {
@@ -299,16 +299,16 @@ fn print_diagnostic(dst: &mut EmitterWriter, topic: &str, lvl: Level,
     }
 
     try!(print_maybe_styled(dst,
-                            format!("{}: ", lvl.to_string())[],
+                            format!("{}: ", lvl.to_string()).index(&FullRange),
                             term::attr::ForegroundColor(lvl.color())));
     try!(print_maybe_styled(dst,
-                            format!("{}", msg)[],
+                            format!("{}", msg).index(&FullRange),
                             term::attr::Bold));
 
     match code {
         Some(code) => {
             let style = term::attr::ForegroundColor(term::color::BRIGHT_MAGENTA);
-            try!(print_maybe_styled(dst, format!(" [{}]", code.clone())[], style));
+            try!(print_maybe_styled(dst, format!(" [{}]", code.clone()).index(&FullRange), style));
         }
         None => ()
     }
@@ -374,7 +374,7 @@ fn emit(&mut self,
 
         match error {
             Ok(()) => {}
-            Err(e) => panic!("failed to print diagnostics: {}", e),
+            Err(e) => panic!("failed to print diagnostics: {:?}", e),
         }
     }
 
@@ -382,7 +382,7 @@ fn custom_emit(&mut self, cm: &codemap::CodeMap,
                    sp: RenderSpan, msg: &str, lvl: Level) {
         match emit(self, cm, sp, msg, None, lvl, true) {
             Ok(()) => {}
-            Err(e) => panic!("failed to print diagnostics: {}", e),
+            Err(e) => panic!("failed to print diagnostics: {:?}", e),
         }
     }
 }
@@ -398,12 +398,12 @@ fn emit(dst: &mut EmitterWriter, cm: &codemap::CodeMap, rsp: RenderSpan,
         // the span)
         let span_end = Span { lo: sp.hi, hi: sp.hi, expn_id: sp.expn_id};
         let ses = cm.span_to_string(span_end);
-        try!(print_diagnostic(dst, ses[], lvl, msg, code));
+        try!(print_diagnostic(dst, ses.index(&FullRange), lvl, msg, code));
         if rsp.is_full_span() {
             try!(custom_highlight_lines(dst, cm, sp, lvl, lines));
         }
     } else {
-        try!(print_diagnostic(dst, ss[], lvl, msg, code));
+        try!(print_diagnostic(dst, ss.index(&FullRange), lvl, msg, code));
         if rsp.is_full_span() {
             try!(highlight_lines(dst, cm, sp, lvl, lines));
         }
@@ -413,9 +413,9 @@ fn emit(dst: &mut EmitterWriter, cm: &codemap::CodeMap, rsp: RenderSpan,
         Some(code) =>
             match dst.registry.as_ref().and_then(|registry| registry.find_description(code)) {
                 Some(_) => {
-                    try!(print_diagnostic(dst, ss[], Help,
+                    try!(print_diagnostic(dst, ss.index(&FullRange), Help,
                                           format!("pass `--explain {}` to see a detailed \
-                                                   explanation", code)[], None));
+                                                   explanation", code).index(&FullRange), None));
                 }
                 None => ()
             },
@@ -432,9 +432,9 @@ fn highlight_lines(err: &mut EmitterWriter,
     let fm = &*lines.file;
 
     let mut elided = false;
-    let mut display_lines = lines.lines[];
+    let mut display_lines = lines.lines.index(&FullRange);
     if display_lines.len() > MAX_LINES {
-        display_lines = display_lines[0u..MAX_LINES];
+        display_lines = display_lines.index(&(0u..MAX_LINES));
         elided = true;
     }
     // Print the offending lines
@@ -494,7 +494,7 @@ fn highlight_lines(err: &mut EmitterWriter,
             }
         }
         try!(print_maybe_styled(err,
-                                format!("{}\n", s)[],
+                                format!("{}\n", s).index(&FullRange),
                                 term::attr::ForegroundColor(lvl.color())));
     }
     Ok(())
@@ -514,7 +514,7 @@ fn custom_highlight_lines(w: &mut EmitterWriter,
                           -> io::IoResult<()> {
     let fm = &*lines.file;
 
-    let lines = lines.lines[];
+    let lines = lines.lines.index(&FullRange);
     if lines.len() > MAX_LINES {
         if let Some(line) = fm.get_line(lines[0]) {
             try!(write!(&mut w.dst, "{}:{} {}\n", fm.name,
@@ -545,7 +545,7 @@ fn custom_highlight_lines(w: &mut EmitterWriter,
     s.push('^');
     s.push('\n');
     print_maybe_styled(w,
-                       s[],
+                       s.index(&FullRange),
                        term::attr::ForegroundColor(lvl.color()))
 }
 
@@ -560,12 +560,12 @@ fn print_macro_backtrace(w: &mut EmitterWriter,
                 codemap::MacroAttribute => ("#[", "]"),
                 codemap::MacroBang => ("", "!")
             };
-            try!(print_diagnostic(w, ss[], Note,
+            try!(print_diagnostic(w, ss.index(&FullRange), Note,
                                   format!("in expansion of {}{}{}", pre,
                                           ei.callee.name,
-                                          post)[], None));
+                                          post).index(&FullRange), None));
             let ss = cm.span_to_string(ei.call_site);
-            try!(print_diagnostic(w, ss[], Note, "expansion site", None));
+            try!(print_diagnostic(w, ss.index(&FullRange), Note, "expansion site", None));
             Ok(Some(ei.call_site))
         }
         None => Ok(None)
@@ -578,6 +578,6 @@ pub fn expect<T, M>(diag: &SpanHandler, opt: Option<T>, msg: M) -> T where
 {
     match opt {
         Some(t) => t,
-        None => diag.handler().bug(msg()[]),
+        None => diag.handler().bug(msg().index(&FullRange)),
     }
 }
index 720a907fe77f0cb4971bbfc92c9232741bd6bbf0..0f4ebd74b66c72c38ec0f8f62a1cf887d71aec8c 100644 (file)
@@ -58,7 +58,7 @@ pub fn expand_diagnostic_used<'cx>(ecx: &'cx mut ExtCtxt,
             Some(previous_span) => {
                 ecx.span_warn(span, format!(
                     "diagnostic code {} already used", token::get_ident(code).get()
-                )[]);
+                ).index(&FullRange));
                 ecx.span_note(previous_span, "previous invocation");
             },
             None => ()
@@ -87,12 +87,12 @@ pub fn expand_register_diagnostic<'cx>(ecx: &'cx mut ExtCtxt,
         if diagnostics.insert(code.name, description).is_some() {
             ecx.span_err(span, format!(
                 "diagnostic code {} already registered", token::get_ident(*code).get()
-            )[]);
+            ).index(&FullRange));
         }
     });
     let sym = Ident::new(token::gensym((
         "__register_diagnostic_".to_string() + token::get_ident(*code).get()
-    )[]));
+    ).index(&FullRange)));
     MacItems::new(vec![quote_item!(ecx, mod $sym {}).unwrap()].into_iter())
 }
 
index b77b822a6b2a150ab9db1c84c5790b52e46bc825..04dec0e8028417a376b62e37dabb4c864f683b5d 100644 (file)
@@ -100,7 +100,7 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                         Some(('=', _)) => None,
                         Some(('+', operand)) => {
                             Some(token::intern_and_get_ident(format!(
-                                        "={}", operand)[]))
+                                        "={}", operand).index(&FullRange)))
                         }
                         _ => {
                             cx.span_err(span, "output operand constraint lacks '=' or '+'");
index 91ae7396ea46920b4a97f1b188e30b9a714f2438..52e402689ba770aea8fcd2f443f88751b4386f5a 100644 (file)
@@ -539,7 +539,7 @@ pub fn original_span_in_file(&self) -> Span {
     pub fn mod_pop(&mut self) { self.mod_path.pop().unwrap(); }
     pub fn mod_path(&self) -> Vec<ast::Ident> {
         let mut v = Vec::new();
-        v.push(token::str_to_ident(self.ecfg.crate_name[]));
+        v.push(token::str_to_ident(self.ecfg.crate_name.index(&FullRange)));
         v.extend(self.mod_path.iter().map(|a| *a));
         return v;
     }
@@ -548,7 +548,7 @@ pub fn bt_push(&mut self, ei: ExpnInfo) {
         if self.recursion_count > self.ecfg.recursion_limit {
             self.span_fatal(ei.call_site,
                             format!("recursion limit reached while expanding the macro `{}`",
-                                    ei.callee.name)[]);
+                                    ei.callee.name).index(&FullRange));
         }
 
         let mut call_site = ei.call_site;
@@ -670,7 +670,7 @@ pub fn check_zero_tts(cx: &ExtCtxt,
                       tts: &[ast::TokenTree],
                       name: &str) {
     if tts.len() != 0 {
-        cx.span_err(sp, format!("{} takes no arguments", name)[]);
+        cx.span_err(sp, format!("{} takes no arguments", name).index(&FullRange));
     }
 }
 
@@ -683,12 +683,12 @@ pub fn get_single_str_from_tts(cx: &mut ExtCtxt,
                                -> Option<String> {
     let mut p = cx.new_parser_from_tts(tts);
     if p.token == token::Eof {
-        cx.span_err(sp, format!("{} takes 1 argument", name)[]);
+        cx.span_err(sp, format!("{} takes 1 argument", name).index(&FullRange));
         return None
     }
     let ret = cx.expander().fold_expr(p.parse_expr());
     if p.token != token::Eof {
-        cx.span_err(sp, format!("{} takes 1 argument", name)[]);
+        cx.span_err(sp, format!("{} takes 1 argument", name).index(&FullRange));
     }
     expr_to_string(cx, ret, "argument must be a string literal").map(|(s, _)| {
         s.get().to_string()
index ea345f3a458f49ea4b5d49b579072cf3efdaf18f..bd4f295401cad046e4e40032c7e213189358c531 100644 (file)
@@ -642,10 +642,10 @@ fn expr_lit(&self, sp: Span, lit: ast::Lit_) -> P<ast::Expr> {
         self.expr(sp, ast::ExprLit(P(respan(sp, lit))))
     }
     fn expr_uint(&self, span: Span, i: uint) -> P<ast::Expr> {
-        self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyU)))
+        self.expr_lit(span, ast::LitInt(i as u64, ast::UnsignedIntLit(ast::TyUs)))
     }
     fn expr_int(&self, sp: Span, i: int) -> P<ast::Expr> {
-        self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyI, ast::Sign::new(i))))
+        self.expr_lit(sp, ast::LitInt(i as u64, ast::SignedIntLit(ast::TyIs, ast::Sign::new(i))))
     }
     fn expr_u8(&self, sp: Span, u: u8) -> P<ast::Expr> {
         self.expr_lit(sp, ast::LitInt(u as u64, ast::UnsignedIntLit(ast::TyU8)))
@@ -709,7 +709,7 @@ fn expr_fail(&self, span: Span, msg: InternedString) -> P<ast::Expr> {
         let loc = self.codemap().lookup_char_pos(span.lo);
         let expr_file = self.expr_str(span,
                                       token::intern_and_get_ident(loc.file
-                                                                  .name[]));
+                                                                  .name.index(&FullRange)));
         let expr_line = self.expr_uint(span, loc.line);
         let expr_file_line_tuple = self.expr_tuple(span, vec!(expr_file, expr_line));
         let expr_file_line_ptr = self.expr_addr_of(span, expr_file_line_tuple);
index 03dd08fdf7fe43f35d81d5221df75fa60bb0dcdc..1f1781dceb30b2eb9b233659b26b86605e686a1a 100644 (file)
@@ -40,14 +40,14 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
                     ast::LitInt(i, ast::UnsignedIntLit(_)) |
                     ast::LitInt(i, ast::SignedIntLit(_, ast::Plus)) |
                     ast::LitInt(i, ast::UnsuffixedIntLit(ast::Plus)) => {
-                        accumulator.push_str(format!("{}", i)[]);
+                        accumulator.push_str(format!("{}", i).index(&FullRange));
                     }
                     ast::LitInt(i, ast::SignedIntLit(_, ast::Minus)) |
                     ast::LitInt(i, ast::UnsuffixedIntLit(ast::Minus)) => {
-                        accumulator.push_str(format!("-{}", i)[]);
+                        accumulator.push_str(format!("-{}", i).index(&FullRange));
                     }
                     ast::LitBool(b) => {
-                        accumulator.push_str(format!("{}", b)[]);
+                        accumulator.push_str(format!("{}", b).index(&FullRange));
                     }
                     ast::LitByte(..) |
                     ast::LitBinary(..) => {
@@ -62,5 +62,5 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt,
     }
     base::MacExpr::new(cx.expr_str(
             sp,
-            token::intern_and_get_ident(accumulator[])))
+            token::intern_and_get_ident(accumulator.index(&FullRange))))
 }
index 2cf60d30a1b25a16b563cea975011038633176d0..02f702248cb6676d7b8dfcfbf9739dec5aa6ef64 100644 (file)
@@ -40,7 +40,7 @@ pub fn expand_syntax_ext<'cx>(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]
             }
         }
     }
-    let res = str_to_ident(res_str[]);
+    let res = str_to_ident(res_str.index(&FullRange));
 
     let e = P(ast::Expr {
         id: ast::DUMMY_NODE_ID,
index cf29bb048d6445b4f98bdc67b80aee7d9cac9094..8ac7e57bb818b3b901ad75a962f2efc63e744ee5 100644 (file)
@@ -29,12 +29,13 @@ pub fn expand_deriving_bound<F>(cx: &mut ExtCtxt,
                 "Send" | "Sync" => {
                     return cx.span_err(span,
                                        format!("{} is an unsafe trait and it \
-                                               should be implemented explicitly", *tname)[])
+                                                should be implemented explicitly",
+                                               *tname).as_slice())
                 }
                 ref tname => {
                     cx.span_bug(span,
                                 format!("expected built-in trait name but \
-                                         found {}", *tname)[])
+                                         found {}", *tname).as_slice())
                 }
             }
         },
@@ -47,7 +48,7 @@ pub fn expand_deriving_bound<F>(cx: &mut ExtCtxt,
     let trait_def = TraitDef {
         span: span,
         attributes: Vec::new(),
-        path: Path::new(vec!("std", "kinds", name)),
+        path: Path::new(vec!("std", "marker", name)),
         additional_bounds: Vec::new(),
         generics: LifetimeBounds::empty(),
         methods: vec!()
index 3c74a9f4431df52d94844d2c656c5d9d0efbdd75..d9d6cebd05c90d6f4bfaaee5b5e566a2b6e6add6 100644 (file)
@@ -80,11 +80,11 @@ fn cs_clone(
         EnumNonMatchingCollapsed (..) => {
             cx.span_bug(trait_span,
                         format!("non-matching enum variants in \
-                                 `deriving({})`", name)[])
+                                 `deriving({})`", name).index(&FullRange))
         }
         StaticEnum(..) | StaticStruct(..) => {
             cx.span_bug(trait_span,
-                        format!("static method in `deriving({})`", name)[])
+                        format!("static method in `deriving({})`", name).index(&FullRange))
         }
     }
 
@@ -101,7 +101,7 @@ fn cs_clone(
                 None => {
                     cx.span_bug(trait_span,
                                 format!("unnamed field in normal struct in \
-                                         `deriving({})`", name)[])
+                                         `deriving({})`", name).index(&FullRange))
                 }
             };
             cx.field_imm(field.span, ident, subcall(field))
index 8094f0d3de8ccedeb30c92967b1761c69c808be7..a9289f0175a6961aa1ee4d4dc0978b16c4a24f38 100644 (file)
@@ -198,7 +198,7 @@ fn decode_static_fields<F>(cx: &mut ExtCtxt,
                 let fields = fields.iter().enumerate().map(|(i, &span)| {
                     getarg(cx, span,
                            token::intern_and_get_ident(format!("_field{}",
-                                                               i)[]),
+                                                               i).index(&FullRange)),
                            i)
                 }).collect();
 
index 0fceb0fbfdac4774dc0e6d489b9b4f877bd63eeb..7114217d51d0ac602b565e62cf5e7642bcfc4dd9 100644 (file)
@@ -183,7 +183,7 @@ fn encodable_substructure(cx: &mut ExtCtxt, trait_span: Span,
                 let name = match name {
                     Some(id) => token::get_ident(id),
                     None => {
-                        token::intern_and_get_ident(format!("_field{}", i)[])
+                        token::intern_and_get_ident(format!("_field{}", i).index(&FullRange))
                     }
                 };
                 let enc = cx.expr_method_call(span, self_.clone(),
index 1aa430c4a08299b325ec73fd42dbb8934ffa4443..50b3559f369fb2f33540ebccca3e7b2b384bb2eb 100644 (file)
@@ -510,15 +510,15 @@ fn expand_struct_def(&self,
                     self,
                     struct_def,
                     type_ident,
-                    self_args[],
-                    nonself_args[])
+                    self_args.index(&FullRange),
+                    nonself_args.index(&FullRange))
             } else {
                 method_def.expand_struct_method_body(cx,
                                                      self,
                                                      struct_def,
                                                      type_ident,
-                                                     self_args[],
-                                                     nonself_args[])
+                                                     self_args.index(&FullRange),
+                                                     nonself_args.index(&FullRange))
             };
 
             method_def.create_method(cx,
@@ -550,15 +550,15 @@ fn expand_enum_def(&self,
                     self,
                     enum_def,
                     type_ident,
-                    self_args[],
-                    nonself_args[])
+                    self_args.index(&FullRange),
+                    nonself_args.index(&FullRange))
             } else {
                 method_def.expand_enum_method_body(cx,
                                                    self,
                                                    enum_def,
                                                    type_ident,
                                                    self_args,
-                                                   nonself_args[])
+                                                   nonself_args.index(&FullRange))
             };
 
             method_def.create_method(cx,
@@ -602,7 +602,7 @@ fn call_substructure_method(&self,
         };
         let mut f = self.combine_substructure.borrow_mut();
         let f: &mut CombineSubstructureFunc = &mut *f;
-        f.call_mut((cx, trait_.span, &substructure))
+        f(cx, trait_.span, &substructure)
     }
 
     fn get_ret_ty(&self,
@@ -645,7 +645,7 @@ fn split_self_nonself_args(&self,
 
         for (i, ty) in self.args.iter().enumerate() {
             let ast_ty = ty.to_ty(cx, trait_.span, type_ident, generics);
-            let ident = cx.ident_of(format!("__arg_{}", i)[]);
+            let ident = cx.ident_of(format!("__arg_{}", i).index(&FullRange));
             arg_tys.push((ident, ast_ty));
 
             let arg_expr = cx.expr_ident(trait_.span, ident);
@@ -752,7 +752,7 @@ fn expand_struct_method_body(&self,
                                              struct_path,
                                              struct_def,
                                              format!("__self_{}",
-                                                     i)[],
+                                                     i).index(&FullRange),
                                              ast::MutImmutable);
             patterns.push(pat);
             raw_fields.push(ident_expr);
@@ -908,22 +908,22 @@ fn build_enum_match_tuple(
             .collect::<Vec<String>>();
 
         let self_arg_idents = self_arg_names.iter()
-            .map(|name|cx.ident_of(name[]))
+            .map(|name|cx.ident_of(name.index(&FullRange)))
             .collect::<Vec<ast::Ident>>();
 
         // The `vi_idents` will be bound, solely in the catch-all, to
         // a series of let statements mapping each self_arg to a uint
         // corresponding to its variant index.
         let vi_idents: Vec<ast::Ident> = self_arg_names.iter()
-            .map(|name| { let vi_suffix = format!("{}_vi", name[]);
-                          cx.ident_of(vi_suffix[]) })
+            .map(|name| { let vi_suffix = format!("{}_vi", name.index(&FullRange));
+                          cx.ident_of(vi_suffix.index(&FullRange)) })
             .collect::<Vec<ast::Ident>>();
 
         // Builds, via callback to call_substructure_method, the
         // delegated expression that handles the catch-all case,
         // using `__variants_tuple` to drive logic if necessary.
         let catch_all_substructure = EnumNonMatchingCollapsed(
-            self_arg_idents, variants[], vi_idents[]);
+            self_arg_idents, variants.index(&FullRange), vi_idents.index(&FullRange));
 
         // These arms are of the form:
         // (Variant1, Variant1, ...) => Body1
@@ -945,12 +945,12 @@ fn build_enum_match_tuple(
                 let mut subpats = Vec::with_capacity(self_arg_names.len());
                 let mut self_pats_idents = Vec::with_capacity(self_arg_names.len() - 1);
                 let first_self_pat_idents = {
-                    let (p, idents) = mk_self_pat(cx, self_arg_names[0][]);
+                    let (p, idents) = mk_self_pat(cx, self_arg_names[0].index(&FullRange));
                     subpats.push(p);
                     idents
                 };
                 for self_arg_name in self_arg_names.tail().iter() {
-                    let (p, idents) = mk_self_pat(cx, self_arg_name[]);
+                    let (p, idents) = mk_self_pat(cx, self_arg_name.index(&FullRange));
                     subpats.push(p);
                     self_pats_idents.push(idents);
                 }
@@ -1006,7 +1006,7 @@ fn build_enum_match_tuple(
                                                 &**variant,
                                                 field_tuples);
                 let arm_expr = self.call_substructure_method(
-                    cx, trait_, type_ident, self_args[], nonself_args,
+                    cx, trait_, type_ident, self_args.index(&FullRange), nonself_args,
                     &substructure);
 
                 cx.arm(sp, vec![single_pat], arm_expr)
@@ -1031,7 +1031,7 @@ fn build_enum_match_tuple(
             let arms: Vec<ast::Arm> = variants.iter().enumerate()
                 .map(|(index, variant)| {
                     let pat = variant_to_pat(cx, sp, type_ident, &**variant);
-                    let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyU));
+                    let lit = ast::LitInt(index as u64, ast::UnsignedIntLit(ast::TyUs));
                     cx.arm(sp, vec![pat], cx.expr_lit(sp, lit))
                 }).collect();
 
@@ -1059,7 +1059,7 @@ fn build_enum_match_tuple(
             }
 
             let arm_expr = self.call_substructure_method(
-                cx, trait_, type_ident, self_args[], nonself_args,
+                cx, trait_, type_ident, self_args.index(&FullRange), nonself_args,
                 &catch_all_substructure);
 
             // Builds the expression:
@@ -1263,7 +1263,7 @@ fn create_struct_pattern(&self,
                     cx.span_bug(sp, "a struct with named and unnamed fields in `derive`");
                 }
             };
-            let ident = cx.ident_of(format!("{}_{}", prefix, i)[]);
+            let ident = cx.ident_of(format!("{}_{}", prefix, i).index(&FullRange));
             paths.push(codemap::Spanned{span: sp, node: ident});
             let val = cx.expr(
                 sp, ast::ExprParen(cx.expr_deref(sp, cx.expr_path(cx.path_ident(sp,ident)))));
@@ -1309,7 +1309,7 @@ fn create_enum_variant_pattern(&self,
                 let mut ident_expr = Vec::new();
                 for (i, va) in variant_args.iter().enumerate() {
                     let sp = self.set_expn_info(cx, va.ty.span);
-                    let ident = cx.ident_of(format!("{}_{}", prefix, i)[]);
+                    let ident = cx.ident_of(format!("{}_{}", prefix, i).index(&FullRange));
                     let path1 = codemap::Spanned{span: sp, node: ident};
                     paths.push(path1);
                     let expr_path = cx.expr_path(cx.path_ident(sp, ident));
@@ -1352,7 +1352,7 @@ pub fn cs_fold<F>(use_foldl: bool,
                       field.span,
                       old,
                       field.self_.clone(),
-                      field.other[])
+                      field.other.index(&FullRange))
                 })
             } else {
                 all_fields.iter().rev().fold(base, |old, field| {
@@ -1360,13 +1360,13 @@ pub fn cs_fold<F>(use_foldl: bool,
                       field.span,
                       old,
                       field.self_.clone(),
-                      field.other[])
+                      field.other.index(&FullRange))
                 })
             }
         },
         EnumNonMatchingCollapsed(ref all_args, _, tuple) =>
-            enum_nonmatch_f.call_mut((cx, trait_span, (all_args[], tuple),
-                                      substructure.nonself_args)),
+            enum_nonmatch_f(cx, trait_span, (all_args.index(&FullRange), tuple),
+                            substructure.nonself_args),
         StaticEnum(..) | StaticStruct(..) => {
             cx.span_bug(trait_span, "static function in `derive`")
         }
@@ -1405,8 +1405,8 @@ pub fn cs_same_method<F>(f: F,
             f(cx, trait_span, called)
         },
         EnumNonMatchingCollapsed(ref all_self_args, _, tuple) =>
-            enum_nonmatch_f.call_mut((cx, trait_span, (all_self_args[], tuple),
-                                     substructure.nonself_args)),
+            enum_nonmatch_f(cx, trait_span, (all_self_args.index(&FullRange), tuple),
+                            substructure.nonself_args),
         StaticEnum(..) | StaticStruct(..) => {
             cx.span_bug(trait_span, "static function in `derive`")
         }
index e72c83b67c89be435404aea043c5b9b6d0f54f62..43a0e0606f8bb421a25ec5385f6a7d0cfdecc2be 100644 (file)
@@ -73,7 +73,7 @@ pub fn expand_meta_derive(cx: &mut ExtCtxt,
                     MetaWord(ref tname) => {
                         macro_rules! expand {
                             ($func:path) => ($func(cx, titem.span, &**titem, item,
-                                                   |i| push.call_mut((i,))))
+                                                   |i| push(i)))
                         }
 
                         match tname.get() {
@@ -123,7 +123,7 @@ macro_rules! expand {
                                 cx.span_err(titem.span,
                                             format!("unknown `derive` \
                                                      trait: `{}`",
-                                                    *tname)[]);
+                                                    *tname).index(&FullRange));
                             }
                         };
                     }
index eceac4e9a8368ff38af02b125baaa07a05b5bb92..fa9a7899a1228ec94b5e454ea14f94d6ffc791f6 100644 (file)
@@ -90,7 +90,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
                 for (i, field) in fields.iter().enumerate() {
                     if i != 0 { format_string.push_str(", "); }
 
-                    format_string.push_str("{}");
+                    format_string.push_str("{:?}");
 
                     exprs.push(field.self_.clone());
                 }
@@ -107,7 +107,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
                     let name = token::get_ident(field.name.unwrap());
                     format_string.push_str(" ");
                     format_string.push_str(name.get());
-                    format_string.push_str(": {}");
+                    format_string.push_str(": {:?}");
 
                     exprs.push(field.self_.clone());
                 }
@@ -127,7 +127,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span,
     let formatter = substr.nonself_args[0].clone();
 
     let meth = cx.ident_of("write_fmt");
-    let s = token::intern_and_get_ident(format_string[]);
+    let s = token::intern_and_get_ident(format_string.index(&FullRange));
     let format_string = cx.expr_str(span, s);
 
     // phew, not our responsibility any more!
index 9fedc4a158e1569f5d5403cf05fd4e270dfe26ed..eb3544e3c5c7f0aaacd08999f0bb1ac8311f56a5 100644 (file)
@@ -30,7 +30,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT
         Some(v) => v
     };
 
-    let e = match os::getenv(var[]) {
+    let e = match os::getenv(var.index(&FullRange)) {
       None => {
           cx.expr_path(cx.path_all(sp,
                                    true,
@@ -56,7 +56,7 @@ pub fn expand_option_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenT
                                    cx.ident_of("Some")),
                               vec!(cx.expr_str(sp,
                                                token::intern_and_get_ident(
-                                          s[]))))
+                                          s.index(&FullRange)))))
       }
     };
     MacExpr::new(e)
@@ -83,7 +83,7 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
         None => {
             token::intern_and_get_ident(format!("environment variable `{}` \
                                                  not defined",
-                                                var)[])
+                                                var).index(&FullRange))
         }
         Some(second) => {
             match expr_to_string(cx, second, "expected string literal") {
@@ -106,7 +106,7 @@ pub fn expand_env<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
             cx.span_err(sp, msg.get());
             cx.expr_uint(sp, 0)
         }
-        Some(s) => cx.expr_str(sp, token::intern_and_get_ident(s[]))
+        Some(s) => cx.expr_str(sp, token::intern_and_get_ident(s.index(&FullRange)))
     };
     MacExpr::new(e)
 }
index 212ec3b0903252ccd9f7c418cb473c39f6bbe1bf..3e1bccf394aa0cea398265d75fc73a4547c294cc 100644 (file)
@@ -36,7 +36,7 @@ pub fn expand_type(t: P<ast::Ty>,
                    fld: &mut MacroExpander,
                    impl_ty: Option<P<ast::Ty>>)
                    -> P<ast::Ty> {
-    debug!("expanding type {} with impl_ty {}", t, impl_ty);
+    debug!("expanding type {:?} with impl_ty {:?}", t, impl_ty);
     let t = match (t.node.clone(), impl_ty) {
         // Expand uses of `Self` in impls to the concrete type.
         (ast::Ty_::TyPath(ref path, _), Some(ref impl_ty)) => {
@@ -287,7 +287,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,
                     fld.cx.span_err(
                         pth.span,
                         format!("macro undefined: '{}!'",
-                                extnamestr.get())[]);
+                                extnamestr.get()).index(&FullRange));
 
                     // let compilation continue
                     None
@@ -303,7 +303,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,
                                 },
                             });
                         let fm = fresh_mark();
-                        let marked_before = mark_tts(tts[], fm);
+                        let marked_before = mark_tts(tts.index(&FullRange), fm);
 
                         // The span that we pass to the expanders we want to
                         // be the root of the call stack. That's the most
@@ -314,7 +314,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,
                         let opt_parsed = {
                             let expanded = expandfun.expand(fld.cx,
                                                             mac_span,
-                                                            marked_before[]);
+                                                            marked_before.index(&FullRange));
                             parse_thunk(expanded)
                         };
                         let parsed = match opt_parsed {
@@ -323,8 +323,8 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,
                                 fld.cx.span_err(
                                     pth.span,
                                     format!("non-expression macro in expression position: {}",
-                                            extnamestr.get()[]
-                                            )[]);
+                                            extnamestr.get().index(&FullRange)
+                                            ).index(&FullRange));
                                 return None;
                             }
                         };
@@ -334,7 +334,7 @@ fn expand_mac_invoc<T, F, G>(mac: ast::Mac, span: codemap::Span,
                         fld.cx.span_err(
                             pth.span,
                             format!("'{}' is not a tt-style macro",
-                                    extnamestr.get())[]);
+                                    extnamestr.get()).index(&FullRange));
                         None
                     }
                 }
@@ -439,7 +439,7 @@ pub fn expand_item(it: P<ast::Item>, fld: &mut MacroExpander)
             if valid_ident {
                 fld.cx.mod_push(it.ident);
             }
-            let macro_use = contains_macro_use(fld, new_attrs[]);
+            let macro_use = contains_macro_use(fld, new_attrs.index(&FullRange));
             let result = with_exts_frame!(fld.cx.syntax_env,
                                           macro_use,
                                           noop_fold_item(it, fld));
@@ -566,7 +566,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
             None => {
                 fld.cx.span_err(path_span,
                                 format!("macro undefined: '{}!'",
-                                        extnamestr)[]);
+                                        extnamestr).index(&FullRange));
                 // let compilation continue
                 return SmallVector::zero();
             }
@@ -579,7 +579,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
                                       format!("macro {}! expects no ident argument, \
                                         given '{}'",
                                       extnamestr,
-                                      token::get_ident(it.ident))[]);
+                                      token::get_ident(it.ident)).index(&FullRange));
                         return SmallVector::zero();
                     }
                     fld.cx.bt_push(ExpnInfo {
@@ -591,14 +591,14 @@ pub fn expand_item_mac(it: P<ast::Item>,
                         }
                     });
                     // mark before expansion:
-                    let marked_before = mark_tts(tts[], fm);
-                    expander.expand(fld.cx, it.span, marked_before[])
+                    let marked_before = mark_tts(tts.index(&FullRange), fm);
+                    expander.expand(fld.cx, it.span, marked_before.index(&FullRange))
                 }
                 IdentTT(ref expander, span) => {
                     if it.ident.name == parse::token::special_idents::invalid.name {
                         fld.cx.span_err(path_span,
                                         format!("macro {}! expects an ident argument",
-                                                extnamestr.get())[]);
+                                                extnamestr.get()).index(&FullRange));
                         return SmallVector::zero();
                     }
                     fld.cx.bt_push(ExpnInfo {
@@ -610,13 +610,14 @@ pub fn expand_item_mac(it: P<ast::Item>,
                         }
                     });
                     // mark before expansion:
-                    let marked_tts = mark_tts(tts[], fm);
+                    let marked_tts = mark_tts(tts.index(&FullRange), fm);
                     expander.expand(fld.cx, it.span, it.ident, marked_tts)
                 }
                 MacroRulesTT => {
                     if it.ident.name == parse::token::special_idents::invalid.name {
                         fld.cx.span_err(path_span,
-                                        format!("macro_rules! expects an ident argument")[]);
+                                        format!("macro_rules! expects an ident argument")
+                                            .index(&FullRange));
                         return SmallVector::zero();
                     }
                     fld.cx.bt_push(ExpnInfo {
@@ -648,7 +649,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
                 _ => {
                     fld.cx.span_err(it.span,
                                     format!("{}! is not legal in item position",
-                                            extnamestr.get())[]);
+                                            extnamestr.get()).index(&FullRange));
                     return SmallVector::zero();
                 }
             }
@@ -667,7 +668,7 @@ pub fn expand_item_mac(it: P<ast::Item>,
         None => {
             fld.cx.span_err(path_span,
                             format!("non-item macro in item position: {}",
-                                    extnamestr.get())[]);
+                                    extnamestr.get()).index(&FullRange));
             return SmallVector::zero();
         }
     };
@@ -913,7 +914,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
             None => {
                 fld.cx.span_err(pth.span,
                                 format!("macro undefined: '{}!'",
-                                        extnamestr)[]);
+                                        extnamestr).index(&FullRange));
                 // let compilation continue
                 return DummyResult::raw_pat(span);
             }
@@ -930,11 +931,11 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
                     });
 
                     let fm = fresh_mark();
-                    let marked_before = mark_tts(tts[], fm);
+                    let marked_before = mark_tts(tts.index(&FullRange), fm);
                     let mac_span = fld.cx.original_span();
                     let expanded = match expander.expand(fld.cx,
                                         mac_span,
-                                        marked_before[]).make_pat() {
+                                        marked_before.index(&FullRange)).make_pat() {
                         Some(e) => e,
                         None => {
                             fld.cx.span_err(
@@ -942,7 +943,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
                                 format!(
                                     "non-pattern macro in pattern position: {}",
                                     extnamestr.get()
-                                )[]
+                                ).index(&FullRange)
                             );
                             return DummyResult::raw_pat(span);
                         }
@@ -954,7 +955,7 @@ fn expand_pat(p: P<ast::Pat>, fld: &mut MacroExpander) -> P<ast::Pat> {
                 _ => {
                     fld.cx.span_err(span,
                                     format!("{}! is not legal in pattern position",
-                                            extnamestr.get())[]);
+                                            extnamestr.get()).index(&FullRange));
                     return DummyResult::raw_pat(span);
                 }
             }
@@ -1231,7 +1232,7 @@ fn fold_mac(&mut self, Spanned {node, span}: ast::Mac) -> ast::Mac {
             node: match node {
                 MacInvocTT(path, tts, ctxt) => {
                     MacInvocTT(self.fold_path(path),
-                               self.fold_tts(tts[]),
+                               self.fold_tts(tts.index(&FullRange)),
                                mtwt::apply_mark(self.mark, ctxt))
                 }
             },
@@ -1712,7 +1713,7 @@ fn run_renaming_test(t: &RenamingTest, test_idx: uint) {
                 let string = ident.get();
                 "xx" == string
             }).collect();
-        let cxbinds: &[&ast::Ident] = cxbinds[];
+        let cxbinds: &[&ast::Ident] = cxbinds.index(&FullRange);
         let cxbind = match cxbinds {
             [b] => b,
             _ => panic!("expected just one binding for ext_cx")
index 1f39555f4962c3217bc1dd8525ed1bedb4400b53..44a596d2657ef28214b99924540e06dd7f7dd8ed 100644 (file)
@@ -113,7 +113,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                 _ => {
                     ecx.span_err(p.span,
                                  format!("expected ident for named argument, found `{}`",
-                                         p.this_token_to_string())[]);
+                                         p.this_token_to_string()).index(&FullRange));
                     return None;
                 }
             };
@@ -126,7 +126,7 @@ fn parse_args(ecx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                 Some(prev) => {
                     ecx.span_err(e.span,
                                  format!("duplicate argument named `{}`",
-                                         name)[]);
+                                         name).index(&FullRange));
                     ecx.parse_sess.span_diagnostic.span_note(prev.span, "previously here");
                     continue
                 }
@@ -217,7 +217,7 @@ fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) {
                     let msg = format!("invalid reference to argument `{}` ({})",
                                       arg, self.describe_num_args());
 
-                    self.ecx.span_err(self.fmtsp, msg[]);
+                    self.ecx.span_err(self.fmtsp, msg.index(&FullRange));
                     return;
                 }
                 {
@@ -237,7 +237,7 @@ fn verify_arg_type(&mut self, arg: Position, ty: ArgumentType) {
                     Some(e) => e.span,
                     None => {
                         let msg = format!("there is no argument named `{}`", name);
-                        self.ecx.span_err(self.fmtsp, msg[]);
+                        self.ecx.span_err(self.fmtsp, msg.index(&FullRange));
                         return;
                     }
                 };
@@ -280,19 +280,19 @@ fn verify_same(&self,
                                   format!("argument redeclared with type `{}` when \
                                            it was previously `{}`",
                                           *ty,
-                                          *cur)[]);
+                                          *cur).index(&FullRange));
             }
             (&Known(ref cur), _) => {
                 self.ecx.span_err(sp,
                                   format!("argument used to format with `{}` was \
                                            attempted to not be used for formatting",
-                                           *cur)[]);
+                                           *cur).index(&FullRange));
             }
             (_, &Known(ref ty)) => {
                 self.ecx.span_err(sp,
                                   format!("argument previously used as a format \
                                            argument attempted to be used as `{}`",
-                                           *ty)[]);
+                                           *ty).index(&FullRange));
             }
             (_, _) => {
                 self.ecx.span_err(sp, "argument declared with multiple formats");
@@ -357,7 +357,7 @@ fn trans_count(&self, c: parse::Count) -> P<ast::Expr> {
     /// Translate the accumulated string literals to a literal expression
     fn trans_literal_string(&mut self) -> P<ast::Expr> {
         let sp = self.fmtsp;
-        let s = token::intern_and_get_ident(self.literal[]);
+        let s = token::intern_and_get_ident(self.literal.index(&FullRange));
         self.literal.clear();
         self.ecx.expr_str(sp, s)
     }
@@ -509,7 +509,7 @@ fn into_expr(mut self) -> P<ast::Expr> {
                 None => continue // error already generated
             };
 
-            let name = self.ecx.ident_of(format!("__arg{}", i)[]);
+            let name = self.ecx.ident_of(format!("__arg{}", i).index(&FullRange));
             pats.push(self.ecx.pat_ident(e.span, name));
             locals.push(Context::format_arg(self.ecx, e.span, arg_ty,
                                             self.ecx.expr_ident(e.span, name)));
@@ -526,7 +526,7 @@ fn into_expr(mut self) -> P<ast::Expr> {
             };
 
             let lname = self.ecx.ident_of(format!("__arg{}",
-                                                  *name)[]);
+                                                  *name).index(&FullRange));
             pats.push(self.ecx.pat_ident(e.span, lname));
             names[self.name_positions[*name]] =
                 Some(Context::format_arg(self.ecx, e.span, arg_ty,
@@ -606,8 +606,8 @@ fn format_arg(ecx: &ExtCtxt, sp: Span,
                   -> P<ast::Expr> {
         let trait_ = match *ty {
             Known(ref tyname) => {
-                match tyname[] {
-                    ""  => "Show",
+                match tyname.index(&FullRange) {
+                    ""  => "String",
                     "?" => "Show",
                     "e" => "LowerExp",
                     "E" => "UpperExp",
@@ -619,7 +619,7 @@ fn format_arg(ecx: &ExtCtxt, sp: Span,
                     _ => {
                         ecx.span_err(sp,
                                      format!("unknown format trait `{}`",
-                                             *tyname)[]);
+                                             *tyname).index(&FullRange));
                         "Dummy"
                     }
                 }
@@ -710,7 +710,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span,
     }
     if !parser.errors.is_empty() {
         cx.ecx.span_err(cx.fmtsp, format!("invalid format string: {}",
-                                          parser.errors.remove(0))[]);
+                                          parser.errors.remove(0)).index(&FullRange));
         return DummyResult::raw_expr(sp);
     }
     if !cx.literal.is_empty() {
index 4075b208f787399d2b8b74e577d09da141188dba..bebd803ac4f862e55681bb542dc512a3055a1619 100644 (file)
@@ -66,7 +66,7 @@ pub fn apply_mark(m: Mrk, ctxt: SyntaxContext) -> SyntaxContext {
 /// Extend a syntax context with a given mark and sctable (explicit memoization)
 fn apply_mark_internal(m: Mrk, ctxt: SyntaxContext, table: &SCTable) -> SyntaxContext {
     let key = (ctxt, m);
-    * table.mark_memo.borrow_mut().entry(&key).get().unwrap_or_else(
+    * table.mark_memo.borrow_mut().entry(key).get().unwrap_or_else(
           |vacant_entry|
               vacant_entry.insert(idx_push(&mut *table.table.borrow_mut(), Mark(m, ctxt))))
 }
@@ -84,7 +84,7 @@ fn apply_rename_internal(id: Ident,
                        table: &SCTable) -> SyntaxContext {
     let key = (ctxt, id, to);
 
-    * table.rename_memo.borrow_mut().entry(&key).get().unwrap_or_else(
+    * table.rename_memo.borrow_mut().entry(key).get().unwrap_or_else(
           |vacant_entry|
               vacant_entry.insert(idx_push(&mut *table.table.borrow_mut(), Rename(id, to, ctxt))))
 }
@@ -121,7 +121,7 @@ fn new_sctable_internal() -> SCTable {
 pub fn display_sctable(table: &SCTable) {
     error!("SC table:");
     for (idx,val) in table.table.borrow().iter().enumerate() {
-        error!("{:4} : {}",idx,val);
+        error!("{:4} : {:?}",idx,val);
     }
 }
 
@@ -223,7 +223,7 @@ pub fn marksof(ctxt: SyntaxContext, stopname: Name) -> Vec<Mrk> {
 }
 
 // the internal function for computing marks
-// it's not clear to me whether it's better to use a [] mutable
+// it's not clear to me whether it's better to use a .index(&FullRange) mutable
 // vector or a cons-list for this.
 fn marksof_internal(ctxt: SyntaxContext,
                     stopname: Name,
index f1b52fa33c386a3bd439ad9b9c2e9e4f0ed308c4..77aea0c370af0001790a4ff2154cc9059ee2fd6f 100644 (file)
@@ -273,13 +273,13 @@ fn to_source_with_hygiene(&self) -> String {
         );
     }
 
-    impl_to_source_int! { signed, int, TyI }
+    impl_to_source_int! { signed, int, TyIs }
     impl_to_source_int! { signed, i8,  TyI8 }
     impl_to_source_int! { signed, i16, TyI16 }
     impl_to_source_int! { signed, i32, TyI32 }
     impl_to_source_int! { signed, i64, TyI64 }
 
-    impl_to_source_int! { unsigned, uint, TyU }
+    impl_to_source_int! { unsigned, uint, TyUs }
     impl_to_source_int! { unsigned, u8,   TyU8 }
     impl_to_source_int! { unsigned, u16,  TyU16 }
     impl_to_source_int! { unsigned, u32,  TyU32 }
@@ -473,7 +473,7 @@ pub fn expand_quote_stmt(cx: &mut ExtCtxt,
 }
 
 fn ids_ext(strs: Vec<String> ) -> Vec<ast::Ident> {
-    strs.iter().map(|str| str_to_ident((*str)[])).collect()
+    strs.iter().map(|str| str_to_ident((*str).index(&FullRange))).collect()
 }
 
 fn id_ext(str: &str) -> ast::Ident {
@@ -675,7 +675,7 @@ fn mk_tt(cx: &ExtCtxt, tt: &ast::TokenTree) -> Vec<P<ast::Stmt>> {
             for i in range(0, tt.len()) {
                 seq.push(tt.get_tt(i));
             }
-            mk_tts(cx, seq[])
+            mk_tts(cx, seq.index(&FullRange))
         }
         ast::TtToken(sp, ref tok) => {
             let e_sp = cx.expr_ident(sp, id_ext("_sp"));
@@ -764,7 +764,7 @@ fn expand_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     let stmt_let_tt = cx.stmt_let(sp, true, id_ext("tt"), cx.expr_vec_ng(sp));
 
     let mut vector = vec!(stmt_let_sp, stmt_let_tt);
-    vector.extend(mk_tts(cx, tts[]).into_iter());
+    vector.extend(mk_tts(cx, tts.index(&FullRange)).into_iter());
     let block = cx.expr_block(
         cx.block_all(sp,
                      Vec::new(),
index a49df457cb35ba21ad42758ed38c71419ac35f7c..1ba91dd371c60ed39b2cab2205e2925effa71848 100644 (file)
@@ -57,7 +57,7 @@ pub fn expand_file(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
 
     let topmost = cx.original_span_in_file();
     let loc = cx.codemap().lookup_char_pos(topmost.lo);
-    let filename = token::intern_and_get_ident(loc.file.name[]);
+    let filename = token::intern_and_get_ident(loc.file.name.index(&FullRange));
     base::MacExpr::new(cx.expr_str(topmost, filename))
 }
 
@@ -65,7 +65,7 @@ pub fn expand_stringify(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                         -> Box<base::MacResult+'static> {
     let s = pprust::tts_to_string(tts);
     base::MacExpr::new(cx.expr_str(sp,
-                                   token::intern_and_get_ident(s[])))
+                                   token::intern_and_get_ident(s.index(&FullRange))))
 }
 
 pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
@@ -78,7 +78,7 @@ pub fn expand_mod(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
                    .connect("::");
     base::MacExpr::new(cx.expr_str(
             sp,
-            token::intern_and_get_ident(string[])))
+            token::intern_and_get_ident(string.index(&FullRange))))
 }
 
 /// include! : parse the given file as an expr
@@ -135,9 +135,9 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     let bytes = match File::open(&file).read_to_end() {
         Err(e) => {
             cx.span_err(sp,
-                        format!("couldn't read {}: {}",
+                        format!("couldn't read {:?}: {}",
                                 file.display(),
-                                e)[]);
+                                e).index(&FullRange));
             return DummyResult::expr(sp);
         }
         Ok(bytes) => bytes,
@@ -146,16 +146,16 @@ pub fn expand_include_str(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
         Ok(src) => {
             // Add this input file to the code map to make it available as
             // dependency information
-            let filename = file.display().to_string();
-            let interned = token::intern_and_get_ident(src[]);
+            let filename = format!("{:?}", file.display());
+            let interned = token::intern_and_get_ident(src.index(&FullRange));
             cx.codemap().new_filemap(filename, src);
 
             base::MacExpr::new(cx.expr_str(sp, interned))
         }
         Err(_) => {
             cx.span_err(sp,
-                        format!("{} wasn't a utf-8 file",
-                                file.display())[]);
+                        format!("{:?} wasn't a utf-8 file",
+                                file.display()).index(&FullRange));
             return DummyResult::expr(sp);
         }
     }
@@ -177,7 +177,7 @@ pub fn expand_include_bytes(cx: &mut ExtCtxt, sp: Span, tts: &[ast::TokenTree])
     match File::open(&file).read_to_end() {
         Err(e) => {
             cx.span_err(sp,
-                        format!("couldn't read {}: {}", file.display(), e)[]);
+                        format!("couldn't read {:?}: {}", file.display(), e).index(&FullRange));
             return DummyResult::expr(sp);
         }
         Ok(bytes) => {
index 1438d152554955662f84513ac87f50fd2f2871ea..d33d03bbfa97eb7aa0d9dc794b4feeafa131a623 100644 (file)
@@ -153,7 +153,7 @@ pub fn count_names(ms: &[TokenTree]) -> uint {
                 seq.num_captures
             }
             &TtDelimited(_, ref delim) => {
-                count_names(delim.tts[])
+                count_names(delim.tts.index(&FullRange))
             }
             &TtToken(_, MatchNt(..)) => {
                 1
@@ -165,7 +165,7 @@ pub fn count_names(ms: &[TokenTree]) -> uint {
 
 pub fn initial_matcher_pos(ms: Rc<Vec<TokenTree>>, sep: Option<Token>, lo: BytePos)
                            -> Box<MatcherPos> {
-    let match_idx_hi = count_names(ms[]);
+    let match_idx_hi = count_names(ms.index(&FullRange));
     let matches: Vec<_> = range(0, match_idx_hi).map(|_| Vec::new()).collect();
     box MatcherPos {
         stack: vec![],
@@ -219,7 +219,7 @@ fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>],
                 }
             }
             &TtToken(sp, MatchNt(bind_name, _, _, _)) => {
-                match ret_val.entry(&bind_name) {
+                match ret_val.entry(bind_name) {
                     Vacant(spot) => {
                         spot.insert(res[*idx].clone());
                         *idx += 1;
@@ -229,7 +229,7 @@ fn n_rec(p_s: &ParseSess, m: &TokenTree, res: &[Rc<NamedMatch>],
                         p_s.span_diagnostic
                            .span_fatal(sp,
                                        format!("duplicated bind name: {}",
-                                               string.get())[])
+                                               string.get()).index(&FullRange))
                     }
                 }
             }
@@ -254,13 +254,13 @@ pub fn parse_or_else(sess: &ParseSess,
                      rdr: TtReader,
                      ms: Vec<TokenTree> )
                      -> HashMap<Ident, Rc<NamedMatch>> {
-    match parse(sess, cfg, rdr, ms[]) {
+    match parse(sess, cfg, rdr, ms.index(&FullRange)) {
         Success(m) => m,
         Failure(sp, str) => {
-            sess.span_diagnostic.span_fatal(sp, str[])
+            sess.span_diagnostic.span_fatal(sp, str.index(&FullRange))
         }
         Error(sp, str) => {
-            sess.span_diagnostic.span_fatal(sp, str[])
+            sess.span_diagnostic.span_fatal(sp, str.index(&FullRange))
         }
     }
 }
@@ -341,7 +341,7 @@ pub fn parse(sess: &ParseSess,
                         // Only touch the binders we have actually bound
                         for idx in range(ei.match_lo, ei.match_hi) {
                             let sub = (ei.matches[idx]).clone();
-                            new_pos.matches[idx]
+                            (&mut new_pos.matches[idx])
                                    .push(Rc::new(MatchedSeq(sub, mk_sp(ei.sp_lo,
                                                                        sp.hi))));
                         }
@@ -386,7 +386,7 @@ pub fn parse(sess: &ParseSess,
                             new_ei.idx += 1u;
                             //we specifically matched zero repeats.
                             for idx in range(ei.match_cur, ei.match_cur + seq.num_captures) {
-                                new_ei.matches[idx].push(Rc::new(MatchedSeq(Vec::new(), sp)));
+                                (&mut new_ei.matches[idx]).push(Rc::new(MatchedSeq(vec![], sp)));
                             }
 
                             cur_eis.push(new_ei);
@@ -444,10 +444,10 @@ pub fn parse(sess: &ParseSess,
         if token_name_eq(&tok, &token::Eof) {
             if eof_eis.len() == 1u {
                 let mut v = Vec::new();
-                for dv in eof_eis[0].matches.iter_mut() {
+                for dv in (&mut eof_eis[0]).matches.iter_mut() {
                     v.push(dv.pop().unwrap());
                 }
-                return Success(nameize(sess, ms, v[]));
+                return Success(nameize(sess, ms, v.index(&FullRange)));
             } else if eof_eis.len() > 1u {
                 return Error(sp, "ambiguity: multiple successful parses".to_string());
             } else {
@@ -486,7 +486,7 @@ pub fn parse(sess: &ParseSess,
                   TtToken(_, MatchNt(_, name, _, _)) => {
                     let name_string = token::get_ident(name);
                     let match_cur = ei.match_cur;
-                    ei.matches[match_cur].push(Rc::new(MatchedNonterminal(
+                    (&mut ei.matches[match_cur]).push(Rc::new(MatchedNonterminal(
                         parse_nt(&mut rust_parser, name_string.get()))));
                     ei.idx += 1u;
                     ei.match_cur += 1;
@@ -506,6 +506,17 @@ pub fn parse(sess: &ParseSess,
 }
 
 pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
+    match name {
+        "tt" => {
+            p.quote_depth += 1u; //but in theory, non-quoted tts might be useful
+            let res = token::NtTT(P(p.parse_token_tree()));
+            p.quote_depth -= 1u;
+            return res;
+        }
+        _ => {}
+    }
+    // check at the beginning and the parser checks after each bump
+    p.check_unknown_macro_variable();
     match name {
       "item" => match p.parse_item(Vec::new()) {
         Some(i) => token::NtItem(i),
@@ -522,21 +533,15 @@ pub fn parse_nt(p: &mut Parser, name: &str) -> Nonterminal {
         _ => {
             let token_str = pprust::token_to_string(&p.token);
             p.fatal((format!("expected ident, found {}",
-                             token_str[]))[])
+                             token_str.index(&FullRange))).index(&FullRange))
         }
       },
       "path" => {
         token::NtPath(box p.parse_path(LifetimeAndTypesWithoutColons))
       }
       "meta" => token::NtMeta(p.parse_meta_item()),
-      "tt" => {
-        p.quote_depth += 1u; //but in theory, non-quoted tts might be useful
-        let res = token::NtTT(P(p.parse_token_tree()));
-        p.quote_depth -= 1u;
-        res
-      }
       _ => {
-          p.fatal(format!("unsupported builtin nonterminal parser: {}", name)[])
+          p.fatal(format!("unsupported builtin nonterminal parser: {}", name).index(&FullRange))
       }
     }
 }
index 9837c8088fa4507a38f6ec9a523384009787d53c..64c53e298efe62208d9e623ce7248f3d1d9a2e67 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
 //
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use ast::{Ident, TtDelimited, TtSequence, TtToken};
+use ast::{TokenTree, TtDelimited, TtSequence, TtToken};
 use ast;
 use codemap::{Span, DUMMY_SP};
 use ext::base::{ExtCtxt, MacResult, SyntaxExtension};
 use ext::tt::macro_parser::{Success, Error, Failure};
 use ext::tt::macro_parser::{NamedMatch, MatchedSeq, MatchedNonterminal};
 use ext::tt::macro_parser::{parse, parse_or_else};
-use parse::lexer::new_tt_reader;
+use parse::lexer::{new_tt_reader, new_tt_reader_with_doc_flag};
 use parse::parser::Parser;
 use parse::attr::ParserAttr;
-use parse::token::{special_idents, gensym_ident};
-use parse::token::{MatchNt, NtTT};
+use parse::token::{special_idents, gensym_ident, NtTT, Token};
+use parse::token::Token::*;
 use parse::token;
 use print;
 use ptr::P;
@@ -52,7 +52,7 @@ fn ensure_complete_parse(&self, allow_semi: bool) {
                                following",
                               token_str);
             let span = parser.span;
-            parser.span_err(span, msg[]);
+            parser.span_err(span, msg.index(&FullRange));
         }
     }
 }
@@ -109,8 +109,8 @@ fn make_stmt(self: Box<ParserAnyMacro<'a>>) -> Option<P<ast::Stmt>> {
 }
 
 struct MacroRulesMacroExpander {
-    name: Ident,
-    imported_from: Option<Ident>,
+    name: ast::Ident,
+    imported_from: Option<ast::Ident>,
     lhses: Vec<Rc<NamedMatch>>,
     rhses: Vec<Rc<NamedMatch>>,
 }
@@ -126,16 +126,16 @@ fn expand<'cx>(&self,
                           self.name,
                           self.imported_from,
                           arg,
-                          self.lhses[],
-                          self.rhses[])
+                          self.lhses.index(&FullRange),
+                          self.rhses.index(&FullRange))
     }
 }
 
 /// Given `lhses` and `rhses`, this is the new macro we create
 fn generic_extension<'cx>(cx: &'cx ExtCtxt,
                           sp: Span,
-                          name: Ident,
-                          imported_from: Option<Ident>,
+                          name: ast::Ident,
+                          imported_from: Option<ast::Ident>,
                           arg: &[ast::TokenTree],
                           lhses: &[Rc<NamedMatch>],
                           rhses: &[Rc<NamedMatch>])
@@ -154,17 +154,17 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
         match **lhs {
           MatchedNonterminal(NtTT(ref lhs_tt)) => {
             let lhs_tt = match **lhs_tt {
-                TtDelimited(_, ref delim) => delim.tts[],
+                TtDelimited(_, ref delim) => delim.tts.index(&FullRange),
                 _ => cx.span_fatal(sp, "malformed macro lhs")
             };
             // `None` is because we're not interpolating
-            let mut arg_rdr = new_tt_reader(&cx.parse_sess().span_diagnostic,
-                                            None,
-                                            None,
-                                            arg.iter()
-                                               .map(|x| (*x).clone())
-                                               .collect());
-            arg_rdr.desugar_doc_comments = true;
+            let arg_rdr = new_tt_reader_with_doc_flag(&cx.parse_sess().span_diagnostic,
+                                                      None,
+                                                      None,
+                                                      arg.iter()
+                                                         .map(|x| (*x).clone())
+                                                         .collect(),
+                                                      true);
             match parse(cx.parse_sess(), cx.cfg(), arg_rdr, lhs_tt) {
               Success(named_matches) => {
                 let rhs = match *rhses[i] {
@@ -183,7 +183,8 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
                                            Some(named_matches),
                                            imported_from,
                                            rhs);
-                let p = Parser::new(cx.parse_sess(), cx.cfg(), box trncbr);
+                let mut p = Parser::new(cx.parse_sess(), cx.cfg(), box trncbr);
+                p.check_unknown_macro_variable();
                 // Let the context choose how to interpret the result.
                 // Weird, but useful for X-macros.
                 return box ParserAnyMacro {
@@ -194,13 +195,13 @@ fn generic_extension<'cx>(cx: &'cx ExtCtxt,
                 best_fail_spot = sp;
                 best_fail_msg = (*msg).clone();
               },
-              Error(sp, ref msg) => cx.span_fatal(sp, msg[])
+              Error(sp, ref msg) => cx.span_fatal(sp, msg.index(&FullRange))
             }
           }
           _ => cx.bug("non-matcher found in parsed lhses")
         }
     }
-    cx.span_fatal(best_fail_spot, best_fail_msg[]);
+    cx.span_fatal(best_fail_spot, best_fail_msg.index(&FullRange));
 }
 
 // Note that macro-by-example's input is also matched against a token tree:
@@ -260,6 +261,10 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
         _ => cx.span_bug(def.span, "wrong-structured lhs")
     };
 
+    for lhs in lhses.iter() {
+        check_lhs_nt_follows(cx, &**lhs, def.span);
+    }
+
     let rhses = match *argument_map[rhs_nm] {
         MatchedSeq(ref s, _) => /* FIXME (#2543) */ (*s).clone(),
         _ => cx.span_bug(def.span, "wrong-structured rhs")
@@ -274,3 +279,181 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt,
 
     NormalTT(exp, Some(def.span))
 }
+
+fn check_lhs_nt_follows(cx: &mut ExtCtxt, lhs: &NamedMatch, sp: Span) {
+    // lhs is going to be like MatchedNonterminal(NtTT(TtDelimited(...))), where
+    // the entire lhs is those tts.
+    // if ever we get box/deref patterns, this could turn into an `if let
+    // &MatchedNonterminal(NtTT(box TtDelimited(...))) = lhs`
+    let matcher = match lhs {
+        &MatchedNonterminal(NtTT(ref inner)) => match &**inner {
+            &TtDelimited(_, ref tts) => tts.tts.as_slice(),
+            _ => cx.span_bug(sp, "wrong-structured lhs for follow check")
+        },
+        _ => cx.span_bug(sp, "wrong-structured lhs for follow check")
+    };
+
+    check_matcher(cx, matcher.iter(), &Eof);
+    // we don't abort on errors on rejection, the driver will do that for us
+    // after parsing/expansion. we can report every error in every macro this way.
+}
+
+// returns the last token that was checked, for TtSequence. this gets used later on.
+fn check_matcher<'a, I>(cx: &mut ExtCtxt, matcher: I, follow: &Token)
+-> Option<(Span, Token)> where I: Iterator<Item=&'a TokenTree> {
+    use print::pprust::token_to_string;
+
+    let mut last = None;
+
+    // 2. For each token T in M:
+    let mut tokens = matcher.peekable();
+    while let Some(token) = tokens.next() {
+        last = match *token {
+            TtToken(sp, MatchNt(ref name, ref frag_spec, _, _)) => {
+                // ii. If T is a simple NT, look ahead to the next token T' in
+                // M.
+                let next_token = match tokens.peek() {
+                    // If T' closes a complex NT, replace T' with F
+                    Some(&&TtToken(_, CloseDelim(_))) => follow.clone(),
+                    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());
+                        Eof
+                    },
+                    // die next iteration
+                    Some(&&TtDelimited(_, ref delim)) => delim.close_token(),
+                    // else, we're at the end of the macro or sequence
+                    None => follow.clone()
+                };
+
+                let tok = if let TtToken(_, ref tok) = *token { tok } else { unreachable!() };
+                // If T' is in the set FOLLOW(NT), continue. Else, reject.
+                match &next_token {
+                    &Eof => return Some((sp, tok.clone())),
+                    _ if is_in_follow(cx, &next_token, frag_spec.as_str()) => continue,
+                    next => {
+                        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());
+                        continue
+                    },
+                }
+            },
+            TtSequence(sp, ref seq) => {
+                // iii. Else, T is a complex NT.
+                match seq.separator {
+                    // If T has the form $(...)U+ or $(...)U* for some token U,
+                    // run the algorithm on the contents with F set to U. If it
+                    // accepts, continue, else, reject.
+                    Some(ref u) => {
+                        let last = check_matcher(cx, seq.tts.iter(), u);
+                        match last {
+                            // Since the delimiter isn't required after the last
+                            // repetition, make sure that the *next* token is
+                            // sane. This doesn't actually compute the FIRST of
+                            // the rest of the matcher yet, it only considers
+                            // single tokens and simple NTs. This is imprecise,
+                            // but conservatively correct.
+                            Some((span, tok)) => {
+                                let fol = match tokens.peek() {
+                                    Some(&&TtToken(_, ref tok)) => tok.clone(),
+                                    Some(&&TtDelimited(_, ref delim)) => delim.close_token(),
+                                    Some(_) => {
+                                        cx.span_err(sp, "sequence repetition followed by \
+                                                another sequence repetition, which is not allowed");
+                                        Eof
+                                    },
+                                    None => Eof
+                                };
+                                check_matcher(cx, Some(&TtToken(span, tok.clone())).into_iter(),
+                                              &fol)
+                            },
+                            None => last,
+                        }
+                    },
+                    // If T has the form $(...)+ or $(...)*, run the algorithm
+                    // on the contents with F set to the token following the
+                    // sequence. If it accepts, continue, else, reject.
+                    None => {
+                        let fol = match tokens.peek() {
+                            Some(&&TtToken(_, ref tok)) => tok.clone(),
+                            Some(&&TtDelimited(_, ref delim)) => delim.close_token(),
+                            Some(_) => {
+                                cx.span_err(sp, "sequence repetition followed by another \
+                                             sequence repetition, which is not allowed");
+                                Eof
+                            },
+                            None => Eof
+                        };
+                        check_matcher(cx, seq.tts.iter(), &fol)
+                    }
+                }
+            },
+            TtToken(..) => {
+                // i. If T is not an NT, continue.
+                continue
+            },
+            TtDelimited(_, ref tts) => {
+                // if we don't pass in that close delimiter, we'll incorrectly consider the matcher
+                // `{ $foo:ty }` as having a follow that isn't `RBrace`
+                check_matcher(cx, tts.tts.iter(), &tts.close_token())
+            }
+        }
+    }
+    last
+}
+
+fn is_in_follow(cx: &ExtCtxt, tok: &Token, frag: &str) -> bool {
+    if let &CloseDelim(_) = tok {
+        return true;
+    }
+
+    match frag {
+        "item" => {
+            // since items *must* be followed by either a `;` or a `}`, we can
+            // accept anything after them
+            true
+        },
+        "block" => {
+            // anything can follow block, the braces provide a easy boundary to
+            // maintain
+            true
+        },
+        "stmt" | "expr"  => {
+            match *tok {
+                FatArrow | Comma | Semi => true,
+                _ => false
+            }
+        },
+        "pat" => {
+            match *tok {
+                FatArrow | Comma | Eq => true,
+                _ => false
+            }
+        },
+        "path" | "ty" => {
+            match *tok {
+                Comma | FatArrow | Colon | Eq | Gt => true,
+                Ident(i, _) if i.as_str() == "as" => true,
+                _ => false
+            }
+        },
+        "ident" => {
+            // being a single token, idents are harmless
+            true
+        },
+        "meta" | "tt" => {
+            // being either a single token or a delimited sequence, tt is
+            // harmless
+            true
+        },
+        _ => cx.bug(format!("unrecognized builtin nonterminal {}",
+                            frag).as_slice()),
+    }
+}
index e4e6f5ac6b0f0f0c4953b6ab426eb8cb914d2e31..bc07c7f6cae4d18b3592fb002a992c18309558a9 100644 (file)
@@ -53,13 +53,28 @@ pub struct TtReader<'a> {
 }
 
 /// This can do Macro-By-Example transcription. On the other hand, if
-/// `src` contains no `TtSequence`s and `TtNonterminal`s, `interp` can (and
-/// should) be none.
+/// `src` contains no `TtSequence`s, `MatchNt`s or `SubstNt`s, `interp` can
+/// (and should) be None.
 pub fn new_tt_reader<'a>(sp_diag: &'a SpanHandler,
                          interp: Option<HashMap<Ident, Rc<NamedMatch>>>,
                          imported_from: Option<Ident>,
-                         src: Vec<ast::TokenTree> )
+                         src: Vec<ast::TokenTree>)
                          -> TtReader<'a> {
+    new_tt_reader_with_doc_flag(sp_diag, interp, imported_from, src, false)
+}
+
+/// The extra `desugar_doc_comments` flag enables reading doc comments
+/// like any other attribute which consists of `meta` and surrounding #[ ] tokens.
+///
+/// This can do Macro-By-Example transcription. On the other hand, if
+/// `src` contains no `TtSequence`s, `MatchNt`s or `SubstNt`s, `interp` can
+/// (and should) be None.
+pub fn new_tt_reader_with_doc_flag<'a>(sp_diag: &'a SpanHandler,
+                                       interp: Option<HashMap<Ident, Rc<NamedMatch>>>,
+                                       imported_from: Option<Ident>,
+                                       src: Vec<ast::TokenTree>,
+                                       desugar_doc_comments: bool)
+                                       -> TtReader<'a> {
     let mut r = TtReader {
         sp_diag: sp_diag,
         stack: vec!(TtFrame {
@@ -80,7 +95,7 @@ pub fn new_tt_reader<'a>(sp_diag: &'a SpanHandler,
         crate_name_next: None,
         repeat_idx: Vec::new(),
         repeat_len: Vec::new(),
-        desugar_doc_comments: false,
+        desugar_doc_comments: desugar_doc_comments,
         /* dummy values, never read: */
         cur_tok: token::Eof,
         cur_span: DUMMY_SP,
@@ -128,7 +143,7 @@ fn add(self, other: LockstepIterSize) -> LockstepIterSize {
                     let l_n = token::get_ident(l_id.clone());
                     let r_n = token::get_ident(r_id);
                     LisContradiction(format!("inconsistent lockstep iteration: \
-                                              '{}' has {} items, but '{}' has {}",
+                                              '{:?}' has {} items, but '{:?}' has {}",
                                               l_n, l_len, r_n, r_len).to_string())
                 }
             },
@@ -240,7 +255,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
                     }
                     LisContradiction(ref msg) => {
                         // FIXME #2887 blame macro invoker instead
-                        r.sp_diag.span_fatal(sp.clone(), msg[]);
+                        r.sp_diag.span_fatal(sp.clone(), msg.index(&FullRange));
                     }
                     LisConstraint(len, _) => {
                         if len == 0 {
@@ -266,18 +281,15 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
             }
             // FIXME #2887: think about span stuff here
             TtToken(sp, SubstNt(ident, namep)) => {
+                r.stack.last_mut().unwrap().idx += 1;
                 match lookup_cur_matched(r, ident) {
                     None => {
-                        r.stack.push(TtFrame {
-                            forest: TtToken(sp, SubstNt(ident, namep)),
-                            idx: 0,
-                            dotdotdoted: false,
-                            sep: None
-                        });
+                        r.cur_span = sp;
+                        r.cur_tok = SubstNt(ident, namep);
+                        return ret_val;
                         // this can't be 0 length, just like TtDelimited
                     }
                     Some(cur_matched) => {
-                        r.stack.last_mut().unwrap().idx += 1;
                         match *cur_matched {
                             // sidestep the interpolation tricks for ident because
                             // (a) idents can be in lots of places, so it'd be a pain
@@ -296,8 +308,8 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan {
                             MatchedSeq(..) => {
                                 r.sp_diag.span_fatal(
                                     r.cur_span, /* blame the macro writer */
-                                    format!("variable '{}' is still repeating at this depth",
-                                            token::get_ident(ident))[]);
+                                    format!("variable '{:?}' is still repeating at this depth",
+                                            token::get_ident(ident)).index(&FullRange));
                             }
                         }
                     }
index 0810d4ee93ac700cf5c650d7cc6fa983524b5935..f10113254de04f82ad10802b91e2437d0456a53a 100644 (file)
@@ -44,7 +44,7 @@
     ("non_ascii_idents", Active),
     ("thread_local", Active),
     ("link_args", Active),
-    ("phase", Active),  // NOTE(stage0): switch to Removed after next snapshot
+    ("phase", Removed),
     ("plugin_registrar", Active),
     ("log_syntax", Active),
     ("trace_macros", Active),
@@ -86,6 +86,9 @@
     // A way to temporarily opt out of the new orphan rules. This will *never* be accepted.
     ("old_orphan_check", Deprecated),
 
+    // A way to temporarily opt out of the new impl rules. This will *never* be accepted.
+    ("old_impl_check", Deprecated),
+
     // OIBIT specific features
     ("optin_builtin_traits", Active),
 
@@ -149,7 +152,7 @@ fn gate_feature(&self, feature: &str, span: Span, explain: &str) {
             self.span_handler.span_err(span, explain);
             self.span_handler.span_help(span, format!("add #![feature({})] to the \
                                                        crate attributes to enable",
-                                                      feature)[]);
+                                                      feature).index(&FullRange));
         }
     }
 
@@ -240,7 +243,7 @@ fn visit_item(&mut self, i: &ast::Item) {
         }
         match i.node {
             ast::ItemForeignMod(ref foreign_module) => {
-                if attr::contains_name(i.attrs[], "link_args") {
+                if attr::contains_name(i.attrs.index(&FullRange), "link_args") {
                     self.gate_feature("link_args", i.span,
                                       "the `link_args` attribute is not portable \
                                        across platforms, it is recommended to \
@@ -254,14 +257,14 @@ fn visit_item(&mut self, i: &ast::Item) {
             }
 
             ast::ItemFn(..) => {
-                if attr::contains_name(i.attrs[], "plugin_registrar") {
+                if attr::contains_name(i.attrs.index(&FullRange), "plugin_registrar") {
                     self.gate_feature("plugin_registrar", i.span,
                                       "compiler plugins are experimental and possibly buggy");
                 }
             }
 
             ast::ItemStruct(..) => {
-                if attr::contains_name(i.attrs[], "simd") {
+                if attr::contains_name(i.attrs.index(&FullRange), "simd") {
                     self.gate_feature("simd", i.span,
                                       "SIMD types are experimental and possibly buggy");
                 }
@@ -278,7 +281,7 @@ fn visit_item(&mut self, i: &ast::Item) {
                     _ => {}
                 }
 
-                if attr::contains_name(i.attrs[],
+                if attr::contains_name(i.attrs.as_slice(),
                                        "unsafe_destructor") {
                     self.gate_feature("unsafe_destructor",
                                       i.span,
@@ -287,13 +290,20 @@ fn visit_item(&mut self, i: &ast::Item) {
                                        removed in the future");
                 }
 
-                if attr::contains_name(i.attrs[],
+                if attr::contains_name(i.attrs.index(&FullRange),
                                        "old_orphan_check") {
                     self.gate_feature(
                         "old_orphan_check",
                         i.span,
                         "the new orphan check rules will eventually be strictly enforced");
                 }
+
+                if attr::contains_name(i.attrs.index(&FullRange),
+                                       "old_impl_check") {
+                    self.gate_feature("old_impl_check",
+                                      i.span,
+                                      "`#[old_impl_check]` will be removed in the future");
+                }
             }
 
             _ => {}
@@ -303,13 +313,14 @@ fn visit_item(&mut self, i: &ast::Item) {
     }
 
     fn visit_foreign_item(&mut self, i: &ast::ForeignItem) {
-        if attr::contains_name(i.attrs[], "linkage") {
+        if attr::contains_name(i.attrs.index(&FullRange), "linkage") {
             self.gate_feature("linkage", i.span,
                               "the `linkage` attribute is experimental \
                                and not portable across platforms")
         }
 
-        let links_to_llvm = match attr::first_attr_value_str_by_name(i.attrs[], "link_name") {
+        let links_to_llvm = match attr::first_attr_value_str_by_name(i.attrs.as_slice(),
+                                                                     "link_name") {
             Some(val) => val.get().starts_with("llvm."),
             _ => false
         };
index b7bfd346d506b96fffdfbbb0e535d273a0969255..9e14f9dd1eaae3a0209539edd8e1df3ecb43c0fe 100644 (file)
        html_root_url = "http://doc.rust-lang.org/nightly/")]
 
 #![allow(unknown_features)]
-#![feature(macro_rules, globs, default_type_params, phase, slicing_syntax)]
+#![feature(slicing_syntax)]
 #![feature(quote, unsafe_destructor)]
-#![feature(unboxed_closures)]
-#![feature(old_orphan_check)]
-#![feature(associated_types)]
 
 extern crate arena;
 extern crate fmt_macros;
 extern crate serialize;
 extern crate term;
 extern crate libc;
-
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
+#[macro_use] extern crate log;
 
 extern crate "serialize" as rustc_serialize; // used by deriving
 
index 2a27431a0868cff224bbf2a32e6514cf363749e1..707e540a17bfe7c51d5893d7bb9f0ab7d9d5a852 100644 (file)
@@ -82,31 +82,12 @@ fn from_iter<I: Iterator<Item=T>>(iter: I) -> OwnedSlice<T> {
     }
 }
 
-#[cfg(stage0)]
-impl<S: Encoder<E>, T: Encodable<S, E>, E> Encodable<S, E> for OwnedSlice<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-       self.as_slice().encode(s)
-    }
-}
-
-#[cfg(not(stage0))]
 impl<T: Encodable> Encodable for OwnedSlice<T> {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
        self.as_slice().encode(s)
     }
 }
 
-#[cfg(stage0)]
-impl<D: Decoder<E>, T: Decodable<D, E>, E> Decodable<D, E> for OwnedSlice<T> {
-    fn decode(d: &mut D) -> Result<OwnedSlice<T>, E> {
-        Ok(OwnedSlice::from_vec(match Decodable::decode(d) {
-            Ok(t) => t,
-            Err(e) => return Err(e)
-        }))
-    }
-}
-
-#[cfg(not(stage0))]
 impl<T: Decodable> Decodable for OwnedSlice<T> {
     fn decode<D: Decoder>(d: &mut D) -> Result<OwnedSlice<T>, D::Error> {
         Ok(OwnedSlice::from_vec(match Decodable::decode(d) {
index 41693d9d47a51d0cdd67ca2c692daffeadfb1708..4aad7f911dbb7a40f5506c72fdd2c47f8734413a 100644 (file)
@@ -32,7 +32,7 @@ impl<'a> ParserAttr for Parser<'a> {
     fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute> {
         let mut attrs: Vec<ast::Attribute> = Vec::new();
         loop {
-            debug!("parse_outer_attributes: self.token={}",
+            debug!("parse_outer_attributes: self.token={:?}",
                    self.token);
             match self.token {
               token::Pound => {
@@ -62,7 +62,7 @@ fn parse_outer_attributes(&mut self) -> Vec<ast::Attribute> {
     /// If permit_inner is true, then a leading `!` indicates an inner
     /// attribute
     fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute {
-        debug!("parse_attributes: permit_inner={} self.token={}",
+        debug!("parse_attributes: permit_inner={:?} self.token={:?}",
                permit_inner, self.token);
         let (span, value, mut style) = match self.token {
             token::Pound => {
@@ -92,7 +92,7 @@ fn parse_attribute(&mut self, permit_inner: bool) -> ast::Attribute {
             }
             _ => {
                 let token_str = self.this_token_to_string();
-                self.fatal(format!("expected `#`, found `{}`", token_str)[]);
+                self.fatal(format!("expected `#`, found `{}`", token_str).index(&FullRange));
             }
         };
 
index 0d5592b57b1d112d28936cb938ae818984613793..e7fc5aac9c772cb0b20bbe83a980185efb4ed724 100644 (file)
@@ -82,7 +82,7 @@ fn vertical_trim(lines: Vec<String> ) -> Vec<String> {
         while j > i && lines[j - 1].trim().is_empty() {
             j -= 1;
         }
-        return lines[i..j].iter().map(|x| (*x).clone()).collect();
+        return lines.index(&(i..j)).iter().map(|x| (*x).clone()).collect();
     }
 
     /// remove a "[ \t]*\*" block from each line, if possible
@@ -116,7 +116,7 @@ fn horizontal_trim(lines: Vec<String> ) -> Vec<String> {
 
         if can_trim {
             lines.iter().map(|line| {
-                line[i + 1..line.len()].to_string()
+                line.index(&((i + 1)..line.len())).to_string()
             }).collect()
         } else {
             lines
@@ -127,12 +127,12 @@ fn horizontal_trim(lines: Vec<String> ) -> Vec<String> {
     static ONLINERS: &'static [&'static str] = &["///!", "///", "//!", "//"];
     for prefix in ONLINERS.iter() {
         if comment.starts_with(*prefix) {
-            return comment[prefix.len()..].to_string();
+            return comment.index(&(prefix.len()..)).to_string();
         }
     }
 
     if comment.starts_with("/*") {
-        let lines = comment[3u..comment.len() - 2u]
+        let lines = comment.index(&(3u..(comment.len() - 2u)))
             .lines_any()
             .map(|s| s.to_string())
             .collect::<Vec<String> >();
@@ -187,7 +187,7 @@ fn read_line_comments(rdr: &mut StringReader, code_to_the_left: bool,
         let line = rdr.read_one_line_comment();
         debug!("{}", line);
         // Doc comments are not put in comments.
-        if is_doc_comment(line[]) {
+        if is_doc_comment(line.index(&FullRange)) {
             break;
         }
         lines.push(line);
@@ -224,10 +224,10 @@ fn all_whitespace(s: &str, col: CharPos) -> Option<uint> {
 fn trim_whitespace_prefix_and_push_line(lines: &mut Vec<String> ,
                                         s: String, col: CharPos) {
     let len = s.len();
-    let s1 = match all_whitespace(s[], col) {
+    let s1 = match all_whitespace(s.index(&FullRange), col) {
         Some(col) => {
             if col < len {
-                s[col..len].to_string()
+                s.index(&(col..len)).to_string()
             } else {
                 "".to_string()
             }
@@ -261,7 +261,7 @@ fn read_block_comment(rdr: &mut StringReader,
             rdr.bump();
             rdr.bump();
         }
-        if is_block_doc_comment(curr_line[]) {
+        if is_block_doc_comment(curr_line.index(&FullRange)) {
             return
         }
         assert!(!curr_line.contains_char('\n'));
index a50b97142c2ef1d98d23e38106d1d10759573b7e..153b18b876002f63754db142a91184b93eca2d03 100644 (file)
@@ -25,7 +25,7 @@
 use std::str;
 use std::string::CowString;
 
-pub use ext::tt::transcribe::{TtReader, new_tt_reader};
+pub use ext::tt::transcribe::{TtReader, new_tt_reader, new_tt_reader_with_doc_flag};
 
 pub mod comments;
 
@@ -111,7 +111,7 @@ fn is_eof(&self) -> bool {
     }
     fn next_token(&mut self) -> TokenAndSpan {
         let r = tt_next_token(self);
-        debug!("TtReader: r={}", r);
+        debug!("TtReader: r={:?}", r);
         r
     }
     fn fatal(&self, m: &str) -> ! {
@@ -196,7 +196,7 @@ fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char)
         let mut m = m.to_string();
         m.push_str(": ");
         for c in c.escape_default() { m.push(c) }
-        self.fatal_span_(from_pos, to_pos, m[]);
+        self.fatal_span_(from_pos, to_pos, m.index(&FullRange));
     }
 
     /// Report a lexical error spanning [`from_pos`, `to_pos`), appending an
@@ -205,7 +205,7 @@ fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) {
         let mut m = m.to_string();
         m.push_str(": ");
         for c in c.escape_default() { m.push(c) }
-        self.err_span_(from_pos, to_pos, m[]);
+        self.err_span_(from_pos, to_pos, m.index(&FullRange));
     }
 
     /// Report a lexical error spanning [`from_pos`, `to_pos`), appending the
@@ -214,8 +214,8 @@ fn fatal_span_verbose(&self, from_pos: BytePos, to_pos: BytePos, mut m: String)
         m.push_str(": ");
         let from = self.byte_offset(from_pos).to_uint();
         let to = self.byte_offset(to_pos).to_uint();
-        m.push_str(self.filemap.src[from..to]);
-        self.fatal_span_(from_pos, to_pos, m[]);
+        m.push_str(self.filemap.src.index(&(from..to)));
+        self.fatal_span_(from_pos, to_pos, m.index(&FullRange));
     }
 
     /// Advance peek_tok and peek_span to refer to the next token, and
@@ -256,13 +256,13 @@ pub fn with_str_from<T, F>(&self, start: BytePos, f: F) -> T where
     /// adjusted 1 towards each other (assumes that on either side there is a
     /// single-byte delimiter).
     pub fn name_from(&self, start: BytePos) -> ast::Name {
-        debug!("taking an ident from {} to {}", start, self.last_pos);
+        debug!("taking an ident from {:?} to {:?}", start, self.last_pos);
         self.with_str_from(start, token::intern)
     }
 
     /// As name_from, with an explicit endpoint.
     pub fn name_from_to(&self, start: BytePos, end: BytePos) -> ast::Name {
-        debug!("taking an ident from {} to {}", start, end);
+        debug!("taking an ident from {:?} to {:?}", start, end);
         self.with_str_from_to(start, end, token::intern)
     }
 
@@ -301,7 +301,7 @@ fn translate_crlf_(rdr: &StringReader, start: BytePos,
             while i < s.len() {
                 let str::CharRange { ch, next } = s.char_range_at(i);
                 if ch == '\r' {
-                    if j < i { buf.push_str(s[j..i]); }
+                    if j < i { buf.push_str(s.index(&(j..i))); }
                     j = next;
                     if next >= s.len() || s.char_at(next) != '\n' {
                         let pos = start + BytePos(i as u32);
@@ -311,7 +311,7 @@ fn translate_crlf_(rdr: &StringReader, start: BytePos,
                 }
                 i = next;
             }
-            if j < s.len() { buf.push_str(s[j..]); }
+            if j < s.len() { buf.push_str(s.index(&(j..))); }
             buf
         }
     }
@@ -496,7 +496,7 @@ fn scan_whitespace_or_comment(&mut self) -> Option<TokenAndSpan> {
             // for skipping over all "junk"
             '/' | '#' => {
                 let c = self.scan_comment();
-                debug!("scanning a comment {}", c);
+                debug!("scanning a comment {:?}", c);
                 c
             },
             c if is_whitespace(Some(c)) => {
@@ -506,7 +506,7 @@ fn scan_whitespace_or_comment(&mut self) -> Option<TokenAndSpan> {
                     tok: token::Whitespace,
                     sp: codemap::mk_sp(start_bpos, self.last_pos)
                 });
-                debug!("scanning whitespace: {}", c);
+                debug!("scanning whitespace: {:?}", c);
                 c
             },
             _ => None
@@ -556,7 +556,7 @@ fn scan_block_comment(&mut self) -> Option<TokenAndSpan> {
                     self.translate_crlf(start_bpos, string,
                                         "bare CR not allowed in block doc-comment")
                 } else { string.into_cow() };
-                token::DocComment(token::intern(string[]))
+                token::DocComment(token::intern(string.index(&FullRange)))
             } else {
                 token::Comment
             };
@@ -592,8 +592,8 @@ fn bump_expecting_char<'a,D:fmt::Show>(r: &mut StringReader<'a>,
                                                whence: &str) {
             match r.curr {
                 Some(r_c) if r_c == c => r.bump(),
-                Some(r_c) => panic!("expected {}, hit {}, {}", described_c, r_c, whence),
-                None      => panic!("expected {}, hit EOF, {}", described_c, whence),
+                Some(r_c) => panic!("expected {:?}, hit {:?}, {}", described_c, r_c, whence),
+                None      => panic!("expected {:?}, hit EOF, {}", described_c, whence),
             }
         }
 
@@ -614,7 +614,7 @@ fn bump_expecting_char<'a,D:fmt::Show>(r: &mut StringReader<'a>,
         self.scan_digits(base);
         let encoded_name : u32 = self.with_str_from(start_bpos, |s| {
             num::from_str_radix(s, 10).unwrap_or_else(|| {
-                panic!("expected digits representing a name, got `{}`, {}, range [{},{}]",
+                panic!("expected digits representing a name, got {:?}, {}, range [{:?},{:?}]",
                       s, whence, start_bpos, self.last_pos);
             })
         });
@@ -632,7 +632,7 @@ fn bump_expecting_char<'a,D:fmt::Show>(r: &mut StringReader<'a>,
         self.scan_digits(base);
         let encoded_ctxt : ast::SyntaxContext = self.with_str_from(start_bpos, |s| {
             num::from_str_radix(s, 10).unwrap_or_else(|| {
-                panic!("expected digits representing a ctxt, got `{}`, {}", s, whence);
+                panic!("expected digits representing a ctxt, got {:?}, {}", s, whence);
             })
         });
 
@@ -652,7 +652,7 @@ fn scan_digits(&mut self, radix: uint) -> uint {
             if c == Some('_') { debug!("skipping a _"); self.bump(); continue; }
             match c.and_then(|cc| cc.to_digit(radix)) {
                 Some(_) => {
-                    debug!("{} in scan_digits", c);
+                    debug!("{:?} in scan_digits", c);
                     len += 1;
                     self.bump();
                 }
@@ -728,7 +728,7 @@ fn scan_hex_digits(&mut self,
                        delim: char,
                        below_0x7f_only: bool)
                        -> bool {
-        debug!("scanning {} digits until {}", n_digits, delim);
+        debug!("scanning {} digits until {:?}", n_digits, delim);
         let start_bpos = self.last_pos;
         let mut accum_int = 0;
 
@@ -990,7 +990,7 @@ fn next_token_inner(&mut self) -> token::Token {
         if is_dec_digit(c) {
             let num = self.scan_number(c.unwrap());
             let suffix = self.scan_optional_raw_name();
-            debug!("next_token_inner: scanned number {}, {}", num, suffix);
+            debug!("next_token_inner: scanned number {:?}, {:?}", num, suffix);
             return token::Literal(num, suffix)
         }
 
@@ -1110,7 +1110,7 @@ fn next_token_inner(&mut self) -> token::Token {
                 // expansion purposes. See #12512 for the gory details of why
                 // this is necessary.
                 let ident = self.with_str_from(start, |lifetime_name| {
-                    str_to_ident(format!("'{}", lifetime_name)[])
+                    str_to_ident(format!("'{}", lifetime_name).index(&FullRange))
                 });
 
                 // Conjure up a "keyword checking ident" to make sure that
@@ -1444,14 +1444,14 @@ fn in_range(c: Option<char>, lo: char, hi: char) -> bool {
 pub fn is_doc_comment(s: &str) -> bool {
     let res = (s.starts_with("///") && *s.as_bytes().get(3).unwrap_or(&b' ') != b'/')
               || s.starts_with("//!");
-    debug!("is `{}` a doc comment? {}", s, res);
+    debug!("is {:?} a doc comment? {}", s, res);
     res
 }
 
 pub fn is_block_doc_comment(s: &str) -> bool {
     let res = (s.starts_with("/**") && *s.as_bytes().get(3).unwrap_or(&b' ') != b'*')
               || s.starts_with("/*!");
-    debug!("is `{}` a doc comment? {}", s, res);
+    debug!("is {:?} a doc comment? {}", s, res);
     res
 }
 
index b0969a573e66b3cf35e1cb5a0573c079e85228de..d26b3af67bd47ae2e9f1ecb0abe72754459cddef 100644 (file)
@@ -24,8 +24,7 @@
 use std::str;
 use std::iter;
 
-#[cfg_attr(stage0, macro_escape)]
-#[cfg_attr(not(stage0), macro_use)]
+#[macro_use]
 pub mod parser;
 
 pub mod lexer;
@@ -254,19 +253,19 @@ pub fn file_to_filemap(sess: &ParseSess, path: &Path, spanopt: Option<Span>)
     let bytes = match File::open(path).read_to_end() {
         Ok(bytes) => bytes,
         Err(e) => {
-            err(format!("couldn't read {}: {}",
+            err(format!("couldn't read {:?}: {:?}",
                         path.display(),
-                        e)[]);
+                        e).index(&FullRange));
             unreachable!()
         }
     };
-    match str::from_utf8(bytes[]).ok() {
+    match str::from_utf8(bytes.index(&FullRange)).ok() {
         Some(s) => {
             return string_to_filemap(sess, s.to_string(),
                                      path.as_str().unwrap().to_string())
         }
         None => {
-            err(format!("{} is not UTF-8 encoded", path.display())[])
+            err(format!("{:?} is not UTF-8 encoded", path.display()).index(&FullRange))
         }
     }
     unreachable!()
@@ -297,7 +296,9 @@ pub fn tts_to_parser<'a>(sess: &'a ParseSess,
                          tts: Vec<ast::TokenTree>,
                          cfg: ast::CrateConfig) -> Parser<'a> {
     let trdr = lexer::new_tt_reader(&sess.span_diagnostic, None, None, tts);
-    Parser::new(sess, cfg, box trdr)
+    let mut p = Parser::new(sess, cfg, box trdr);
+    p.check_unknown_macro_variable();
+    p
 }
 
 // FIXME (Issue #16472): The `with_hygiene` mod should go away after
@@ -398,10 +399,10 @@ pub fn char_lit(lit: &str) -> (char, int) {
     }
 
     let msg = format!("lexer should have rejected a bad character escape {}", lit);
-    let msg2 = msg[];
+    let msg2 = msg.index(&FullRange);
 
     fn esc(len: uint, lit: &str) -> Option<(char, int)> {
-        num::from_str_radix(lit[2..len], 16)
+        num::from_str_radix(lit.index(&(2..len)), 16)
         .and_then(char::from_u32)
         .map(|x| (x, len as int))
     }
@@ -409,7 +410,7 @@ fn esc(len: uint, lit: &str) -> Option<(char, int)> {
     let unicode_escape = |&: | -> Option<(char, int)>
         if lit.as_bytes()[2] == b'{' {
             let idx = lit.find('}').expect(msg2);
-            let subslice = lit[3..idx];
+            let subslice = lit.index(&(3..idx));
             num::from_str_radix(subslice, 16)
                 .and_then(char::from_u32)
                 .map(|x| (x, subslice.chars().count() as int + 4))
@@ -471,7 +472,7 @@ fn eat<'a>(it: &mut iter::Peekable<(uint, char), str::CharIndices<'a>>) {
                             eat(&mut chars);
                         } else {
                             // otherwise, a normal escape
-                            let (c, n) = char_lit(lit[i..]);
+                            let (c, n) = char_lit(lit.index(&(i..)));
                             for _ in range(0, n - 1) { // we don't need to move past the first \
                                 chars.next();
                             }
@@ -534,12 +535,12 @@ pub fn raw_str_lit(lit: &str) -> String {
 fn looks_like_width_suffix(first_chars: &[char], s: &str) -> bool {
     s.len() > 1 &&
         first_chars.contains(&s.char_at(0)) &&
-        s[1..].chars().all(|c| '0' <= c && c <= '9')
+        s.index(&(1..)).chars().all(|c| '0' <= c && c <= '9')
 }
 
 fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
                       sd: &SpanHandler, sp: Span) -> ast::Lit_ {
-    debug!("filtered_float_lit: {}, {}", data, suffix);
+    debug!("filtered_float_lit: {}, {:?}", data, suffix);
     match suffix {
         Some("f32") => ast::LitFloat(data, ast::TyF32),
         Some("f64") => ast::LitFloat(data, ast::TyF64),
@@ -547,7 +548,7 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
             if suf.len() >= 2 && looks_like_width_suffix(&['f'], suf) {
                 // if it looks like a width, lets try to be helpful.
                 sd.span_err(sp, &*format!("illegal width `{}` for float literal, \
-                                          valid widths are 32 and 64", suf[1..]));
+                                          valid widths are 32 and 64", suf.index(&(1..))));
             } else {
                 sd.span_err(sp, &*format!("illegal suffix `{}` for float literal, \
                                           valid suffixes are `f32` and `f64`", suf));
@@ -559,7 +560,7 @@ fn filtered_float_lit(data: token::InternedString, suffix: Option<&str>,
     }
 }
 pub fn float_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) -> ast::Lit_ {
-    debug!("float_lit: {}, {}", s, suffix);
+    debug!("float_lit: {:?}, {:?}", s, suffix);
     // FIXME #2252: bounds checking float literals is defered until trans
     let s = s.chars().filter(|&c| c != '_').collect::<String>();
     let data = token::intern_and_get_ident(&*s);
@@ -583,7 +584,7 @@ pub fn byte_lit(lit: &str) -> (u8, uint) {
             b'\'' => b'\'',
             b'0' => b'\0',
             _ => {
-                match ::std::num::from_str_radix::<u64>(lit[2..4], 16) {
+                match ::std::num::from_str_radix::<u64>(lit.index(&(2..4)), 16) {
                     Some(c) =>
                         if c > 0xFF {
                             panic!(err(2))
@@ -633,7 +634,7 @@ fn eat<'a, I: Iterator<Item=(uint, u8)>>(it: &mut iter::Peekable<(uint, u8), I>)
                     }
                     _ => {
                         // otherwise, a normal escape
-                        let (c, n) = byte_lit(lit[i..]);
+                        let (c, n) = byte_lit(lit.index(&(i..)));
                         // we don't need to move past the first \
                         for _ in range(0, n - 1) {
                             chars.next();
@@ -662,9 +663,9 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
     // s can only be ascii, byte indexing is fine
 
     let s2 = s.chars().filter(|&c| c != '_').collect::<String>();
-    let mut s = s2[];
+    let mut s = s2.index(&FullRange);
 
-    debug!("integer_lit: {}, {}", s, suffix);
+    debug!("integer_lit: {}, {:?}", s, suffix);
 
     let mut base = 10;
     let orig = s;
@@ -695,18 +696,20 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
     }
 
     if base != 10 {
-        s = s[2..];
+        s = s.index(&(2..));
     }
 
     if let Some(suf) = suffix {
         if suf.is_empty() { sd.span_bug(sp, "found empty literal suffix in Some")}
         ty = match suf {
-            "i"   => ast::SignedIntLit(ast::TyI, ast::Plus),
+            "i"   => ast::SignedIntLit(ast::TyIs, ast::Plus),
+            "is"   => ast::SignedIntLit(ast::TyIs, ast::Plus),
             "i8"  => ast::SignedIntLit(ast::TyI8, ast::Plus),
             "i16" => ast::SignedIntLit(ast::TyI16, ast::Plus),
             "i32" => ast::SignedIntLit(ast::TyI32, ast::Plus),
             "i64" => ast::SignedIntLit(ast::TyI64, ast::Plus),
-            "u"   => ast::UnsignedIntLit(ast::TyU),
+            "u"   => ast::UnsignedIntLit(ast::TyUs),
+            "us"   => ast::UnsignedIntLit(ast::TyUs),
             "u8"  => ast::UnsignedIntLit(ast::TyU8),
             "u16" => ast::UnsignedIntLit(ast::TyU16),
             "u32" => ast::UnsignedIntLit(ast::TyU32),
@@ -717,7 +720,7 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
                 if looks_like_width_suffix(&['i', 'u'], suf) {
                     sd.span_err(sp, &*format!("illegal width `{}` for integer literal; \
                                               valid widths are 8, 16, 32 and 64",
-                                              suf[1..]));
+                                              suf.index(&(1..))));
                 } else {
                     sd.span_err(sp, &*format!("illegal suffix `{}` for numeric literal", suf));
                 }
@@ -727,8 +730,8 @@ pub fn integer_lit(s: &str, suffix: Option<&str>, sd: &SpanHandler, sp: Span) ->
         }
     }
 
-    debug!("integer_lit: the type is {}, base {}, the new string is {}, the original \
-           string was {}, the original suffix was {}", ty, base, s, orig, suffix);
+    debug!("integer_lit: the type is {:?}, base {:?}, the new string is {:?}, the original \
+           string was {:?}, the original suffix was {:?}", ty, base, s, orig, suffix);
 
     let res: u64 = match ::std::num::from_str_radix(s, base) {
         Some(r) => r,
@@ -815,7 +818,7 @@ fn sp(a: u32, b: u32) -> Span {
     #[test]
     fn string_to_tts_macro () {
         let tts = string_to_tts("macro_rules! zip (($a)=>($a))".to_string());
-        let tts: &[ast::TokenTree] = tts[];
+        let tts: &[ast::TokenTree] = tts.index(&FullRange);
         match tts {
             [ast::TtToken(_, token::Ident(name_macro_rules, token::Plain)),
              ast::TtToken(_, token::Not),
@@ -823,30 +826,30 @@ fn string_to_tts_macro () {
              ast::TtDelimited(_, ref macro_delimed)]
             if name_macro_rules.as_str() == "macro_rules"
             && name_zip.as_str() == "zip" => {
-                match macro_delimed.tts[] {
+                match macro_delimed.tts.index(&FullRange) {
                     [ast::TtDelimited(_, ref first_delimed),
                      ast::TtToken(_, token::FatArrow),
                      ast::TtDelimited(_, ref second_delimed)]
                     if macro_delimed.delim == token::Paren => {
-                        match first_delimed.tts[] {
+                        match first_delimed.tts.index(&FullRange) {
                             [ast::TtToken(_, token::Dollar),
                              ast::TtToken(_, token::Ident(name, token::Plain))]
                             if first_delimed.delim == token::Paren
                             && name.as_str() == "a" => {},
-                            _ => panic!("value 3: {}", **first_delimed),
+                            _ => panic!("value 3: {:?}", **first_delimed),
                         }
-                        match second_delimed.tts[] {
+                        match second_delimed.tts.index(&FullRange) {
                             [ast::TtToken(_, token::Dollar),
                              ast::TtToken(_, token::Ident(name, token::Plain))]
                             if second_delimed.delim == token::Paren
                             && name.as_str() == "a" => {},
-                            _ => panic!("value 4: {}", **second_delimed),
+                            _ => panic!("value 4: {:?}", **second_delimed),
                         }
                     },
-                    _ => panic!("value 2: {}", **macro_delimed),
+                    _ => panic!("value 2: {:?}", **macro_delimed),
                 }
             },
-            _ => panic!("value: {}",tts),
+            _ => panic!("value: {:?}",tts),
         }
     }
 
@@ -1113,24 +1116,24 @@ fn parser_done(p: Parser){
         let use_s = "use foo::bar::baz;";
         let vitem = string_to_view_item(use_s.to_string());
         let vitem_s = view_item_to_string(&vitem);
-        assert_eq!(vitem_s[], use_s);
+        assert_eq!(vitem_s.index(&FullRange), use_s);
 
         let use_s = "use foo::bar as baz;";
         let vitem = string_to_view_item(use_s.to_string());
         let vitem_s = view_item_to_string(&vitem);
-        assert_eq!(vitem_s[], use_s);
+        assert_eq!(vitem_s.index(&FullRange), use_s);
     }
 
     #[test] fn parse_extern_crate() {
         let ex_s = "extern crate foo;";
         let vitem = string_to_view_item(ex_s.to_string());
         let vitem_s = view_item_to_string(&vitem);
-        assert_eq!(vitem_s[], ex_s);
+        assert_eq!(vitem_s.index(&FullRange), ex_s);
 
         let ex_s = "extern crate \"foo\" as bar;";
         let vitem = string_to_view_item(ex_s.to_string());
         let vitem_s = view_item_to_string(&vitem);
-        assert_eq!(vitem_s[], ex_s);
+        assert_eq!(vitem_s.index(&FullRange), ex_s);
     }
 
     fn get_spans_of_pat_idents(src: &str) -> Vec<Span> {
@@ -1167,10 +1170,10 @@ fn visit_pat(&mut self, p: &'v ast::Pat) {
 
         for &src in srcs.iter() {
             let spans = get_spans_of_pat_idents(src);
-            let Span{lo:lo,hi:hi,..} = spans[0];
-            assert!("self" == src[lo.to_uint()..hi.to_uint()],
+            let Span{ lo, hi, .. } = spans[0];
+            assert!("self" == &src[lo.to_uint()..hi.to_uint()],
                     "\"{}\" != \"self\". src=\"{}\"",
-                    src[lo.to_uint()..hi.to_uint()], src)
+                    &src[lo.to_uint()..hi.to_uint()], src)
         }
     }
 
@@ -1209,7 +1212,7 @@ fn wb() -> c_int { O_WRONLY as c_int }
         let docs = item.attrs.iter().filter(|a| a.name().get() == "doc")
                     .map(|a| a.value_str().unwrap().get().to_string()).collect::<Vec<_>>();
         let b: &[_] = &["/// doc comment".to_string(), "/// line 2".to_string()];
-        assert_eq!(docs[], b);
+        assert_eq!(docs.index(&FullRange), b);
 
         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();
index a49680d7e1c0344a682098a6270ede9214650f4c..23728c74ae8b5542b175305a362d6ceec870f2eb 100644 (file)
@@ -127,13 +127,13 @@ fn report(&mut self,
               kind_str: &str,
               desc: &str) {
         self.span_err(sp,
-                      format!("obsolete syntax: {}", kind_str)[]);
+                      format!("obsolete syntax: {}", kind_str).index(&FullRange));
 
         if !self.obsolete_set.contains(&kind) {
             self.sess
                 .span_diagnostic
                 .handler()
-                .note(format!("{}", desc)[]);
+                .note(format!("{}", desc).index(&FullRange));
             self.obsolete_set.insert(kind);
         }
     }
index 83ee3219a966aacf6e9c4f8cb77eefffe3e1b5d2..9c16dbb2c5c0af0cc92abfe3c83038e9ff9b2fd3 100644 (file)
@@ -63,7 +63,7 @@
 use ast::{Visibility, WhereClause};
 use ast;
 use ast_util::{self, as_prec, ident_to_path, operator_prec};
-use codemap::{self, Span, BytePos, Spanned, spanned, mk_sp, DUMMY_SP};
+use codemap::{self, Span, BytePos, Spanned, spanned, mk_sp};
 use diagnostic;
 use ext::tt::macro_parser;
 use parse;
@@ -389,12 +389,12 @@ pub fn unexpected_last(&mut self, t: &token::Token) -> ! {
         let token_str = Parser::token_to_string(t);
         let last_span = self.last_span;
         self.span_fatal(last_span, format!("unexpected token: `{}`",
-                                                token_str)[]);
+                                                token_str).index(&FullRange));
     }
 
     pub fn unexpected(&mut self) -> ! {
         let this_token = self.this_token_to_string();
-        self.fatal(format!("unexpected token: `{}`", this_token)[]);
+        self.fatal(format!("unexpected token: `{}`", this_token).index(&FullRange));
     }
 
     /// Expect and consume the token t. Signal an error if
@@ -408,7 +408,7 @@ pub fn expect(&mut self, t: &token::Token) {
                 let this_token_str = self.this_token_to_string();
                 self.fatal(format!("expected `{}`, found `{}`",
                                    token_str,
-                                   this_token_str)[])
+                                   this_token_str).index(&FullRange))
             }
         } else {
             self.expect_one_of(slice::ref_slice(t), &[]);
@@ -449,7 +449,7 @@ fn tokens_to_string(tokens: &[TokenType]) -> String {
             expected.push_all(&*self.expected_tokens);
             expected.sort_by(|a, b| a.to_string().cmp(&b.to_string()));
             expected.dedup();
-            let expect = tokens_to_string(expected[]);
+            let expect = tokens_to_string(expected.index(&FullRange));
             let actual = self.this_token_to_string();
             self.fatal(
                 (if expected.len() != 1 {
@@ -460,7 +460,7 @@ fn tokens_to_string(tokens: &[TokenType]) -> String {
                     (format!("expected {}, found `{}`",
                              expect,
                              actual))
-                })[]
+                }).index(&FullRange)
             )
         }
     }
@@ -488,12 +488,12 @@ pub fn check_for_erroneous_unit_struct_expecting(&mut self, expected: &[token::T
     /// followed by some token from the set edible + inedible.  Recover
     /// from anticipated input errors, discarding erroneous characters.
     pub fn commit_expr(&mut self, e: &Expr, edible: &[token::Token], inedible: &[token::Token]) {
-        debug!("commit_expr {}", e);
+        debug!("commit_expr {:?}", e);
         if let ExprPath(..) = e.node {
             // might be unit-struct construction; check for recoverableinput error.
             let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
             expected.push_all(inedible);
-            self.check_for_erroneous_unit_struct_expecting(expected[]);
+            self.check_for_erroneous_unit_struct_expecting(expected.index(&FullRange));
         }
         self.expect_one_of(edible, inedible)
     }
@@ -510,9 +510,9 @@ pub fn commit_stmt(&mut self, edible: &[token::Token], inedible: &[token::Token]
                .as_ref()
                .map_or(false, |t| t.is_ident() || t.is_path()) {
             let mut expected = edible.iter().map(|x| x.clone()).collect::<Vec<_>>();
-            expected.push_all(inedible[]);
+            expected.push_all(inedible.index(&FullRange));
             self.check_for_erroneous_unit_struct_expecting(
-                expected[]);
+                expected.index(&FullRange));
         }
         self.expect_one_of(edible, inedible)
     }
@@ -535,7 +535,7 @@ pub fn parse_ident(&mut self) -> ast::Ident {
             _ => {
                 let token_str = self.this_token_to_string();
                 self.fatal((format!("expected ident, found `{}`",
-                                    token_str))[])
+                                    token_str)).index(&FullRange))
             }
         }
     }
@@ -593,7 +593,7 @@ pub fn expect_keyword(&mut self, kw: keywords::Keyword) {
             let id_interned_str = token::get_name(kw.to_name());
             let token_str = self.this_token_to_string();
             self.fatal(format!("expected `{}`, found `{}`",
-                               id_interned_str, token_str)[])
+                               id_interned_str, token_str).index(&FullRange))
         }
     }
 
@@ -604,7 +604,7 @@ pub fn check_strict_keywords(&mut self) {
             let span = self.span;
             self.span_err(span,
                           format!("expected identifier, found keyword `{}`",
-                                  token_str)[]);
+                                  token_str).index(&FullRange));
         }
     }
 
@@ -613,7 +613,7 @@ pub fn check_reserved_keywords(&mut self) {
         if self.token.is_reserved_keyword() {
             let token_str = self.this_token_to_string();
             self.fatal(format!("`{}` is a reserved keyword",
-                               token_str)[])
+                               token_str).index(&FullRange))
         }
     }
 
@@ -633,7 +633,7 @@ fn expect_and(&mut self) {
                     Parser::token_to_string(&token::BinOp(token::And));
                 self.fatal(format!("expected `{}`, found `{}`",
                                    found_token,
-                                   token_str)[])
+                                   token_str).index(&FullRange))
             }
         }
     }
@@ -654,7 +654,7 @@ fn expect_or(&mut self) {
                     Parser::token_to_string(&token::BinOp(token::Or));
                 self.fatal(format!("expected `{}`, found `{}`",
                                    token_str,
-                                   found_token)[])
+                                   found_token).index(&FullRange))
             }
         }
     }
@@ -697,7 +697,7 @@ fn expect_lt(&mut self) {
             let token_str = Parser::token_to_string(&token::Lt);
             self.fatal(format!("expected `{}`, found `{}`",
                                token_str,
-                               found_token)[])
+                               found_token).index(&FullRange))
         }
     }
 
@@ -749,7 +749,7 @@ pub fn expect_gt(&mut self) {
                 let this_token_str = self.this_token_to_string();
                 self.fatal(format!("expected `{}`, found `{}`",
                                    gt_str,
-                                   this_token_str)[])
+                                   this_token_str).index(&FullRange))
             }
         }
     }
@@ -946,6 +946,8 @@ pub fn bump(&mut self) {
         self.token = next.tok;
         self.tokens_consumed += 1u;
         self.expected_tokens.clear();
+        // check after each token
+        self.check_unknown_macro_variable();
     }
 
     /// Advance the parser by one token and return the bumped token.
@@ -1369,7 +1371,7 @@ pub fn parse_trait_items(&mut self) -> Vec<TraitItem> {
                     let (inner_attrs, body) =
                         p.parse_inner_attrs_and_block();
                     let mut attrs = attrs;
-                    attrs.push_all(inner_attrs[]);
+                    attrs.push_all(inner_attrs.index(&FullRange));
                     ProvidedMethod(P(ast::Method {
                         attrs: attrs,
                         id: ast::DUMMY_NODE_ID,
@@ -1388,7 +1390,7 @@ pub fn parse_trait_items(&mut self) -> Vec<TraitItem> {
                   _ => {
                       let token_str = p.this_token_to_string();
                       p.fatal((format!("expected `;` or `{{`, found `{}`",
-                                       token_str))[])
+                                       token_str)).index(&FullRange))
                   }
                 }
             }
@@ -1584,7 +1586,7 @@ pub fn parse_ty(&mut self) -> P<Ty> {
         } else {
             let this_token_str = self.this_token_to_string();
             let msg = format!("expected type, found `{}`", this_token_str);
-            self.fatal(msg[]);
+            self.fatal(msg.index(&FullRange));
         };
 
         let sp = mk_sp(lo, self.last_span.hi);
@@ -1726,14 +1728,14 @@ pub fn lit_from_token(&mut self, tok: &token::Token) -> Lit_ {
 
                     token::Str_(s) => {
                         (true,
-                         LitStr(token::intern_and_get_ident(parse::str_lit(s.as_str())[]),
+                         LitStr(token::intern_and_get_ident(parse::str_lit(s.as_str()).as_slice()),
                                 ast::CookedStr))
                     }
                     token::StrRaw(s, n) => {
                         (true,
                          LitStr(
                             token::intern_and_get_ident(
-                                parse::raw_str_lit(s.as_str())[]),
+                                parse::raw_str_lit(s.as_str()).index(&FullRange)),
                             ast::RawStr(n)))
                     }
                     token::Binary(i) =>
@@ -1977,7 +1979,7 @@ pub fn parse_lifetime(&mut self) -> ast::Lifetime {
                 };
             }
             _ => {
-                self.fatal(format!("expected a lifetime name")[]);
+                self.fatal(format!("expected a lifetime name").index(&FullRange));
             }
         }
     }
@@ -2015,7 +2017,7 @@ pub fn parse_lifetime_defs(&mut self) -> Vec<ast::LifetimeDef> {
                     let msg = format!("expected `,` or `>` after lifetime \
                                       name, found `{}`",
                                       this_token_str);
-                    self.fatal(msg[]);
+                    self.fatal(msg.index(&FullRange));
                 }
             }
         }
@@ -2103,22 +2105,6 @@ pub fn mk_index(&mut self, expr: P<Expr>, idx: P<Expr>) -> ast::Expr_ {
         ExprIndex(expr, idx)
     }
 
-    pub fn mk_slice(&mut self,
-                    expr: P<Expr>,
-                    start: Option<P<Expr>>,
-                    end: Option<P<Expr>>,
-                    _mutbl: Mutability)
-                    -> ast::Expr_ {
-        // FIXME: we could give more accurate span info here.
-        let (lo, hi) = match (&start, &end) {
-            (&Some(ref s), &Some(ref e)) => (s.span.lo, e.span.hi),
-            (&Some(ref s), &None) => (s.span.lo, s.span.hi),
-            (&None, &Some(ref e)) => (e.span.lo, e.span.hi),
-            (&None, &None) => (DUMMY_SP.lo, DUMMY_SP.hi),
-        };
-        ExprIndex(expr, self.mk_expr(lo, hi, ExprRange(start, end)))
-    }
-
     pub fn mk_range(&mut self,
                     start: Option<P<Expr>>,
                     end: Option<P<Expr>>)
@@ -2515,7 +2501,7 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
                     let last_span = self.last_span;
                     let fstr = n.as_str();
                     self.span_err(last_span,
-                                  format!("unexpected token: `{}`", n.as_str())[]);
+                                  format!("unexpected token: `{}`", n.as_str()).index(&FullRange));
                     if fstr.chars().all(|x| "0123456789.".contains_char(x)) {
                         let float = match fstr.parse::<f64>() {
                             Some(f) => f,
@@ -2524,7 +2510,7 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
                         self.span_help(last_span,
                             format!("try parenthesizing the first index; e.g., `(foo.{}){}`",
                                     float.trunc() as uint,
-                                    float.fract().to_string()[1..])[]);
+                                    float.fract().to_string().index(&(1..))).index(&FullRange));
                     }
                     self.abort_if_errors();
 
@@ -2550,87 +2536,44 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
               }
 
               // expr[...]
-              // Could be either an index expression or a slicing expression.
-              // Any slicing non-terminal can have a mutable version with `mut`
-              // after the opening square bracket.
+              // An index expression.
               token::OpenDelim(token::Bracket) => {
+                let bracket_pos = self.span.lo;
                 self.bump();
-                let mutbl = if self.eat_keyword(keywords::Mut) {
-                    MutMutable
+
+                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)) {
+                    // No expression, expand to a FullRange
+                    // FIXME(#20516) It would be better to use a lang item or
+                    // something for FullRange.
+                    hi = self.last_span.hi;
+                    let range = ExprStruct(ident_to_path(mk_sp(lo, hi),
+                                                         token::special_idents::FullRange),
+                                           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)
                 } else {
-                    MutImmutable
-                };
-                match self.token {
-                    // e[]
-                    token::CloseDelim(token::Bracket) => {
-                        self.bump();
-                        hi = self.span.hi;
-                        let slice = self.mk_slice(e, None, None, mutbl);
-                        e = self.mk_expr(lo, hi, slice)
-                    }
-                    // e[..e]
-                    token::DotDot => {
-                        self.bump();
-                        match self.token {
-                            // e[..]
-                            token::CloseDelim(token::Bracket) => {
-                                self.bump();
-                                hi = self.span.hi;
-                                let slice = self.mk_slice(e, None, None, mutbl);
-                                e = self.mk_expr(lo, hi, slice);
+                    let ix = self.parse_expr();
+                    hi = self.span.hi;
+                    self.commit_expr_expecting(&*ix, token::CloseDelim(token::Bracket));
+                    let index = self.mk_index(e, ix);
+                    e = self.mk_expr(lo, hi, index)
+                }
 
-                                self.span_err(e.span, "incorrect slicing expression: `[..]`");
-                                self.span_note(e.span,
-                                    "use `expr[]` to construct a slice of the whole of expr");
-                            }
-                            // e[..e]
-                            _ => {
-                                hi = self.span.hi;
-                                let e2 = self.parse_expr();
-                                self.commit_expr_expecting(&*e2, token::CloseDelim(token::Bracket));
-                                let slice = self.mk_slice(e, None, Some(e2), mutbl);
-                                e = self.mk_expr(lo, hi, slice)
-                            }
-                        }
-                    }
-                    // e[e] | e[e..] | e[e..e]
-                    _ => {
-                        let ix = self.parse_expr_res(RESTRICTION_NO_DOTS);
-                        match self.token {
-                            // e[e..] | e[e..e]
-                            token::DotDot => {
-                                self.bump();
-                                let e2 = match self.token {
-                                    // e[e..]
-                                    token::CloseDelim(token::Bracket) => {
-                                        self.bump();
-                                        None
-                                    }
-                                    // e[e..e]
-                                    _ => {
-                                        let e2 = self.parse_expr_res(RESTRICTION_NO_DOTS);
-                                        self.commit_expr_expecting(&*e2,
-                                            token::CloseDelim(token::Bracket));
-                                        Some(e2)
-                                    }
-                                };
-                                hi = self.span.hi;
-                                let slice = self.mk_slice(e, Some(ix), e2, mutbl);
-                                e = self.mk_expr(lo, hi, slice)
-                            }
-                            // e[e]
-                            _ => {
-                                if mutbl == ast::MutMutable {
-                                    self.span_err(e.span,
-                                                  "`mut` keyword is invalid in index expressions");
-                                }
-                                hi = self.span.hi;
-                                self.commit_expr_expecting(&*ix, token::CloseDelim(token::Bracket));
-                                let index = self.mk_index(e, ix);
-                                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");
                 }
               }
 
@@ -2655,6 +2598,70 @@ pub fn parse_dot_or_call_expr_with(&mut self, e0: P<Expr>) -> P<Expr> {
         return e;
     }
 
+    // Parse unquoted tokens after a `$` in a token tree
+    fn parse_unquoted(&mut self) -> TokenTree {
+        let mut sp = self.span;
+        let (name, namep) = match self.token {
+            token::Dollar => {
+                self.bump();
+
+                if self.token == token::OpenDelim(token::Paren) {
+                    let Spanned { node: seq, span: seq_span } = self.parse_seq(
+                        &token::OpenDelim(token::Paren),
+                        &token::CloseDelim(token::Paren),
+                        seq_sep_none(),
+                        |p| p.parse_token_tree()
+                    );
+                    let (sep, repeat) = self.parse_sep_and_kleene_op();
+                    let name_num = macro_parser::count_names(seq.as_slice());
+                    return TtSequence(mk_sp(sp.lo, seq_span.hi),
+                                      Rc::new(SequenceRepetition {
+                                          tts: seq,
+                                          separator: sep,
+                                          op: repeat,
+                                          num_captures: name_num
+                                      }));
+                } else if self.token.is_keyword_allow_following_colon(keywords::Crate) {
+                    self.bump();
+                    return TtToken(sp, SpecialVarNt(SpecialMacroVar::CrateMacroVar));
+                } else {
+                    sp = mk_sp(sp.lo, self.span.hi);
+                    let namep = match self.token { token::Ident(_, p) => p, _ => token::Plain };
+                    let name = self.parse_ident();
+                    (name, namep)
+                }
+            }
+            token::SubstNt(name, namep) => {
+                self.bump();
+                (name, namep)
+            }
+            _ => unreachable!()
+        };
+        // continue by trying to parse the `:ident` after `$name`
+        if self.token == token::Colon && self.look_ahead(1, |t| t.is_ident() &&
+                                                                !t.is_strict_keyword() &&
+                                                                !t.is_reserved_keyword()) {
+            self.bump();
+            sp = mk_sp(sp.lo, self.span.hi);
+            let kindp = match self.token { token::Ident(_, p) => p, _ => token::Plain };
+            let nt_kind = self.parse_ident();
+            TtToken(sp, MatchNt(name, nt_kind, namep, kindp))
+        } else {
+            TtToken(sp, SubstNt(name, namep))
+        }
+    }
+
+    pub fn check_unknown_macro_variable(&mut self) {
+        if self.quote_depth == 0u {
+            match self.token {
+                token::SubstNt(name, _) =>
+                    self.fatal(format!("unknown macro variable `{}`",
+                                       token::get_ident(name)).index(&FullRange)),
+                _ => {}
+            }
+        }
+    }
+
     /// Parse an optional separator followed by a Kleene-style
     /// repetition token (+ or *).
     pub fn parse_sep_and_kleene_op(&mut self) -> (Option<token::Token>, ast::KleeneOp) {
@@ -2701,63 +2708,25 @@ pub fn parse_token_tree(&mut self) -> TokenTree {
         fn parse_non_delim_tt_tok(p: &mut Parser) -> TokenTree {
             maybe_whole!(deref p, NtTT);
             match p.token {
-              token::CloseDelim(_) => {
-                  // This is a conservative error: only report the last unclosed delimiter. The
-                  // previous unclosed delimiters could actually be closed! The parser just hasn't
-                  // gotten to them yet.
-                  match p.open_braces.last() {
-                      None => {}
-                      Some(&sp) => p.span_note(sp, "unclosed delimiter"),
-                  };
-                  let token_str = p.this_token_to_string();
-                  p.fatal(format!("incorrect close delimiter: `{}`",
-                                  token_str)[])
-              },
-              /* we ought to allow different depths of unquotation */
-              token::Dollar if p.quote_depth > 0u => {
-                p.bump();
-                let sp = p.span;
-
-                if p.token == token::OpenDelim(token::Paren) {
-                    let seq = p.parse_seq(
-                        &token::OpenDelim(token::Paren),
-                        &token::CloseDelim(token::Paren),
-                        seq_sep_none(),
-                        |p| p.parse_token_tree()
-                    );
-                    let (sep, repeat) = p.parse_sep_and_kleene_op();
-                    let seq = match seq {
-                        Spanned { node, .. } => node,
+                token::CloseDelim(_) => {
+                    // This is a conservative error: only report the last unclosed delimiter. The
+                    // previous unclosed delimiters could actually be closed! The parser just hasn't
+                    // gotten to them yet.
+                    match p.open_braces.last() {
+                        None => {}
+                        Some(&sp) => p.span_note(sp, "unclosed delimiter"),
                     };
-                    let name_num = macro_parser::count_names(seq[]);
-                    TtSequence(mk_sp(sp.lo, p.span.hi),
-                               Rc::new(SequenceRepetition {
-                                   tts: seq,
-                                   separator: sep,
-                                   op: repeat,
-                                   num_captures: name_num
-                               }))
-                } else if p.token.is_keyword_allow_following_colon(keywords::Crate) {
-                    p.bump();
-                    TtToken(sp, SpecialVarNt(SpecialMacroVar::CrateMacroVar))
-                } else {
-                    // A nonterminal that matches or not
-                    let namep = match p.token { token::Ident(_, p) => p, _ => token::Plain };
-                    let name = p.parse_ident();
-                    if p.token == token::Colon && p.look_ahead(1, |t| t.is_ident()) {
-                        p.bump();
-                        let kindp = match p.token { token::Ident(_, p) => p, _ => token::Plain };
-                        let nt_kind = p.parse_ident();
-                        let m = TtToken(sp, MatchNt(name, nt_kind, namep, kindp));
-                        m
-                    } else {
-                        TtToken(sp, SubstNt(name, namep))
-                    }
+                    let token_str = p.this_token_to_string();
+                    p.fatal(format!("incorrect close delimiter: `{}`",
+                                    token_str).index(&FullRange))
+                },
+                /* we ought to allow different depths of unquotation */
+                token::Dollar | token::SubstNt(..) if p.quote_depth > 0u => {
+                    p.parse_unquoted()
+                }
+                _ => {
+                    TtToken(p.span, p.bump_and_get())
                 }
-              }
-              _ => {
-                  TtToken(p.span, p.bump_and_get())
-              }
             }
         }
 
@@ -2890,7 +2859,7 @@ pub fn parse_prefix_expr(&mut self) -> P<Expr> {
                         let this_token_to_string = self.this_token_to_string();
                         self.span_err(span,
                                       format!("expected expression, found `{}`",
-                                              this_token_to_string)[]);
+                                              this_token_to_string).index(&FullRange));
                         let box_span = mk_sp(lo, self.last_span.hi);
                         self.span_help(box_span,
                                        "perhaps you meant `box() (foo)` instead?");
@@ -3273,7 +3242,7 @@ fn parse_pat_fields(&mut self) -> (Vec<codemap::Spanned<ast::FieldPat>> , bool)
                 if self.token != token::CloseDelim(token::Brace) {
                     let token_str = self.this_token_to_string();
                     self.fatal(format!("expected `{}`, found `{}`", "}",
-                                       token_str)[])
+                                       token_str).index(&FullRange))
                 }
                 etc = true;
                 break;
@@ -3294,7 +3263,7 @@ fn parse_pat_fields(&mut self) -> (Vec<codemap::Spanned<ast::FieldPat>> , bool)
                     BindByRef(..) | BindByValue(MutMutable) => {
                         let token_str = self.this_token_to_string();
                         self.fatal(format!("unexpected `{}`",
-                                           token_str)[])
+                                           token_str).index(&FullRange))
                     }
                     _ => {}
                 }
@@ -3577,7 +3546,7 @@ fn parse_pat_ident(&mut self,
             let span = self.span;
             let tok_str = self.this_token_to_string();
             self.span_fatal(span,
-                            format!("expected identifier, found `{}`", tok_str)[]);
+                            format!("expected identifier, found `{}`", tok_str).index(&FullRange));
         }
         let ident = self.parse_ident();
         let last_span = self.last_span;
@@ -3674,7 +3643,7 @@ fn check_expected_item(p: &mut Parser, attrs: &[Attribute]) {
 
         let lo = self.span.lo;
         if self.token.is_keyword(keywords::Let) {
-            check_expected_item(self, item_attrs[]);
+            check_expected_item(self, item_attrs.index(&FullRange));
             self.expect_keyword(keywords::Let);
             let decl = self.parse_let();
             P(spanned(lo, decl.span.hi, StmtDecl(decl, ast::DUMMY_NODE_ID)))
@@ -3683,7 +3652,7 @@ fn check_expected_item(p: &mut Parser, attrs: &[Attribute]) {
             && self.look_ahead(1, |t| *t == token::Not) {
             // it's a macro invocation:
 
-            check_expected_item(self, item_attrs[]);
+            check_expected_item(self, item_attrs.index(&FullRange));
 
             // Potential trouble: if we allow macros with paths instead of
             // idents, we'd need to look ahead past the whole path here...
@@ -3711,7 +3680,7 @@ fn check_expected_item(p: &mut Parser, attrs: &[Attribute]) {
                     let tok_str = self.this_token_to_string();
                     self.fatal(format!("expected {}`(` or `{{`, found `{}`",
                                        ident_str,
-                                       tok_str)[])
+                                       tok_str).index(&FullRange))
                 },
             };
 
@@ -3759,7 +3728,7 @@ fn check_expected_item(p: &mut Parser, attrs: &[Attribute]) {
             }
         } else {
             let found_attrs = !item_attrs.is_empty();
-            let item_err = Parser::expected_item_err(item_attrs[]);
+            let item_err = Parser::expected_item_err(item_attrs.index(&FullRange));
             match self.parse_item_or_view_item(item_attrs, false) {
                 IoviItem(i) => {
                     let hi = i.span.hi;
@@ -3803,7 +3772,7 @@ pub fn parse_block(&mut self) -> P<Block> {
             let sp = self.span;
             let tok = self.this_token_to_string();
             self.span_fatal_help(sp,
-                                 format!("expected `{{`, found `{}`", tok)[],
+                                 format!("expected `{{`, found `{}`", tok).index(&FullRange),
                                  "place this code inside a block");
         }
 
@@ -3857,13 +3826,13 @@ fn parse_block_tail_(&mut self, lo: BytePos, s: BlockCheckMode,
         while self.token != token::CloseDelim(token::Brace) {
             // parsing items even when they're not allowed lets us give
             // better error messages and recover more gracefully.
-            attributes_box.push_all(self.parse_outer_attributes()[]);
+            attributes_box.push_all(self.parse_outer_attributes().index(&FullRange));
             match self.token {
                 token::Semi => {
                     if !attributes_box.is_empty() {
                         let last_span = self.last_span;
                         self.span_err(last_span,
-                                      Parser::expected_item_err(attributes_box[]));
+                                      Parser::expected_item_err(attributes_box.index(&FullRange)));
                         attributes_box = Vec::new();
                     }
                     self.bump(); // empty
@@ -3955,7 +3924,7 @@ fn parse_block_tail_(&mut self, lo: BytePos, s: BlockCheckMode,
         if !attributes_box.is_empty() {
             let last_span = self.last_span;
             self.span_err(last_span,
-                          Parser::expected_item_err(attributes_box[]));
+                          Parser::expected_item_err(attributes_box.index(&FullRange)));
         }
 
         let hi = self.span.hi;
@@ -4399,7 +4368,7 @@ fn expect_self_ident(&mut self) -> ast::Ident {
             _ => {
                 let token_str = self.this_token_to_string();
                 self.fatal(format!("expected `self`, found `{}`",
-                                   token_str)[])
+                                   token_str).index(&FullRange))
             }
         }
     }
@@ -4553,7 +4522,7 @@ macro_rules! parse_remaining_arguments {
                 _ => {
                     let token_str = self.this_token_to_string();
                     self.fatal(format!("expected `,` or `)`, found `{}`",
-                                       token_str)[])
+                                       token_str).index(&FullRange))
                 }
             }
             }
@@ -4729,7 +4698,7 @@ pub fn parse_method(&mut self,
                 let (inner_attrs, body) = self.parse_inner_attrs_and_block();
                 let body_span = body.span;
                 let mut new_attrs = attrs;
-                new_attrs.push_all(inner_attrs[]);
+                new_attrs.push_all(inner_attrs.index(&FullRange));
                 (ast::MethDecl(ident,
                                generics,
                                abi,
@@ -4948,7 +4917,7 @@ pub fn parse_record_struct_body(&mut self, class_name: &ast::Ident) -> Vec<Struc
             if fields.len() == 0 {
                 self.fatal(format!("unit-like struct definition should be \
                     written as `struct {};`",
-                    token::get_ident(class_name.clone()))[]);
+                    token::get_ident(class_name.clone())).index(&FullRange));
             }
 
             self.bump();
@@ -4956,7 +4925,7 @@ pub fn parse_record_struct_body(&mut self, class_name: &ast::Ident) -> Vec<Struc
             let token_str = self.this_token_to_string();
             self.fatal(format!("expected `where`, or `{}` after struct \
                                 name, found `{}`", "{",
-                                token_str)[]);
+                                token_str).index(&FullRange));
         }
 
         fields
@@ -4987,7 +4956,7 @@ pub fn parse_tuple_struct_body(&mut self,
             if fields.len() == 0 {
                 self.fatal(format!("unit-like struct definition should be \
                     written as `struct {};`",
-                    token::get_ident(class_name.clone()))[]);
+                    token::get_ident(class_name.clone())).index(&FullRange));
             }
 
             self.parse_where_clause(generics);
@@ -5002,7 +4971,7 @@ pub fn parse_tuple_struct_body(&mut self,
         } else {
             let token_str = self.this_token_to_string();
             self.fatal(format!("expected `where`, `{}`, `(`, or `;` after struct \
-                name, found `{}`", "{", token_str)[]);
+                name, found `{}`", "{", token_str).index(&FullRange));
         }
     }
 
@@ -5022,7 +4991,7 @@ pub fn parse_single_struct_field(&mut self,
                 let token_str = self.this_token_to_string();
                 self.span_fatal_help(span,
                                      format!("expected `,`, or `}}`, found `{}`",
-                                             token_str)[],
+                                             token_str).index(&FullRange),
                                      "struct fields should be separated by commas")
             }
         }
@@ -5109,11 +5078,11 @@ fn parse_mod_items(&mut self,
             let mut attrs = self.parse_outer_attributes();
             if first {
                 let mut tmp = attrs_remaining.clone();
-                tmp.push_all(attrs[]);
+                tmp.push_all(attrs.index(&FullRange));
                 attrs = tmp;
                 first = false;
             }
-            debug!("parse_mod_items: parse_item_or_view_item(attrs={})",
+            debug!("parse_mod_items: parse_item_or_view_item(attrs={:?})",
                    attrs);
             match self.parse_item_or_view_item(attrs,
                                                true /* macros allowed */) {
@@ -5126,7 +5095,7 @@ fn parse_mod_items(&mut self,
               _ => {
                   let token_str = self.this_token_to_string();
                   self.fatal(format!("expected item, found `{}`",
-                                     token_str)[])
+                                     token_str).index(&FullRange))
               }
             }
         }
@@ -5135,7 +5104,7 @@ fn parse_mod_items(&mut self,
             // We parsed attributes for the first item but didn't find it
             let last_span = self.last_span;
             self.span_err(last_span,
-                          Parser::expected_item_err(attrs_remaining[]));
+                          Parser::expected_item_err(attrs_remaining.index(&FullRange)));
         }
 
         ast::Mod {
@@ -5205,7 +5174,7 @@ fn eval_src_mod(&mut self,
                     -> (ast::Item_, Vec<ast::Attribute> ) {
         let mut prefix = Path::new(self.sess.span_diagnostic.cm.span_to_filename(self.span));
         prefix.pop();
-        let mod_path = Path::new(".").join_many(self.mod_path_stack[]);
+        let mod_path = Path::new(".").join_many(self.mod_path_stack.index(&FullRange));
         let dir_path = prefix.join(&mod_path);
         let mod_string = token::get_ident(id);
         let (file_path, owns_directory) = match ::attr::first_attr_value_str_by_name(
@@ -5215,8 +5184,8 @@ fn eval_src_mod(&mut self,
                 let mod_name = mod_string.get().to_string();
                 let default_path_str = format!("{}.rs", mod_name);
                 let secondary_path_str = format!("{}/mod.rs", mod_name);
-                let default_path = dir_path.join(default_path_str[]);
-                let secondary_path = dir_path.join(secondary_path_str[]);
+                let default_path = dir_path.join(default_path_str.index(&FullRange));
+                let secondary_path = dir_path.join(secondary_path_str.index(&FullRange));
                 let default_exists = default_path.exists();
                 let secondary_exists = secondary_path.exists();
 
@@ -5231,13 +5200,13 @@ fn eval_src_mod(&mut self,
                                    format!("maybe move this module `{0}` \
                                             to its own directory via \
                                             `{0}/mod.rs`",
-                                           this_module)[]);
+                                           this_module).index(&FullRange));
                     if default_exists || secondary_exists {
                         self.span_note(id_sp,
                                        format!("... or maybe `use` the module \
                                                 `{}` instead of possibly \
                                                 redeclaring it",
-                                               mod_name)[]);
+                                               mod_name).index(&FullRange));
                     }
                     self.abort_if_errors();
                 }
@@ -5248,12 +5217,12 @@ fn eval_src_mod(&mut self,
                     (false, false) => {
                         self.span_fatal_help(id_sp,
                                              format!("file not found for module `{}`",
-                                                     mod_name)[],
+                                                     mod_name).index(&FullRange),
                                              format!("name the file either {} or {} inside \
-                                                     the directory {}",
+                                                     the directory {:?}",
                                                      default_path_str,
                                                      secondary_path_str,
-                                                     dir_path.display())[]);
+                                                     dir_path.display()).index(&FullRange));
                     }
                     (true, true) => {
                         self.span_fatal_help(
@@ -5262,7 +5231,7 @@ fn eval_src_mod(&mut self,
                                      and {}",
                                     mod_name,
                                     default_path_str,
-                                    secondary_path_str)[],
+                                    secondary_path_str).index(&FullRange),
                             "delete or rename one of them to remove the ambiguity");
                     }
                 }
@@ -5284,11 +5253,11 @@ fn eval_src_mod_from_path(&mut self,
                 let mut err = String::from_str("circular modules: ");
                 let len = included_mod_stack.len();
                 for p in included_mod_stack.slice(i, len).iter() {
-                    err.push_str(p.display().as_cow()[]);
+                    err.push_str(p.display().as_cow().index(&FullRange));
                     err.push_str(" -> ");
                 }
-                err.push_str(path.display().as_cow()[]);
-                self.span_fatal(id_sp, err[]);
+                err.push_str(path.display().as_cow().index(&FullRange));
+                self.span_fatal(id_sp, err.index(&FullRange));
             }
             None => ()
         }
@@ -5369,7 +5338,7 @@ fn parse_foreign_mod_items(&mut self,
         if !attrs_remaining.is_empty() {
             let last_span = self.last_span;
             self.span_err(last_span,
-                          Parser::expected_item_err(attrs_remaining[]));
+                          Parser::expected_item_err(attrs_remaining.index(&FullRange)));
         }
         assert!(self.token == token::CloseDelim(token::Brace));
         ast::ForeignMod {
@@ -5410,7 +5379,7 @@ fn parse_item_extern_crate(&mut self,
                     self.span_help(span,
                                    format!("perhaps you meant to enclose the crate name `{}` in \
                                            a string?",
-                                          the_ident.as_str())[]);
+                                          the_ident.as_str()).index(&FullRange));
                     None
                 } else {
                     None
@@ -5436,7 +5405,7 @@ fn parse_item_extern_crate(&mut self,
                 self.span_fatal(span,
                                 format!("expected extern crate name but \
                                          found `{}`",
-                                        token_str)[]);
+                                        token_str).index(&FullRange));
             }
         };
 
@@ -5534,7 +5503,7 @@ fn parse_enum_def(&mut self, _generics: &ast::Generics) -> EnumDef {
                     self.span_err(start_span,
                         format!("unit-like struct variant should be written \
                                  without braces, as `{},`",
-                                token::get_ident(ident))[]);
+                                token::get_ident(ident)).index(&FullRange));
                 }
                 kind = StructVariantKind(struct_def);
             } else if self.check(&token::OpenDelim(token::Paren)) {
@@ -5619,7 +5588,7 @@ fn parse_opt_abi(&mut self) -> Option<abi::Abi> {
                             format!("illegal ABI: expected one of [{}], \
                                      found `{}`",
                                     abi::all_names().connect(", "),
-                                    the_string)[]);
+                                    the_string).index(&FullRange));
                         None
                     }
                 }
@@ -5681,7 +5650,7 @@ fn parse_item_or_view_item(&mut self,
                                  format!("`extern mod` is obsolete, use \
                                           `extern crate` instead \
                                           to refer to external \
-                                          crates.")[])
+                                          crates.").index(&FullRange))
                 }
                 return self.parse_item_extern_crate(lo, visibility, attrs);
             }
@@ -5709,7 +5678,7 @@ fn parse_item_or_view_item(&mut self,
             let token_str = self.this_token_to_string();
             self.span_fatal(span,
                             format!("expected `{}` or `fn`, found `{}`", "{",
-                                    token_str)[]);
+                                    token_str).index(&FullRange));
         }
 
         if self.eat_keyword(keywords::Virtual) {
@@ -5822,7 +5791,7 @@ fn parse_item_or_view_item(&mut self,
         if self.eat_keyword(keywords::Mod) {
             // MODULE ITEM
             let (ident, item_, extra_attrs) =
-                self.parse_item_mod(attrs[]);
+                self.parse_item_mod(attrs.index(&FullRange));
             let last_span = self.last_span;
             let item = self.mk_item(lo,
                                     last_span.hi,
@@ -6162,7 +6131,7 @@ fn parse_items_and_view_items(&mut self,
                                   macros_allowed: bool)
                                   -> ParsedItemsAndViewItems {
         let mut attrs = first_item_attrs;
-        attrs.push_all(self.parse_outer_attributes()[]);
+        attrs.push_all(self.parse_outer_attributes().index(&FullRange));
         // First, parse view items.
         let mut view_items : Vec<ast::ViewItem> = Vec::new();
         let mut items = Vec::new();
@@ -6244,7 +6213,7 @@ fn parse_foreign_items(&mut self, first_item_attrs: Vec<Attribute> ,
                            macros_allowed: bool)
         -> ParsedItemsAndViewItems {
         let mut attrs = first_item_attrs;
-        attrs.push_all(self.parse_outer_attributes()[]);
+        attrs.push_all(self.parse_outer_attributes().index(&FullRange));
         let mut foreign_items = Vec::new();
         loop {
             match self.parse_foreign_item(attrs, macros_allowed) {
index daaa4af89db6504f226fc629c32cb85adaada553..437867389103661e2af8bbc67b6cb9a3b3630265 100644 (file)
@@ -392,6 +392,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+
 // Get the first "argument"
 macro_rules! first {
     ( $first:expr, $( $remainder:expr, )* ) => ( $first )
@@ -479,7 +480,7 @@ fn mk_fresh_ident_interner() -> IdentInterner {
         $(init_vec.push($si_str);)*
         $(init_vec.push($sk_str);)*
         $(init_vec.push($rk_str);)*
-        interner::StrInterner::prefill(init_vec[])
+        interner::StrInterner::prefill(init_vec.index(&FullRange))
     }
 }}
 
@@ -515,66 +516,66 @@ pub mod special_idents {
         (9,                          unnamed_field,          "<unnamed_field>");
         (10,                         type_self,              "Self");
         (11,                         prelude_import,         "prelude_import");
+        (12,                         FullRange,              "FullRange");
     }
 
     pub mod keywords {
         // These ones are variants of the Keyword enum
 
         'strict:
-        (12,                         As,         "as");
-        (13,                         Break,      "break");
-        (14,                         Crate,      "crate");
-        (15,                         Else,       "else");
-        (16,                         Enum,       "enum");
-        (17,                         Extern,     "extern");
-        (18,                         False,      "false");
-        (19,                         Fn,         "fn");
-        (20,                         For,        "for");
-        (21,                         If,         "if");
-        (22,                         Impl,       "impl");
-        (23,                         In,         "in");
-        (24,                         Let,        "let");
-        (25,                         Loop,       "loop");
-        (26,                         Match,      "match");
-        (27,                         Mod,        "mod");
-        (28,                         Move,       "move");
-        (29,                         Mut,        "mut");
-        (30,                         Pub,        "pub");
-        (31,                         Ref,        "ref");
-        (32,                         Return,     "return");
+        (13,                         As,         "as");
+        (14,                         Break,      "break");
+        (15,                         Crate,      "crate");
+        (16,                         Else,       "else");
+        (17,                         Enum,       "enum");
+        (18,                         Extern,     "extern");
+        (19,                         False,      "false");
+        (20,                         Fn,         "fn");
+        (21,                         For,        "for");
+        (22,                         If,         "if");
+        (23,                         Impl,       "impl");
+        (24,                         In,         "in");
+        (25,                         Let,        "let");
+        (26,                         Loop,       "loop");
+        (27,                         Match,      "match");
+        (28,                         Mod,        "mod");
+        (29,                         Move,       "move");
+        (30,                         Mut,        "mut");
+        (31,                         Pub,        "pub");
+        (32,                         Ref,        "ref");
+        (33,                         Return,     "return");
         // Static and Self are also special idents (prefill de-dupes)
         (super::STATIC_KEYWORD_NAME_NUM, Static, "static");
         (super::SELF_KEYWORD_NAME_NUM,   Self,   "self");
-        (33,                         Struct,     "struct");
+        (34,                         Struct,     "struct");
         (super::SUPER_KEYWORD_NAME_NUM, Super,   "super");
-        (34,                         True,       "true");
-        (35,                         Trait,      "trait");
-        (36,                         Type,       "type");
-        (37,                         Unsafe,     "unsafe");
-        (38,                         Use,        "use");
-        (39,                         Virtual,    "virtual");
-        (40,                         While,      "while");
-        (41,                         Continue,   "continue");
-        (42,                         Proc,       "proc");
-        (43,                         Box,        "box");
-        (44,                         Const,      "const");
-        (45,                         Where,      "where");
-
+        (35,                         True,       "true");
+        (36,                         Trait,      "trait");
+        (37,                         Type,       "type");
+        (38,                         Unsafe,     "unsafe");
+        (39,                         Use,        "use");
+        (40,                         Virtual,    "virtual");
+        (41,                         While,      "while");
+        (42,                         Continue,   "continue");
+        (43,                         Proc,       "proc");
+        (44,                         Box,        "box");
+        (45,                         Const,      "const");
+        (46,                         Where,      "where");
         'reserved:
-        (46,                         Alignof,    "alignof");
-        (47,                         Be,         "be");
-        (48,                         Offsetof,   "offsetof");
-        (49,                         Priv,       "priv");
-        (50,                         Pure,       "pure");
-        (51,                         Sizeof,     "sizeof");
-        (52,                         Typeof,     "typeof");
-        (53,                         Unsized,    "unsized");
-        (54,                         Yield,      "yield");
-        (55,                         Do,         "do");
-        (56,                         Abstract,   "abstract");
-        (57,                         Final,      "final");
-        (58,                         Override,   "override");
-        (59,                         Macro,      "macro");
+        (47,                         Alignof,    "alignof");
+        (48,                         Be,         "be");
+        (49,                         Offsetof,   "offsetof");
+        (50,                         Priv,       "priv");
+        (51,                         Pure,       "pure");
+        (52,                         Sizeof,     "sizeof");
+        (53,                         Typeof,     "typeof");
+        (54,                         Unsized,    "unsized");
+        (55,                         Yield,      "yield");
+        (56,                         Do,         "do");
+        (57,                         Abstract,   "abstract");
+        (58,                         Final,      "final");
+        (59,                         Override,   "override");
+        (60,                         Macro,      "macro");
     }
 }
 
@@ -628,7 +629,7 @@ fn new_from_rc_str(string: RcStr) -> InternedString {
 
     #[inline]
     pub fn get<'a>(&'a self) -> &'a str {
-        self.string[]
+        self.string.index(&FullRange)
     }
 }
 
@@ -652,59 +653,47 @@ fn container_as_bytes<'a>(&'a self) -> &'a [u8] {
 
 impl fmt::Show for InternedString {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", self.string[])
+        fmt::String::fmt(self, f)
+    }
+}
+
+impl fmt::String for InternedString {
+    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+        write!(f, "{}", self.string.index(&FullRange))
     }
 }
 
 impl<'a> PartialEq<&'a str> for InternedString {
     #[inline(always)]
     fn eq(&self, other: & &'a str) -> bool {
-        PartialEq::eq(self.string[], *other)
+        PartialEq::eq(self.string.index(&FullRange), *other)
     }
     #[inline(always)]
     fn ne(&self, other: & &'a str) -> bool {
-        PartialEq::ne(self.string[], *other)
+        PartialEq::ne(self.string.index(&FullRange), *other)
     }
 }
 
 impl<'a> PartialEq<InternedString > for &'a str {
     #[inline(always)]
     fn eq(&self, other: &InternedString) -> bool {
-        PartialEq::eq(*self, other.string[])
+        PartialEq::eq(*self, other.string.index(&FullRange))
     }
     #[inline(always)]
     fn ne(&self, other: &InternedString) -> bool {
-        PartialEq::ne(*self, other.string[])
+        PartialEq::ne(*self, other.string.index(&FullRange))
     }
 }
 
-#[cfg(stage0)]
-impl<D:Decoder<E>, E> Decodable<D, E> for InternedString {
-    fn decode(d: &mut D) -> Result<InternedString, E> {
-        Ok(get_name(get_ident_interner().intern(
-                    try!(d.read_str())[])))
-    }
-}
-
-#[cfg(not(stage0))]
 impl Decodable for InternedString {
     fn decode<D: Decoder>(d: &mut D) -> Result<InternedString, D::Error> {
-        Ok(get_name(get_ident_interner().intern(
-                    try!(d.read_str())[])))
-    }
-}
-
-#[cfg(stage0)]
-impl<S:Encoder<E>, E> Encodable<S, E> for InternedString {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        s.emit_str(self.string[])
+        Ok(get_name(get_ident_interner().intern(try!(d.read_str()).index(&FullRange))))
     }
 }
 
-#[cfg(not(stage0))]
 impl Encodable for InternedString {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
-        s.emit_str(self.string[])
+        s.emit_str(self.string.index(&FullRange))
     }
 }
 
index 11cefc8719bab768119788414d5368302941e95d..52306075c21ec37740b3a57bb095b3c0b092d645 100644 (file)
@@ -140,7 +140,7 @@ pub fn buf_str(toks: Vec<Token>,
         }
         s.push_str(format!("{}={}",
                            szs[i],
-                           tok_str(toks[i].clone()))[]);
+                           tok_str(toks[i].clone())).index(&FullRange));
         i += 1u;
         i %= n;
     }
@@ -602,7 +602,7 @@ pub fn print(&mut self, x: Token, l: int) -> io::IoResult<()> {
             assert_eq!(l, len);
             // assert!(l <= space);
             self.space -= len;
-            self.print_str(s[])
+            self.print_str(s.index(&FullRange))
           }
           Eof => {
             // Eof should never get here.
index 402583b60fae5387e6c89055f875408341539c5e..87dcc9e70f46184491034f334fd9a9374cb72cb8 100644 (file)
@@ -114,7 +114,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
                                       out,
                                       ann,
                                       is_expanded);
-    try!(s.print_mod(&krate.module, krate.attrs[]));
+    try!(s.print_mod(&krate.module, krate.attrs.index(&FullRange)));
     try!(s.print_remaining_comments());
     eof(&mut s.s)
 }
@@ -580,7 +580,7 @@ pub fn break_offset_if_not_bol(&mut self, n: uint,
     pub fn synth_comment(&mut self, text: String) -> IoResult<()> {
         try!(word(&mut self.s, "/*"));
         try!(space(&mut self.s));
-        try!(word(&mut self.s, text[]));
+        try!(word(&mut self.s, text.index(&FullRange)));
         try!(space(&mut self.s));
         word(&mut self.s, "*/")
     }
@@ -685,7 +685,7 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> {
             }
             ast::TyTup(ref elts) => {
                 try!(self.popen());
-                try!(self.commasep(Inconsistent, elts[],
+                try!(self.commasep(Inconsistent, elts.index(&FullRange),
                                    |s, ty| s.print_type(&**ty)));
                 if elts.len() == 1 {
                     try!(word(&mut self.s, ","));
@@ -721,10 +721,10 @@ pub fn print_type(&mut self, ty: &ast::Ty) -> IoResult<()> {
             }
             ast::TyObjectSum(ref ty, ref bounds) => {
                 try!(self.print_type(&**ty));
-                try!(self.print_bounds("+", bounds[]));
+                try!(self.print_bounds("+", bounds.index(&FullRange)));
             }
             ast::TyPolyTraitRef(ref bounds) => {
-                try!(self.print_bounds("", bounds[]));
+                try!(self.print_bounds("", bounds.index(&FullRange)));
             }
             ast::TyQPath(ref qpath) => {
                 try!(word(&mut self.s, "<"));
@@ -759,7 +759,7 @@ pub fn print_foreign_item(&mut self,
                               item: &ast::ForeignItem) -> IoResult<()> {
         try!(self.hardbreak_if_not_bol());
         try!(self.maybe_print_comment(item.span.lo));
-        try!(self.print_outer_attributes(item.attrs[]));
+        try!(self.print_outer_attributes(item.attrs.index(&FullRange)));
         match item.node {
             ast::ForeignItemFn(ref decl, ref generics) => {
                 try!(self.print_fn(&**decl, None, abi::Rust, item.ident, generics,
@@ -770,7 +770,7 @@ pub fn print_foreign_item(&mut self,
             }
             ast::ForeignItemStatic(ref t, m) => {
                 try!(self.head(visibility_qualified(item.vis,
-                                                    "static")[]));
+                                                    "static").index(&FullRange)));
                 if m {
                     try!(self.word_space("mut"));
                 }
@@ -787,7 +787,7 @@ pub fn print_foreign_item(&mut self,
     fn print_associated_type(&mut self, typedef: &ast::AssociatedType)
                              -> IoResult<()>
     {
-        try!(self.print_outer_attributes(typedef.attrs[]));
+        try!(self.print_outer_attributes(typedef.attrs.index(&FullRange)));
         try!(self.word_space("type"));
         try!(self.print_ty_param(&typedef.ty_param));
         word(&mut self.s, ";")
@@ -806,12 +806,12 @@ fn print_typedef(&mut self, typedef: &ast::Typedef) -> IoResult<()> {
     pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
         try!(self.hardbreak_if_not_bol());
         try!(self.maybe_print_comment(item.span.lo));
-        try!(self.print_outer_attributes(item.attrs[]));
+        try!(self.print_outer_attributes(item.attrs.index(&FullRange)));
         try!(self.ann.pre(self, NodeItem(item)));
         match item.node {
             ast::ItemStatic(ref ty, m, ref expr) => {
                 try!(self.head(visibility_qualified(item.vis,
-                                                    "static")[]));
+                                                    "static").index(&FullRange)));
                 if m == ast::MutMutable {
                     try!(self.word_space("mut"));
                 }
@@ -828,7 +828,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
             }
             ast::ItemConst(ref ty, ref expr) => {
                 try!(self.head(visibility_qualified(item.vis,
-                                                    "const")[]));
+                                                    "const").index(&FullRange)));
                 try!(self.print_ident(item.ident));
                 try!(self.word_space(":"));
                 try!(self.print_type(&**ty));
@@ -851,29 +851,29 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
                     item.vis
                 ));
                 try!(word(&mut self.s, " "));
-                try!(self.print_block_with_attrs(&**body, item.attrs[]));
+                try!(self.print_block_with_attrs(&**body, item.attrs.index(&FullRange)));
             }
             ast::ItemMod(ref _mod) => {
                 try!(self.head(visibility_qualified(item.vis,
-                                                    "mod")[]));
+                                                    "mod").index(&FullRange)));
                 try!(self.print_ident(item.ident));
                 try!(self.nbsp());
                 try!(self.bopen());
-                try!(self.print_mod(_mod, item.attrs[]));
+                try!(self.print_mod(_mod, item.attrs.index(&FullRange)));
                 try!(self.bclose(item.span));
             }
             ast::ItemForeignMod(ref nmod) => {
                 try!(self.head("extern"));
-                try!(self.word_nbsp(nmod.abi.to_string()[]));
+                try!(self.word_nbsp(nmod.abi.to_string().index(&FullRange)));
                 try!(self.bopen());
-                try!(self.print_foreign_mod(nmod, item.attrs[]));
+                try!(self.print_foreign_mod(nmod, item.attrs.index(&FullRange)));
                 try!(self.bclose(item.span));
             }
             ast::ItemTy(ref ty, ref params) => {
                 try!(self.ibox(indent_unit));
                 try!(self.ibox(0u));
                 try!(self.word_nbsp(visibility_qualified(item.vis,
-                                                         "type")[]));
+                                                         "type").index(&FullRange)));
                 try!(self.print_ident(item.ident));
                 try!(self.print_generics(params));
                 try!(self.end()); // end the inner ibox
@@ -895,7 +895,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
                 ));
             }
             ast::ItemStruct(ref struct_def, ref generics) => {
-                try!(self.head(visibility_qualified(item.vis,"struct")[]));
+                try!(self.head(visibility_qualified(item.vis,"struct").index(&FullRange)));
                 try!(self.print_struct(&**struct_def, generics, item.ident, item.span));
             }
 
@@ -936,7 +936,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
 
                 try!(space(&mut self.s));
                 try!(self.bopen());
-                try!(self.print_inner_attributes(item.attrs[]));
+                try!(self.print_inner_attributes(item.attrs.index(&FullRange)));
                 for impl_item in impl_items.iter() {
                     match *impl_item {
                         ast::MethodImplItem(ref meth) => {
@@ -967,7 +967,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
                         real_bounds.push(b);
                     }
                 }
-                try!(self.print_bounds(":", real_bounds[]));
+                try!(self.print_bounds(":", real_bounds.index(&FullRange)));
                 try!(self.print_where_clause(generics));
                 try!(word(&mut self.s, " "));
                 try!(self.bopen());
@@ -985,7 +985,7 @@ pub fn print_item(&mut self, item: &ast::Item) -> IoResult<()> {
                 try!(self.print_ident(item.ident));
                 try!(self.cbox(indent_unit));
                 try!(self.popen());
-                try!(self.print_tts(tts[]));
+                try!(self.print_tts(tts.index(&FullRange)));
                 try!(self.pclose());
                 try!(word(&mut self.s, ";"));
                 try!(self.end());
@@ -1019,12 +1019,12 @@ pub fn print_enum_def(&mut self, enum_definition: &ast::EnumDef,
                           generics: &ast::Generics, ident: ast::Ident,
                           span: codemap::Span,
                           visibility: ast::Visibility) -> IoResult<()> {
-        try!(self.head(visibility_qualified(visibility, "enum")[]));
+        try!(self.head(visibility_qualified(visibility, "enum").index(&FullRange)));
         try!(self.print_ident(ident));
         try!(self.print_generics(generics));
         try!(self.print_where_clause(generics));
         try!(space(&mut self.s));
-        self.print_variants(enum_definition.variants[], span)
+        self.print_variants(enum_definition.variants.index(&FullRange), span)
     }
 
     pub fn print_variants(&mut self,
@@ -1034,7 +1034,7 @@ pub fn print_variants(&mut self,
         for v in variants.iter() {
             try!(self.space_if_not_bol());
             try!(self.maybe_print_comment(v.span.lo));
-            try!(self.print_outer_attributes(v.node.attrs[]));
+            try!(self.print_outer_attributes(v.node.attrs.index(&FullRange)));
             try!(self.ibox(indent_unit));
             try!(self.print_variant(&**v));
             try!(word(&mut self.s, ","));
@@ -1062,7 +1062,7 @@ pub fn print_struct(&mut self,
             if !struct_def.fields.is_empty() {
                 try!(self.popen());
                 try!(self.commasep(
-                    Inconsistent, struct_def.fields[],
+                    Inconsistent, struct_def.fields.index(&FullRange),
                     |s, field| {
                         match field.node.kind {
                             ast::NamedField(..) => panic!("unexpected named field"),
@@ -1092,7 +1092,7 @@ pub fn print_struct(&mut self,
                     ast::NamedField(ident, visibility) => {
                         try!(self.hardbreak_if_not_bol());
                         try!(self.maybe_print_comment(field.span.lo));
-                        try!(self.print_outer_attributes(field.node.attrs[]));
+                        try!(self.print_outer_attributes(field.node.attrs.index(&FullRange)));
                         try!(self.print_visibility(visibility));
                         try!(self.print_ident(ident));
                         try!(self.word_nbsp(":"));
@@ -1116,7 +1116,7 @@ pub fn print_struct(&mut self,
     pub fn print_tt(&mut self, tt: &ast::TokenTree) -> IoResult<()> {
         match *tt {
             ast::TtToken(_, ref tk) => {
-                try!(word(&mut self.s, token_to_string(tk)[]));
+                try!(word(&mut self.s, token_to_string(tk).index(&FullRange)));
                 match *tk {
                     parse::token::DocComment(..) => {
                         hardbreak(&mut self.s)
@@ -1125,11 +1125,11 @@ pub fn print_tt(&mut self, tt: &ast::TokenTree) -> IoResult<()> {
                 }
             }
             ast::TtDelimited(_, ref delimed) => {
-                try!(word(&mut self.s, token_to_string(&delimed.open_token())[]));
+                try!(word(&mut self.s, token_to_string(&delimed.open_token()).index(&FullRange)));
                 try!(space(&mut self.s));
-                try!(self.print_tts(delimed.tts[]));
+                try!(self.print_tts(delimed.tts.index(&FullRange)));
                 try!(space(&mut self.s));
-                word(&mut self.s, token_to_string(&delimed.close_token())[])
+                word(&mut self.s, token_to_string(&delimed.close_token()).index(&FullRange))
             },
             ast::TtSequence(_, ref seq) => {
                 try!(word(&mut self.s, "$("));
@@ -1139,7 +1139,7 @@ pub fn print_tt(&mut self, tt: &ast::TokenTree) -> IoResult<()> {
                 try!(word(&mut self.s, ")"));
                 match seq.separator {
                     Some(ref tk) => {
-                        try!(word(&mut self.s, token_to_string(tk)[]));
+                        try!(word(&mut self.s, token_to_string(tk).index(&FullRange)));
                     }
                     None => {},
                 }
@@ -1170,7 +1170,7 @@ pub fn print_variant(&mut self, v: &ast::Variant) -> IoResult<()> {
                 if !args.is_empty() {
                     try!(self.popen());
                     try!(self.commasep(Consistent,
-                                       args[],
+                                       args.index(&FullRange),
                                        |s, arg| s.print_type(&*arg.ty)));
                     try!(self.pclose());
                 }
@@ -1194,7 +1194,7 @@ pub fn print_variant(&mut self, v: &ast::Variant) -> IoResult<()> {
     pub fn print_ty_method(&mut self, m: &ast::TypeMethod) -> IoResult<()> {
         try!(self.hardbreak_if_not_bol());
         try!(self.maybe_print_comment(m.span.lo));
-        try!(self.print_outer_attributes(m.attrs[]));
+        try!(self.print_outer_attributes(m.attrs.index(&FullRange)));
         try!(self.print_ty_fn(None,
                               None,
                               m.unsafety,
@@ -1226,7 +1226,7 @@ pub fn print_impl_item(&mut self, ii: &ast::ImplItem) -> IoResult<()> {
     pub fn print_method(&mut self, meth: &ast::Method) -> IoResult<()> {
         try!(self.hardbreak_if_not_bol());
         try!(self.maybe_print_comment(meth.span.lo));
-        try!(self.print_outer_attributes(meth.attrs[]));
+        try!(self.print_outer_attributes(meth.attrs.index(&FullRange)));
         match meth.node {
             ast::MethDecl(ident,
                           ref generics,
@@ -1244,7 +1244,7 @@ pub fn print_method(&mut self, meth: &ast::Method) -> IoResult<()> {
                                    Some(&explicit_self.node),
                                    vis));
                 try!(word(&mut self.s, " "));
-                self.print_block_with_attrs(&**body, meth.attrs[])
+                self.print_block_with_attrs(&**body, meth.attrs.index(&FullRange))
             },
             ast::MethMac(codemap::Spanned { node: ast::MacInvocTT(ref pth, ref tts, _),
                                             ..}) => {
@@ -1253,7 +1253,7 @@ pub fn print_method(&mut self, meth: &ast::Method) -> IoResult<()> {
                 try!(word(&mut self.s, "! "));
                 try!(self.cbox(indent_unit));
                 try!(self.popen());
-                try!(self.print_tts(tts[]));
+                try!(self.print_tts(tts.index(&FullRange)));
                 try!(self.pclose());
                 try!(word(&mut self.s, ";"));
                 self.end()
@@ -1520,7 +1520,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
             ast::ExprVec(ref exprs) => {
                 try!(self.ibox(indent_unit));
                 try!(word(&mut self.s, "["));
-                try!(self.commasep_exprs(Inconsistent, exprs[]));
+                try!(self.commasep_exprs(Inconsistent, exprs.index(&FullRange)));
                 try!(word(&mut self.s, "]"));
                 try!(self.end());
             }
@@ -1537,36 +1537,38 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
 
             ast::ExprStruct(ref path, ref fields, ref wth) => {
                 try!(self.print_path(path, true));
-                try!(word(&mut self.s, "{"));
-                try!(self.commasep_cmnt(
-                    Consistent,
-                    fields[],
-                    |s, field| {
-                        try!(s.ibox(indent_unit));
-                        try!(s.print_ident(field.ident.node));
-                        try!(s.word_space(":"));
-                        try!(s.print_expr(&*field.expr));
-                        s.end()
-                    },
-                    |f| f.span));
-                match *wth {
-                    Some(ref expr) => {
-                        try!(self.ibox(indent_unit));
-                        if !fields.is_empty() {
-                            try!(word(&mut self.s, ","));
-                            try!(space(&mut self.s));
+                if !(fields.is_empty() && wth.is_none()) {
+                    try!(word(&mut self.s, "{"));
+                    try!(self.commasep_cmnt(
+                        Consistent,
+                        fields.index(&FullRange),
+                        |s, field| {
+                            try!(s.ibox(indent_unit));
+                            try!(s.print_ident(field.ident.node));
+                            try!(s.word_space(":"));
+                            try!(s.print_expr(&*field.expr));
+                            s.end()
+                        },
+                        |f| f.span));
+                    match *wth {
+                        Some(ref expr) => {
+                            try!(self.ibox(indent_unit));
+                            if !fields.is_empty() {
+                                try!(word(&mut self.s, ","));
+                                try!(space(&mut self.s));
+                            }
+                            try!(word(&mut self.s, ".."));
+                            try!(self.print_expr(&**expr));
+                            try!(self.end());
                         }
-                        try!(word(&mut self.s, ".."));
-                        try!(self.print_expr(&**expr));
-                        try!(self.end());
+                        _ => try!(word(&mut self.s, ",")),
                     }
-                    _ => try!(word(&mut self.s, ","))
+                    try!(word(&mut self.s, "}"));
                 }
-                try!(word(&mut self.s, "}"));
             }
             ast::ExprTup(ref exprs) => {
                 try!(self.popen());
-                try!(self.commasep_exprs(Inconsistent, exprs[]));
+                try!(self.commasep_exprs(Inconsistent, exprs.index(&FullRange)));
                 if exprs.len() == 1 {
                     try!(word(&mut self.s, ","));
                 }
@@ -1574,7 +1576,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
             }
             ast::ExprCall(ref func, ref args) => {
                 try!(self.print_expr_maybe_paren(&**func));
-                try!(self.print_call_post(args[]));
+                try!(self.print_call_post(args.index(&FullRange)));
             }
             ast::ExprMethodCall(ident, ref tys, ref args) => {
                 let base_args = args.slice_from(1);
@@ -1583,7 +1585,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 try!(self.print_ident(ident.node));
                 if tys.len() > 0u {
                     try!(word(&mut self.s, "::<"));
-                    try!(self.commasep(Inconsistent, tys[],
+                    try!(self.commasep(Inconsistent, tys.index(&FullRange),
                                        |s, ty| s.print_type(&**ty)));
                     try!(word(&mut self.s, ">"));
                 }
@@ -1780,11 +1782,11 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 try!(self.print_string(a.asm.get(), a.asm_str_style));
                 try!(self.word_space(":"));
 
-                try!(self.commasep(Inconsistent, a.outputs[],
+                try!(self.commasep(Inconsistent, a.outputs.index(&FullRange),
                                    |s, &(ref co, ref o, is_rw)| {
                     match co.get().slice_shift_char() {
                         Some(('=', operand)) if is_rw => {
-                            try!(s.print_string(format!("+{}", operand)[],
+                            try!(s.print_string(format!("+{}", operand).index(&FullRange),
                                                 ast::CookedStr))
                         }
                         _ => try!(s.print_string(co.get(), ast::CookedStr))
@@ -1797,7 +1799,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 try!(space(&mut self.s));
                 try!(self.word_space(":"));
 
-                try!(self.commasep(Inconsistent, a.inputs[],
+                try!(self.commasep(Inconsistent, a.inputs.index(&FullRange),
                                    |s, &(ref co, ref o)| {
                     try!(s.print_string(co.get(), ast::CookedStr));
                     try!(s.popen());
@@ -1808,7 +1810,7 @@ pub fn print_expr(&mut self, expr: &ast::Expr) -> IoResult<()> {
                 try!(space(&mut self.s));
                 try!(self.word_space(":"));
 
-                try!(self.commasep(Inconsistent, a.clobbers[],
+                try!(self.commasep(Inconsistent, a.clobbers.index(&FullRange),
                                    |s, co| {
                     try!(s.print_string(co.get(), ast::CookedStr));
                     Ok(())
@@ -1882,7 +1884,7 @@ pub fn print_decl(&mut self, decl: &ast::Decl) -> IoResult<()> {
     pub fn print_ident(&mut self, ident: ast::Ident) -> IoResult<()> {
         if self.encode_idents_with_hygiene {
             let encoded = ident.encode_with_hygiene();
-            try!(word(&mut self.s, encoded[]))
+            try!(word(&mut self.s, encoded.index(&FullRange)))
         } else {
             try!(word(&mut self.s, token::get_ident(ident).get()))
         }
@@ -1890,7 +1892,7 @@ pub fn print_ident(&mut self, ident: ast::Ident) -> IoResult<()> {
     }
 
     pub fn print_uint(&mut self, i: uint) -> IoResult<()> {
-        word(&mut self.s, i.to_string()[])
+        word(&mut self.s, i.to_string().index(&FullRange))
     }
 
     pub fn print_name(&mut self, name: ast::Name) -> IoResult<()> {
@@ -1964,7 +1966,7 @@ fn print_path_parameters(&mut self,
                     }
                     try!(self.commasep(
                         Inconsistent,
-                        data.types[],
+                        data.types.index(&FullRange),
                         |s, ty| s.print_type(&**ty)));
                         comma = true;
                 }
@@ -1987,7 +1989,7 @@ fn print_path_parameters(&mut self,
                 try!(word(&mut self.s, "("));
                 try!(self.commasep(
                     Inconsistent,
-                    data.inputs[],
+                    data.inputs.index(&FullRange),
                     |s, ty| s.print_type(&**ty)));
                 try!(word(&mut self.s, ")"));
 
@@ -2040,7 +2042,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> IoResult<()> {
                     Some(ref args) => {
                         if !args.is_empty() {
                             try!(self.popen());
-                            try!(self.commasep(Inconsistent, args[],
+                            try!(self.commasep(Inconsistent, args.index(&FullRange),
                                               |s, p| s.print_pat(&**p)));
                             try!(self.pclose());
                         }
@@ -2052,7 +2054,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> IoResult<()> {
                 try!(self.nbsp());
                 try!(self.word_space("{"));
                 try!(self.commasep_cmnt(
-                    Consistent, fields[],
+                    Consistent, fields.index(&FullRange),
                     |s, f| {
                         try!(s.cbox(indent_unit));
                         if !f.node.is_shorthand {
@@ -2073,7 +2075,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> IoResult<()> {
             ast::PatTup(ref elts) => {
                 try!(self.popen());
                 try!(self.commasep(Inconsistent,
-                                   elts[],
+                                   elts.index(&FullRange),
                                    |s, p| s.print_pat(&**p)));
                 if elts.len() == 1 {
                     try!(word(&mut self.s, ","));
@@ -2101,7 +2103,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> IoResult<()> {
             ast::PatVec(ref before, ref slice, ref after) => {
                 try!(word(&mut self.s, "["));
                 try!(self.commasep(Inconsistent,
-                                   before[],
+                                   before.index(&FullRange),
                                    |s, p| s.print_pat(&**p)));
                 for p in slice.iter() {
                     if !before.is_empty() { try!(self.word_space(",")); }
@@ -2115,7 +2117,7 @@ pub fn print_pat(&mut self, pat: &ast::Pat) -> IoResult<()> {
                     if !after.is_empty() { try!(self.word_space(",")); }
                 }
                 try!(self.commasep(Inconsistent,
-                                   after[],
+                                   after.index(&FullRange),
                                    |s, p| s.print_pat(&**p)));
                 try!(word(&mut self.s, "]"));
             }
@@ -2132,7 +2134,7 @@ fn print_arm(&mut self, arm: &ast::Arm) -> IoResult<()> {
         }
         try!(self.cbox(indent_unit));
         try!(self.ibox(0u));
-        try!(self.print_outer_attributes(arm.attrs[]));
+        try!(self.print_outer_attributes(arm.attrs.index(&FullRange)));
         let mut first = true;
         for p in arm.pats.iter() {
             if first {
@@ -2232,7 +2234,7 @@ pub fn print_fn_args(&mut self, decl: &ast::FnDecl,
 
         // HACK(eddyb) ignore the separately printed self argument.
         let args = if first {
-            decl.inputs[]
+            decl.inputs.index(&FullRange)
         } else {
             decl.inputs.slice_from(1)
         };
@@ -2398,7 +2400,7 @@ pub fn print_generics(&mut self,
             ints.push(i);
         }
 
-        try!(self.commasep(Inconsistent, ints[], |s, &idx| {
+        try!(self.commasep(Inconsistent, ints.index(&FullRange), |s, &idx| {
             if idx < generics.lifetimes.len() {
                 let lifetime = &generics.lifetimes[idx];
                 s.print_lifetime_def(lifetime)
@@ -2415,7 +2417,7 @@ pub fn print_generics(&mut self,
 
     pub fn print_ty_param(&mut self, param: &ast::TyParam) -> IoResult<()> {
         try!(self.print_ident(param.ident));
-        try!(self.print_bounds(":", param.bounds[]));
+        try!(self.print_bounds(":", param.bounds.index(&FullRange)));
         match param.default {
             Some(ref default) => {
                 try!(space(&mut self.s));
@@ -2491,7 +2493,7 @@ pub fn print_meta_item(&mut self, item: &ast::MetaItem) -> IoResult<()> {
                 try!(word(&mut self.s, name.get()));
                 try!(self.popen());
                 try!(self.commasep(Consistent,
-                                   items[],
+                                   items.index(&FullRange),
                                    |s, i| s.print_meta_item(&**i)));
                 try!(self.pclose());
             }
@@ -2527,7 +2529,7 @@ pub fn print_view_path(&mut self, vp: &ast::ViewPath) -> IoResult<()> {
                     try!(self.print_path(path, false));
                     try!(word(&mut self.s, "::{"));
                 }
-                try!(self.commasep(Inconsistent, idents[], |s, w| {
+                try!(self.commasep(Inconsistent, idents.index(&FullRange), |s, w| {
                     match w.node {
                         ast::PathListIdent { name, .. } => {
                             s.print_ident(name)
@@ -2545,7 +2547,7 @@ pub fn print_view_path(&mut self, vp: &ast::ViewPath) -> IoResult<()> {
     pub fn print_view_item(&mut self, item: &ast::ViewItem) -> IoResult<()> {
         try!(self.hardbreak_if_not_bol());
         try!(self.maybe_print_comment(item.span.lo));
-        try!(self.print_outer_attributes(item.attrs[]));
+        try!(self.print_outer_attributes(item.attrs.index(&FullRange)));
         try!(self.print_visibility(item.vis));
         match item.node {
             ast::ViewItemExternCrate(id, ref optional_path, _) => {
@@ -2687,7 +2689,7 @@ pub fn print_ty_fn(&mut self,
             try!(self.pclose());
         }
 
-        try!(self.print_bounds(":", bounds[]));
+        try!(self.print_bounds(":", bounds.index(&FullRange)));
 
         try!(self.print_fn_output(decl));
 
@@ -2746,7 +2748,7 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
         try!(self.maybe_print_comment(lit.span.lo));
         match self.next_lit(lit.span.lo) {
             Some(ref ltrl) => {
-                return word(&mut self.s, (*ltrl).lit[]);
+                return word(&mut self.s, (*ltrl).lit.index(&FullRange));
             }
             _ => ()
         }
@@ -2756,7 +2758,7 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
                 let mut res = String::from_str("b'");
                 ascii::escape_default(byte, |c| res.push(c as char));
                 res.push('\'');
-                word(&mut self.s, res[])
+                word(&mut self.s, res.index(&FullRange))
             }
             ast::LitChar(ch) => {
                 let mut res = String::from_str("'");
@@ -2764,27 +2766,27 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
                     res.push(c);
                 }
                 res.push('\'');
-                word(&mut self.s, res[])
+                word(&mut self.s, res.index(&FullRange))
             }
             ast::LitInt(i, t) => {
                 match t {
                     ast::SignedIntLit(st, ast::Plus) => {
                         word(&mut self.s,
-                             ast_util::int_ty_to_string(st, Some(i as i64))[])
+                             ast_util::int_ty_to_string(st, Some(i as i64)).index(&FullRange))
                     }
                     ast::SignedIntLit(st, ast::Minus) => {
                         let istr = ast_util::int_ty_to_string(st, Some(-(i as i64)));
                         word(&mut self.s,
-                             format!("-{}", istr)[])
+                             format!("-{}", istr).index(&FullRange))
                     }
                     ast::UnsignedIntLit(ut) => {
-                        word(&mut self.s, ast_util::uint_ty_to_string(ut, Some(i))[])
+                        word(&mut self.s, ast_util::uint_ty_to_string(ut, Some(i)).as_slice())
                     }
                     ast::UnsuffixedIntLit(ast::Plus) => {
-                        word(&mut self.s, format!("{}", i)[])
+                        word(&mut self.s, format!("{}", i).index(&FullRange))
                     }
                     ast::UnsuffixedIntLit(ast::Minus) => {
-                        word(&mut self.s, format!("-{}", i)[])
+                        word(&mut self.s, format!("-{}", i).index(&FullRange))
                     }
                 }
             }
@@ -2793,7 +2795,7 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
                      format!(
                          "{}{}",
                          f.get(),
-                         ast_util::float_ty_to_string(t)[])[])
+                         ast_util::float_ty_to_string(t).index(&FullRange)).index(&FullRange))
             }
             ast::LitFloatUnsuffixed(ref f) => word(&mut self.s, f.get()),
             ast::LitBool(val) => {
@@ -2805,7 +2807,7 @@ pub fn print_literal(&mut self, lit: &ast::Lit) -> IoResult<()> {
                     ascii::escape_default(ch as u8,
                                           |ch| escaped.push(ch as char));
                 }
-                word(&mut self.s, format!("b\"{}\"", escaped)[])
+                word(&mut self.s, format!("b\"{}\"", escaped).index(&FullRange))
             }
         }
     }
@@ -2846,7 +2848,7 @@ pub fn print_comment(&mut self,
             comments::Mixed => {
                 assert_eq!(cmnt.lines.len(), 1u);
                 try!(zerobreak(&mut self.s));
-                try!(word(&mut self.s, cmnt.lines[0][]));
+                try!(word(&mut self.s, cmnt.lines[0].index(&FullRange)));
                 zerobreak(&mut self.s)
             }
             comments::Isolated => {
@@ -2855,7 +2857,7 @@ pub fn print_comment(&mut self,
                     // Don't print empty lines because they will end up as trailing
                     // whitespace
                     if !line.is_empty() {
-                        try!(word(&mut self.s, line[]));
+                        try!(word(&mut self.s, line.index(&FullRange)));
                     }
                     try!(hardbreak(&mut self.s));
                 }
@@ -2864,13 +2866,13 @@ pub fn print_comment(&mut self,
             comments::Trailing => {
                 try!(word(&mut self.s, " "));
                 if cmnt.lines.len() == 1u {
-                    try!(word(&mut self.s, cmnt.lines[0][]));
+                    try!(word(&mut self.s, cmnt.lines[0].index(&FullRange)));
                     hardbreak(&mut self.s)
                 } else {
                     try!(self.ibox(0u));
                     for line in cmnt.lines.iter() {
                         if !line.is_empty() {
-                            try!(word(&mut self.s, line[]));
+                            try!(word(&mut self.s, line.index(&FullRange)));
                         }
                         try!(hardbreak(&mut self.s));
                     }
@@ -2903,7 +2905,7 @@ pub fn print_string(&mut self, st: &str,
                          string=st))
             }
         };
-        word(&mut self.s, st[])
+        word(&mut self.s, st.index(&FullRange))
     }
 
     pub fn next_comment(&mut self) -> Option<comments::Comment> {
@@ -2934,7 +2936,7 @@ pub fn print_opt_abi_and_extern_if_nondefault(&mut self,
             Some(abi::Rust) => Ok(()),
             Some(abi) => {
                 try!(self.word_nbsp("extern"));
-                self.word_nbsp(abi.to_string()[])
+                self.word_nbsp(abi.to_string().index(&FullRange))
             }
             None => Ok(())
         }
@@ -2945,7 +2947,7 @@ pub fn print_extern_opt_abi(&mut self,
         match opt_abi {
             Some(abi) => {
                 try!(self.word_nbsp("extern"));
-                self.word_nbsp(abi.to_string()[])
+                self.word_nbsp(abi.to_string().index(&FullRange))
             }
             None => Ok(())
         }
@@ -2961,7 +2963,7 @@ pub fn print_fn_header_info(&mut self,
 
         if abi != abi::Rust {
             try!(self.word_nbsp("extern"));
-            try!(self.word_nbsp(abi.to_string()[]));
+            try!(self.word_nbsp(abi.to_string().index(&FullRange)));
         }
 
         word(&mut self.s, "fn")
index 13eda7bb88f05eb48b05824d912bb240c85f31c4..8abb46011e65ce85b37f18248981d8cec7d34f2c 100644 (file)
@@ -111,28 +111,12 @@ fn hash(&self, state: &mut S) {
     }
 }
 
-#[cfg(stage0)]
-impl<E, D: Decoder<E>, T: 'static + Decodable<D, E>> Decodable<D, E> for P<T> {
-    fn decode(d: &mut D) -> Result<P<T>, E> {
-        Decodable::decode(d).map(P)
-    }
-}
-
-#[cfg(not(stage0))]
 impl<T: 'static + Decodable> Decodable for P<T> {
     fn decode<D: Decoder>(d: &mut D) -> Result<P<T>, D::Error> {
         Decodable::decode(d).map(P)
     }
 }
 
-#[cfg(stage0)]
-impl<E, S: Encoder<E>, T: Encodable<S, E>> Encodable<S, E> for P<T> {
-    fn encode(&self, s: &mut S) -> Result<(), E> {
-        (**self).encode(s)
-    }
-}
-
-#[cfg(not(stage0))]
 impl<T: Encodable> Encodable for P<T> {
     fn encode<S: Encoder>(&self, s: &mut S) -> Result<(), S::Error> {
         (**self).encode(s)
index 4ef7eb97a218946e8c16b2b24d70c91d7617aff4..daa51203287b3744b6b17dcb10c274f454f8e1e3 100644 (file)
@@ -40,7 +40,7 @@ pub fn maybe_inject_prelude(krate: ast::Crate) -> ast::Crate {
 }
 
 fn use_std(krate: &ast::Crate) -> bool {
-    !attr::contains_name(krate.attrs[], "no_std")
+    !attr::contains_name(krate.attrs.index(&FullRange), "no_std")
 }
 
 fn no_prelude(attrs: &[ast::Attribute]) -> bool {
@@ -56,7 +56,7 @@ fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
 
         // The name to use in `extern crate "name" as std;`
         let actual_crate_name = match self.alt_std_name {
-            Some(ref s) => token::intern_and_get_ident(s[]),
+            Some(ref s) => token::intern_and_get_ident(s.index(&FullRange)),
             None => token::intern_and_get_ident("std"),
         };
 
@@ -104,7 +104,7 @@ fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
         attr::mark_used(&no_std_attr);
         krate.attrs.push(no_std_attr);
 
-        if !no_prelude(krate.attrs[]) {
+        if !no_prelude(krate.attrs.index(&FullRange)) {
             // only add `use std::prelude::*;` if there wasn't a
             // `#![no_implicit_prelude]` at the crate level.
             // fold_mod() will insert glob path.
@@ -124,7 +124,7 @@ fn fold_crate(&mut self, mut krate: ast::Crate) -> ast::Crate {
     }
 
     fn fold_item(&mut self, item: P<ast::Item>) -> SmallVector<P<ast::Item>> {
-        if !no_prelude(item.attrs[]) {
+        if !no_prelude(item.attrs.index(&FullRange)) {
             // only recur if there wasn't `#![no_implicit_prelude]`
             // on this item, i.e. this means that the prelude is not
             // implicitly imported though the whole subtree
index e480532a41053b9e4b6fbd14ad5bc00476863527..711715355e9503a1972419b104c809596d9dbf4c 100644 (file)
@@ -73,14 +73,14 @@ pub fn modify_for_testing(sess: &ParseSess,
     // We generate the test harness when building in the 'test'
     // configuration, either with the '--test' or '--cfg test'
     // command line options.
-    let should_test = attr::contains_name(krate.config[], "test");
+    let should_test = attr::contains_name(krate.config.index(&FullRange), "test");
 
     // Check for #[reexport_test_harness_main = "some_name"] which
     // creates a `use some_name = __test::main;`. This needs to be
     // unconditional, so that the attribute is still marked as used in
     // non-test builds.
     let reexport_test_harness_main =
-        attr::first_attr_value_str_by_name(krate.attrs[],
+        attr::first_attr_value_str_by_name(krate.attrs.index(&FullRange),
                                            "reexport_test_harness_main");
 
     if should_test {
@@ -119,7 +119,7 @@ fn fold_item(&mut self, i: P<ast::Item>) -> SmallVector<P<ast::Item>> {
             self.cx.path.push(ident);
         }
         debug!("current path: {}",
-               ast_util::path_name_i(self.cx.path[]));
+               ast_util::path_name_i(self.cx.path.index(&FullRange)));
 
         if is_test_fn(&self.cx, &*i) || is_bench_fn(&self.cx, &*i) {
             match i.node {
@@ -194,7 +194,7 @@ fn fold_mod(&mut self, m: ast::Mod) -> ast::Mod {
             if !self.cx.path.is_empty() {
                 self.tested_submods.push((self.cx.path[self.cx.path.len()-1], sym));
             } else {
-                debug!("pushing nothing, sym: {}", sym);
+                debug!("pushing nothing, sym: {:?}", sym);
                 self.cx.toplevel_reexport = Some(sym);
             }
         }
@@ -277,8 +277,8 @@ fn strip_test_functions(krate: ast::Crate) -> ast::Crate {
     // When not compiling with --test we should not compile the
     // #[test] functions
     config::strip_items(krate, |attrs| {
-        !attr::contains_name(attrs[], "test") &&
-        !attr::contains_name(attrs[], "bench")
+        !attr::contains_name(attrs.index(&FullRange), "test") &&
+        !attr::contains_name(attrs.index(&FullRange), "bench")
     })
 }
 
@@ -291,7 +291,7 @@ enum HasTestSignature {
 
 
 fn is_test_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
-    let has_test_attr = attr::contains_name(i.attrs[], "test");
+    let has_test_attr = attr::contains_name(i.attrs.index(&FullRange), "test");
 
     fn has_test_signature(i: &ast::Item) -> HasTestSignature {
         match &i.node {
@@ -329,7 +329,7 @@ fn has_test_signature(i: &ast::Item) -> HasTestSignature {
 }
 
 fn is_bench_fn(cx: &TestCtxt, i: &ast::Item) -> bool {
-    let has_bench_attr = attr::contains_name(i.attrs[], "bench");
+    let has_bench_attr = attr::contains_name(i.attrs.index(&FullRange), "bench");
 
     fn has_test_signature(i: &ast::Item) -> bool {
         match i.node {
@@ -384,7 +384,7 @@ fn should_fail(i: &ast::Item) -> ShouldFail {
 mod __test {
   extern crate test (name = "test", vers = "...");
   fn main() {
-    test::test_main_static(::os::args()[], tests)
+    test::test_main_static(::os::args().index(&FullRange), tests)
   }
 
   static tests : &'static [test::TestDescAndFn] = &[
@@ -510,8 +510,8 @@ fn mk_tests(cx: &TestCtxt) -> P<ast::Item> {
 }
 
 fn is_test_crate(krate: &ast::Crate) -> bool {
-    match attr::find_crate_name(krate.attrs[]) {
-        Some(ref s) if "test" == s.get()[] => true,
+    match attr::find_crate_name(krate.attrs.index(&FullRange)) {
+        Some(ref s) if "test" == s.get().index(&FullRange) => true,
         _ => false
     }
 }
@@ -551,11 +551,11 @@ fn mk_test_desc_and_fn_rec(cx: &TestCtxt, test: &Test) -> P<ast::Expr> {
     // creates $name: $expr
     let field = |&: name, expr| ecx.field_imm(span, ecx.ident_of(name), expr);
 
-    debug!("encoding {}", ast_util::path_name_i(path[]));
+    debug!("encoding {}", ast_util::path_name_i(path.index(&FullRange)));
 
     // path to the #[test] function: "foo::bar::baz"
-    let path_string = ast_util::path_name_i(path[]);
-    let name_expr = ecx.expr_str(span, token::intern_and_get_ident(path_string[]));
+    let path_string = ast_util::path_name_i(path.index(&FullRange));
+    let name_expr = ecx.expr_str(span, token::intern_and_get_ident(path_string.index(&FullRange)));
 
     // self::test::StaticTestName($name_expr)
     let name_expr = ecx.expr_call(span,
index 85eea2d9daf27226f889f7c80b4c3643587fbd48..93de342d487dccdc32e8c55fcdc576e552c19cf0 100644 (file)
@@ -28,7 +28,7 @@ pub struct Interner<T> {
     vect: RefCell<Vec<T> >,
 }
 
-// when traits can extend traits, we should extend index<Name,T> to get []
+// when traits can extend traits, we should extend index<Name,T> to get .index(&FullRange)
 impl<T: Eq + Hash + Clone + 'static> Interner<T> {
     pub fn new() -> Interner<T> {
         Interner {
@@ -109,27 +109,27 @@ impl Eq for RcStr {}
 
 impl Ord for RcStr {
     fn cmp(&self, other: &RcStr) -> Ordering {
-        self[].cmp(other[])
+        self.index(&FullRange).cmp(other.index(&FullRange))
     }
 }
 
 impl fmt::Show for RcStr {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         use std::fmt::Show;
-        self[].fmt(f)
+        self.index(&FullRange).fmt(f)
     }
 }
 
 impl BorrowFrom<RcStr> for str {
     fn borrow_from(owned: &RcStr) -> &str {
-        owned.string[]
+        owned.string.index(&FullRange)
     }
 }
 
 impl Deref for RcStr {
     type Target = str;
 
-    fn deref(&self) -> &str { self.string[] }
+    fn deref(&self) -> &str { self.string.index(&FullRange) }
 }
 
 /// A StrInterner differs from Interner<String> in that it accepts
@@ -139,7 +139,7 @@ pub struct StrInterner {
     vect: RefCell<Vec<RcStr> >,
 }
 
-/// When traits can extend traits, we should extend index<Name,T> to get []
+/// When traits can extend traits, we should extend index<Name,T> to get .index(&FullRange)
 impl StrInterner {
     pub fn new() -> StrInterner {
         StrInterner {
index dd42bede13ac3e69d8f35850bad010214a9e9e24..c953f591d805864b8993fd75d8095b915772fca6 100644 (file)
        html_playground_url = "http://play.rust-lang.org/")]
 
 #![allow(unknown_features)]
-#![feature(macro_rules, phase, slicing_syntax, globs)]
-
+#![feature(slicing_syntax)]
 #![deny(missing_docs)]
 
-#[cfg(stage0)]
-#[phase(plugin, link)]
-extern crate log;
-
-#[cfg(not(stage0))]
-#[macro_use]
-extern crate log;
+#[macro_use] extern crate log;
 
 pub use terminfo::TerminfoTerminal;
 #[cfg(windows)]
index 80d195d9218461486f28d92ed749d17143641b3c..f2dcdc6160aa9e3b9f00848d9a6a3dcd8f18cd95 100644 (file)
@@ -180,7 +180,7 @@ pub fn new(out: T) -> Option<Box<Terminal<T>+Send+'static>> {
             }
         };
 
-        let entry = open(term[]);
+        let entry = open(term.index(&FullRange));
         if entry.is_err() {
             if os::getenv("MSYSCON").map_or(false, |s| {
                     "mintty.exe" == s
@@ -190,14 +190,14 @@ pub fn new(out: T) -> Option<Box<Terminal<T>+Send+'static>> {
                                                   ti: msys_terminfo(),
                                                   num_colors: 8} as Box<Terminal<T>+Send>);
             }
-            debug!("error finding terminfo entry: {}", entry.err().unwrap());
+            debug!("error finding terminfo entry: {:?}", entry.err().unwrap());
             return None;
         }
 
         let mut file = entry.unwrap();
         let ti = parse(&mut file, false);
         if ti.is_err() {
-            debug!("error parsing terminfo entry: {}", ti.unwrap_err());
+            debug!("error parsing terminfo entry: {:?}", ti.unwrap_err());
             return None;
         }
 
index 04238f1c96536fd08a1e0f1895a845f8ccaddef9..b0bce8f31120f94d6412b47d66966066eac47764 100644 (file)
@@ -290,7 +290,7 @@ pub fn expand(cap: &[u8], params: &[Param], vars: &mut Variables)
                     ';' => (),
 
                     _ => {
-                        return Err(format!("unrecognized format option {}", cur))
+                        return Err(format!("unrecognized format option {:?}", cur))
                     }
                 }
             },
@@ -552,7 +552,7 @@ fn format(val: Param, op: FormatOp, flags: Flags) -> Result<Vec<u8> ,String> {
                     s
                 }
                 _ => {
-                    return Err(format!("non-string on stack with %{}",
+                    return Err(format!("non-string on stack with %{:?}",
                                        op.to_char()))
                 }
             }
@@ -636,7 +636,7 @@ fn get_res(fmt: &str, cap: &str, params: &[Param], vars: &mut Variables) ->
                     "Binop {} succeeded incorrectly with 1 stack entry", cap);
             let res = get_res("%{1}%{2}", cap, &[], vars);
             assert!(res.is_ok(),
-                    "Binop {} failed with 2 stack entries: {}", cap, res.unwrap_err());
+                    "Binop {} failed with 2 stack entries: {:?}", cap, res.unwrap_err());
         }
     }
 
index 5f0111c7d7a84de51191dff892f86531c099cc44..7a06849abd161a7fac3c56685f62b98376520781 100644 (file)
@@ -163,7 +163,7 @@ pub fn parse(file: &mut io::Reader, longnames: bool)
     macro_rules! try { ($e:expr) => (
         match $e {
             Ok(e) => e,
-            Err(e) => return Err(format!("{}", e))
+            Err(e) => return Err(format!("{:?}", e))
         }
     ) }
 
@@ -284,13 +284,13 @@ macro_rules! try { ($e:expr) => (
 
 
             // Find the offset of the NUL we want to go to
-            let nulpos = string_table[offset as uint .. string_table_bytes as uint]
+            let nulpos = string_table.index(&((offset as uint) .. (string_table_bytes as uint)))
                 .iter().position(|&b| b == 0);
             match nulpos {
                 Some(len) => {
                     string_map.insert(name.to_string(),
-                                      string_table[offset as uint ..
-                                          offset as uint + len].to_vec())
+                                      string_table.index(&((offset as uint) ..
+                                          (offset as uint + len))).to_vec())
                 },
                 None => {
                     return Err("invalid file: missing NUL in \
index 395fac52d8dacedbbeb2f44d1c800291a9fcd069..2651be1ebb8f570a856e6b044a7215696fde7698 100644 (file)
@@ -61,13 +61,13 @@ pub fn get_dbpath_for_term(term: &str) -> Option<Box<Path>> {
     for p in dirs_to_search.iter() {
         if p.exists() {
             let f = first_char.to_string();
-            let newp = p.join_many(&[f[], term]);
+            let newp = p.join_many(&[f.index(&FullRange), term]);
             if newp.exists() {
                 return Some(box newp);
             }
             // on some installations the dir is named after the hex of the char (e.g. OS X)
             let f = format!("{:x}", first_char as uint);
-            let newp = p.join_many(&[f[], term]);
+            let newp = p.join_many(&[f.index(&FullRange), term]);
             if newp.exists() {
                 return Some(box newp);
             }
@@ -82,11 +82,11 @@ pub fn open(term: &str) -> Result<File, String> {
         Some(x) => {
             match File::open(&*x) {
                 Ok(file) => Ok(file),
-                Err(e) => Err(format!("error opening file: {}", e)),
+                Err(e) => Err(format!("error opening file: {:?}", e)),
             }
         }
         None => {
-            Err(format!("could not find terminfo entry for {}", term))
+            Err(format!("could not find terminfo entry for {:?}", term))
         }
     }
 }
index c417fd94e22eb953a9cd73955cbb63a729f8c52a..68d06cc4dab6480ec62139050d0e7a39adc896b6 100644 (file)
 #![doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
        html_favicon_url = "http://www.rust-lang.org/favicon.ico",
        html_root_url = "http://doc.rust-lang.org/nightly/")]
-
-#![allow(unknown_features)]
-#![feature(asm, globs, slicing_syntax)]
-#![feature(unboxed_closures, default_type_params)]
-#![feature(old_orphan_check)]
+#![feature(asm, slicing_syntax)]
 
 extern crate getopts;
 extern crate regex;
@@ -95,7 +91,7 @@ pub mod test {
 // colons. This way if some test runner wants to arrange the tests
 // hierarchically it may.
 
-#[derive(Clone, PartialEq, Eq, Hash)]
+#[derive(Clone, PartialEq, Eq, Hash, Show)]
 pub enum TestName {
     StaticTestName(&'static str),
     DynTestName(String)
@@ -108,9 +104,9 @@ fn as_slice<'a>(&'a self) -> &'a str {
         }
     }
 }
-impl Show for TestName {
+impl fmt::String for TestName {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        self.as_slice().fmt(f)
+        fmt::String::fmt(self.as_slice(), f)
     }
 }
 
@@ -257,13 +253,13 @@ pub fn test_main(args: &[String], tests: Vec<TestDescAndFn> ) {
     let opts =
         match parse_opts(args) {
             Some(Ok(o)) => o,
-            Some(Err(msg)) => panic!("{}", msg),
+            Some(Err(msg)) => panic!("{:?}", msg),
             None => return
         };
     match run_tests_console(&opts, tests) {
         Ok(true) => {}
         Ok(false) => panic!("Some tests failed"),
-        Err(e) => panic!("io error when running tests: {}", e),
+        Err(e) => panic!("io error when running tests: {:?}", e),
     }
 }
 
@@ -410,7 +406,7 @@ pub fn parse_opts(args: &[String]) -> Option<OptRes> {
         let s = matches.free[0].as_slice();
         match Regex::new(s) {
             Ok(re) => Some(re),
-            Err(e) => return Some(Err(format!("could not parse /{}/: {}", s, e)))
+            Err(e) => return Some(Err(format!("could not parse /{}/: {:?}", s, e)))
         }
     } else {
         None
@@ -793,7 +789,7 @@ pub fn write_run_finish(&mut self,
         let ratchet_success = match *ratchet_metrics {
             None => true,
             Some(ref pth) => {
-                try!(self.write_plain(format!("\nusing metrics ratchet: {}\n",
+                try!(self.write_plain(format!("\nusing metrics ratchet: {:?}\n",
                                               pth.display()).as_slice()));
                 match ratchet_pct {
                     None => (),
@@ -912,7 +908,7 @@ fn len_if_padded(t: &TestDescAndFn) -> uint {
         None => (),
         Some(ref pth) => {
             try!(st.metrics.save(pth));
-            try!(st.write_plain(format!("\nmetrics saved to: {}",
+            try!(st.write_plain(format!("\nmetrics saved to: {:?}",
                                           pth.display()).as_slice()));
         }
     }
@@ -952,7 +948,7 @@ fn should_sort_failures_before_printing_them() {
 
     st.write_failures().unwrap();
     let s = match st.out {
-        Raw(ref m) => String::from_utf8_lossy(m[]),
+        Raw(ref m) => String::from_utf8_lossy(m.index(&FullRange)),
         Pretty(_) => unreachable!()
     };
 
@@ -1137,11 +1133,11 @@ fn run_test_inner(desc: TestDesc,
                 cfg = cfg.stderr(box stderr as Box<Writer + Send>);
             }
 
-            let result_guard = cfg.spawn(move || { testfn.invoke(()) });
+            let result_guard = cfg.scoped(move || { testfn.invoke(()) });
             let stdout = reader.read_to_end().unwrap().into_iter().collect();
             let test_result = calc_result(&desc, result_guard.join());
             monitor_ch.send((desc.clone(), test_result, stdout)).unwrap();
-        }).detach();
+        });
     }
 
     match testfn {
@@ -1206,7 +1202,7 @@ pub fn load(p: &Path) -> MetricMap {
         let mut decoder = json::Decoder::new(value);
         MetricMap(match Decodable::decode(&mut decoder) {
             Ok(t) => t,
-            Err(e) => panic!("failure decoding JSON: {}", e)
+            Err(e) => panic!("failure decoding JSON: {:?}", e)
         })
     }
 
index bdc05a50301d54bf0c9f5e1e85b7b1f7998200ab..1abb52459e493d1941f6104aac7d0240ce4d2257 100644 (file)
@@ -13,7 +13,7 @@
 use std::cmp::Ordering::{self, Less, Greater, Equal};
 use std::collections::hash_map::Entry::{Occupied, Vacant};
 use std::collections::hash_map;
-use std::fmt::Show;
+use std::fmt;
 use std::hash::Hash;
 use std::io;
 use std::mem;
@@ -333,7 +333,7 @@ pub fn winsorize<T: Float + FromPrimitive>(samples: &mut [T], pct: T) {
 }
 
 /// Render writes the min, max and quartiles of the provided `Summary` to the provided `Writer`.
-pub fn write_5_number_summary<W: Writer, T: Float + Show>(w: &mut W,
+pub fn write_5_number_summary<W: Writer, T: Float + fmt::String + fmt::Show>(w: &mut W,
                                                           s: &Summary<T>) -> io::IoResult<()> {
     let (q1,q2,q3) = s.quartiles;
     write!(w, "(min={}, q1={}, med={}, q3={}, max={})",
@@ -355,7 +355,7 @@ pub fn write_5_number_summary<W: Writer, T: Float + Show>(w: &mut W,
 /// ```{.ignore}
 ///   10 |        [--****#******----------]          | 40
 /// ```
-pub fn write_boxplot<W: Writer, T: Float + Show + FromPrimitive>(
+pub fn write_boxplot<W: Writer, T: Float + fmt::String + fmt::Show + FromPrimitive>(
                      w: &mut W,
                      s: &Summary<T>,
                      width_hint: uint)
@@ -444,7 +444,7 @@ pub fn freq_count<T, U>(mut iter: T) -> hash_map::HashMap<U, uint>
 {
     let mut map: hash_map::HashMap<U,uint> = hash_map::HashMap::new();
     for elem in iter {
-        match map.entry(&elem) {
+        match map.entry(elem) {
             Occupied(mut entry) => { *entry.get_mut() += 1; },
             Vacant(entry) => { entry.insert(1); },
         }
index a3884d0c86e1de78a708508117d6a611e598b3c1..db98b429e40678bd4c140545cca1f3bca8e3fc6f 100644 (file)
@@ -28,8 +28,7 @@
        html_root_url = "http://doc.rust-lang.org/nightly/",
        html_playground_url = "http://play.rust-lang.org/")]
 #![no_std]
-#![feature(globs, macro_rules, slicing_syntax, unboxed_closures)]
-#![feature(associated_types)]
+#![feature(slicing_syntax)]
 
 extern crate core;
 
index c755ea93184028fb9f068c2a0b83a902ddbd1752..3f089d62e4ee527013505189cec1dad0c2dc47cd 100644 (file)
@@ -7801,7 +7801,7 @@ pub fn width(c: char, is_cjk: bool) -> Option<uint> {
 }
 
 pub mod grapheme {
-    use core::kinds::Copy;
+    use core::marker::Copy;
     use core::slice::SliceExt;
     pub use self::GraphemeCat::*;
     use core::result::Result::{Ok, Err};
index b820135911e17c7a46b901db56baa48e5155bf46..ec1fdb3b9d3b1fb9e1dae97a65dd3a13db9bfb23 160000 (submodule)
--- a/src/llvm
+++ b/src/llvm
@@ -1 +1 @@
-Subproject commit b820135911e17c7a46b901db56baa48e5155bf46
+Subproject commit ec1fdb3b9d3b1fb9e1dae97a65dd3a13db9bfb23
index b5ac4cd44321da10dfd70f070dbc9094ca3f92ff..3a37981744a5af2433fed551f742465c78c9af7f 160000 (submodule)
@@ -1 +1 @@
-Subproject commit b5ac4cd44321da10dfd70f070dbc9094ca3f92ff
+Subproject commit 3a37981744a5af2433fed551f742465c78c9af7f
index 5c21a8a8abfb0c3615031b8bc01b7f7044abfdc9..d6134898cbdc8833c69392a798d283771d032f80 100644 (file)
@@ -1,3 +1,12 @@
+S 2015-01-06 340ac04
+  freebsd-x86_64 5413b8931d7076e90c873e0cc7a43e0793c2b17a
+  linux-i386 cacb8e3ad15937916e455d8f63e740c30a807b10
+  linux-x86_64 e4a7f73959130671a5eb9107d593d37b43e571b0
+  macos-i386 da6b0b7d12964e815175eb1fe5fc495098ca3125
+  macos-x86_64 edf8a109e175be6e5bc44484261d2248946f1dd1
+  winnt-i386 34fc7d9905d5845cdc7901f661d43a463534a20d
+  winnt-x86_64 99580840f5763f517f47cd55ff373e4d116b018d
+
 S 2015-01-04 b2085d9
   freebsd-x86_64 50ccb6bf9c0645d0746a5167493a39b2be40c2d4
   linux-i386 b880b98d832c9a049b8ef6a50df50061e363de5a
index ec4c0281d5597071b97ec23867ef915e16e5ddc6..673c38697b79cbf10644f7b8ecc8f97b1b318348 100644 (file)
@@ -15,6 +15,6 @@ pub fn foo<T:Send + Clone>(x: T) -> Receiver<T> {
     let (tx, rx) = channel();
     Thread::spawn(move|| {
         tx.send(x.clone());
-    }).detach();
+    });
     rx
 }
index 6799b5fa85c29ca301ebbee3ce007e65851c9153..0a888d2bd112f81f720d3ee241d51e320c403504 100644 (file)
@@ -17,7 +17,7 @@ pub struct cat {
       pub name : String,
     }
 
-    impl fmt::Show for cat {
+    impl fmt::String for cat {
         fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
             write!(f, "{}", self.name)
         }
index 1a2f429c9ebc1c31b32d2923d1ec915b304458b9..21784bda27a8f14e5e3a0e37a4c8529548d257e4 100644 (file)
@@ -18,8 +18,8 @@ pub fn foo<T>() -> int {
 
 // issue 8134
 struct Foo;
-impl<T> Foo {
-    pub fn foo(&self) {
+impl Foo {
+    pub fn foo<T>(&self) {
         static X: uint = 1;
     }
 }
@@ -33,8 +33,8 @@ fn in_doctype(&mut self) {
 }
 
 struct Bar;
-impl<T> Foo {
-    pub fn bar(&self) {
+impl Foo {
+    pub fn bar<T>(&self) {
         static X: uint = 1;
     }
 }
index d1126e742527375d82948e0f4e3065f2f62678c4..387601de8284c0116054edbf6ab555eb270e00c9 100644 (file)
@@ -64,7 +64,7 @@ fn run(args: &[String]) {
         let mut worker_results = Vec::new();
         for _ in range(0u, workers) {
             let to_child = to_child.clone();
-            worker_results.push(Thread::spawn(move|| {
+            worker_results.push(Thread::scoped(move|| {
                 for _ in range(0u, size / workers) {
                     //println!("worker {}: sending {} bytes", i, num_bytes);
                     to_child.send(request::bytes(num_bytes)).unwrap();
@@ -74,7 +74,7 @@ fn run(args: &[String]) {
         }
         Thread::spawn(move|| {
             server(&from_parent, &to_parent);
-        }).detach();
+        });
 
         for r in worker_results.into_iter() {
             let _ = r.join();
index ef22aac776e0334727370b5fcba0cdeedd431af4..d6d01e5452b95d631f751639c745f1c5d6b5b7a6 100644 (file)
@@ -59,7 +59,7 @@ fn run(args: &[String]) {
         let mut worker_results = Vec::new();
         let from_parent = if workers == 1 {
             let (to_child, from_parent) = channel();
-            worker_results.push(Thread::spawn(move|| {
+            worker_results.push(Thread::scoped(move|| {
                 for _ in range(0u, size / workers) {
                     //println!("worker {}: sending {} bytes", i, num_bytes);
                     to_child.send(request::bytes(num_bytes));
@@ -71,7 +71,7 @@ fn run(args: &[String]) {
             let (to_child, from_parent) = channel();
             for _ in range(0u, workers) {
                 let to_child = to_child.clone();
-                worker_results.push(Thread::spawn(move|| {
+                worker_results.push(Thread::scoped(move|| {
                     for _ in range(0u, size / workers) {
                         //println!("worker {}: sending {} bytes", i, num_bytes);
                         to_child.send(request::bytes(num_bytes));
@@ -83,7 +83,7 @@ fn run(args: &[String]) {
         };
         Thread::spawn(move|| {
             server(&from_parent, &to_parent);
-        }).detach();
+        });
 
         for r in worker_results.into_iter() {
             let _ = r.join();
index 5ecc580de08d554ca1c7c49ffa62f25e46c9a055..b854dc11b988abd910304495390132e6591fa611 100644 (file)
@@ -35,7 +35,7 @@ fn run_pair(n: uint) {
         // Create a channel: B->A
         let (btx, brx) = channel();
 
-        let guard_a = Thread::spawn(move|| {
+        let guard_a = Thread::scoped(move|| {
             let (tx, rx) = (atx, brx);
             for _ in range(0, n) {
                 tx.send(()).unwrap();
@@ -43,7 +43,7 @@ fn run_pair(n: uint) {
             }
         });
 
-        let guard_b = Thread::spawn(move|| {
+        let guard_b = Thread::scoped(move|| {
             let (tx, rx) = (btx, arx);
             for _ in range(0, n) {
                 rx.recv().unwrap();
index 8b212555d4011cdb2d7d1a301d2b4172127befd8..37210cd93f1b319b05e57af130477ea6d2f19b1b 100644 (file)
@@ -25,7 +25,7 @@ fn parfib(n: uint) -> uint {
     let (tx, rx) = channel();
     Thread::spawn(move|| {
         tx.send(parfib(n-1));
-    }).detach();
+    });
     let m2 = parfib(n-2);
     return (rx.recv().unwrap() + m2);
 }
index c7a43d61a9a86b1215626a292fbbdafc597ca76f..737776368dd0c5150b09e6aa34edea71461229a7 100644 (file)
@@ -95,7 +95,7 @@ fn main() {
     let mut messages = range_step(min_depth, max_depth + 1, 2).map(|depth| {
             use std::num::Int;
             let iterations = 2i.pow((max_depth - depth + min_depth) as uint);
-            Thread::spawn(move|| {
+            Thread::scoped(move|| {
                 let mut chk = 0;
                 for i in range(1, iterations + 1) {
                     let arena = TypedArena::new();
index 96bca25d1c455a031b74620871dded052d323fc4..c58c6ef62125e1fa63e9859991e69454bb84b2d3 100644 (file)
@@ -49,7 +49,7 @@ fn print_complements() {
     let all = [Blue, Red, Yellow];
     for aa in all.iter() {
         for bb in all.iter() {
-            println!("{} + {} -> {}", *aa, *bb, transform(*aa, *bb));
+            println!("{:?} + {:?} -> {:?}", *aa, *bb, transform(*aa, *bb));
         }
     }
 }
@@ -84,7 +84,7 @@ fn show_color_list(set: Vec<Color>) -> String {
     let mut out = String::new();
     for col in set.iter() {
         out.push(' ');
-        out.push_str(col.to_string().as_slice());
+        out.push_str(format!("{:?}", col).as_slice());
     }
     out
 }
@@ -170,7 +170,7 @@ fn creature(
         }
     }
     // log creatures met and evil clones of self
-    let report = format!("{}{}", creatures_met, Number(evil_clones_met));
+    let report = format!("{}{:?}", creatures_met, Number(evil_clones_met));
     to_rendezvous_log.send(report).unwrap();
 }
 
@@ -195,7 +195,7 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
                          from_rendezvous,
                          to_rendezvous,
                          to_rendezvous_log);
-            }).detach();
+            });
             to_creature
         }).collect();
 
@@ -225,7 +225,7 @@ fn rendezvous(nn: uint, set: Vec<Color>) {
     }
 
     // print the total number of creatures met
-    println!("{}\n", Number(creatures_met));
+    println!("{:?}\n", Number(creatures_met));
 }
 
 fn main() {
index 7dca2b24fc11e8fa9b9ef817f74ee26d9fd4e990..261741c073f3a56bddc34cb7b520da1f28d708bb 100644 (file)
@@ -105,7 +105,7 @@ fn get(&mut self, mut idx: i32) -> P {
             let d = idx / self.fact[i] as i32;
             self.cnt[i] = d;
             idx %= self.fact[i] as i32;
-            for (place, val) in pp.iter_mut().zip(self.perm.p[..i+1].iter()) {
+            for (place, val) in pp.iter_mut().zip(self.perm.p[..(i+1)].iter()) {
                 *place = (*val) as u8
             }
 
@@ -168,7 +168,7 @@ fn fannkuch(n: i32) -> (i32, i32) {
     for (i, j) in range(0, N).zip(iter::count(0, k)) {
         let max = cmp::min(j+k, perm.max());
 
-        futures.push(Thread::spawn(move|| {
+        futures.push(Thread::scoped(move|| {
             work(perm, j as uint, max as uint)
         }))
     }
index bbbfb0051f99bd069805fdf9fe3bae753d0c9ecb..9a6152dc13c9d4429ef36f97fd12ac65b02be735 100644 (file)
@@ -130,7 +130,7 @@ fn make(&mut self, n: uint) -> IoResult<()> {
         copy_memory(buf.as_mut_slice(), alu);
         let buf_len = buf.len();
         copy_memory(buf.slice_mut(alu_len, buf_len),
-                    alu[..LINE_LEN]);
+                    &alu[0..LINE_LEN]);
 
         let mut pos = 0;
         let mut bytes;
@@ -206,7 +206,7 @@ fn make(&mut self, n: uint) -> IoResult<()> {
         for i in range(0u, chars_left) {
             buf[i] = self.nextc();
         }
-        self.out.write(buf[..chars_left])
+        self.out.write(&buf[0..chars_left])
     }
 }
 
index 9128930651f25ec6fd77ea6a1a7821ca214ba09b..29994f45d3af27b3726903ce8658756e49b638a7 100644 (file)
@@ -99,7 +99,7 @@ fn make_fasta<W: Writer, I: Iterator<Item=u8>>(
         }
         n -= nb;
         line[nb] = '\n' as u8;
-        try!(wr.write(line[..nb+1]));
+        try!(wr.write(&line[..(nb+1)]));
     }
     Ok(())
 }
index e6ef6a8c8c9ec4da7841ca5e263852b94cb25933..3845c6c593c5fe9abf368d77210b95412ec51b99 100644 (file)
@@ -101,11 +101,11 @@ fn windows_with_carry<F>(bb: &[u8], nn: uint, mut it: F) -> Vec<u8> where
 
    let len = bb.len();
    while ii < len - (nn - 1u) {
-      it(bb[ii..ii+nn]);
+      it(&bb[ii..(ii+nn)]);
       ii += 1u;
    }
 
-   return bb[len - (nn - 1u)..len].to_vec();
+   return bb[(len - (nn - 1u))..len].to_vec();
 }
 
 fn make_sequence_processor(sz: uint,
@@ -173,7 +173,7 @@ fn main() {
 
         Thread::spawn(move|| {
             make_sequence_processor(sz, &from_parent, &to_parent_);
-        }).detach();
+        });
 
         to_child
     }).collect::<Vec<Sender<Vec<u8> >> >();
index 28d7488c9bf8f837f3458d0d2f0d9b0d180a0c58..d0ff47628d432295715ff1c5c77434d1f62e345e 100644 (file)
@@ -247,14 +247,14 @@ fn generate_frequencies(mut input: &[u8], frame: uint) -> Table {
     // Pull first frame.
     for _ in range(0, frame) {
         code = code.push_char(input[0]);
-        input = input[1..];
+        input = &input[1..];
     }
     frequencies.lookup(code, BumpCallback);
 
     while input.len() != 0 && input[0] != ('>' as u8) {
         code = code.rotate(input[0], frame);
         frequencies.lookup(code, BumpCallback);
-        input = input[1..];
+        input = &input[1..];
     }
     frequencies
 }
@@ -304,11 +304,11 @@ fn main() {
 
     let nb_freqs: Vec<_> = range(1u, 3).map(|i| {
         let input = input.clone();
-        (i, Thread::spawn(move|| generate_frequencies(input.as_slice(), i)))
+        (i, Thread::scoped(move|| generate_frequencies(input.as_slice(), i)))
     }).collect();
     let occ_freqs: Vec<_> = OCCURRENCES.iter().map(|&occ| {
         let input = input.clone();
-        Thread::spawn(move|| generate_frequencies(input.as_slice(), occ.len()))
+        Thread::scoped(move|| generate_frequencies(input.as_slice(), occ.len()))
     }).collect();
 
     for (i, freq) in nb_freqs.into_iter() {
index 16d6036d4c40ff8eb9b6d228941e37b088a41815..f6124c1271f05b1df5d31d81fdc630ea121e5eb0 100644 (file)
@@ -82,7 +82,7 @@ fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
     let mut precalc_i = Vec::with_capacity(h);
 
     let precalc_futures = range(0, WORKERS).map(|i| {
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             let mut rs = Vec::with_capacity(w / WORKERS);
             let mut is = Vec::with_capacity(w / WORKERS);
 
@@ -123,7 +123,7 @@ fn mandelbrot<W: io::Writer>(w: uint, mut out: W) -> io::IoResult<()> {
         let vec_init_r = arc_init_r.clone();
         let vec_init_i = arc_init_i.clone();
 
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             let mut res: Vec<u8> = Vec::with_capacity((chunk_size * w) / 8);
             let init_r_slice = vec_init_r.as_slice();
 
index ca3d10afa5d47e38ee02e001c62f916844cece64..34a036eff375024fb839b8daaf2000b0f5c5fcb7 100644 (file)
@@ -321,7 +321,7 @@ fn par_search(masks: Vec<Vec<Vec<u64>>>) -> Data {
             let mut data = Data::new();
             search(&*masks, m, 1, List::Cons(m, &List::Nil), &mut data);
             tx.send(data).unwrap();
-        }).detach();
+        });
     }
 
     // collecting the results
index 84ceb432048bc674996125967ac7e21b636b42fa..3953d3f9cdd33a7789a74f3eb9f85b6df4029ff0 100644 (file)
@@ -35,15 +35,15 @@ fn pfib(tx: &Sender<int>, n: int) {
         } else {
             let (tx1, rx) = channel();
             let tx2 = tx1.clone();
-            Thread::spawn(move|| pfib(&tx2, n - 1)).detach();
+            Thread::spawn(move|| pfib(&tx2, n - 1));
             let tx2 = tx1.clone();
-            Thread::spawn(move|| pfib(&tx2, n - 2)).detach();
+            Thread::spawn(move|| pfib(&tx2, n - 2));
             tx.send(rx.recv().unwrap() + rx.recv().unwrap());
         }
     }
 
     let (tx, rx) = channel();
-    Thread::spawn(move|| pfib(&tx, n) ).detach();
+    Thread::spawn(move|| pfib(&tx, n) );
     rx.recv().unwrap()
 }
 
@@ -78,7 +78,7 @@ fn stress_task(id: int) {
 fn stress(num_tasks: int) {
     let mut results = Vec::new();
     for i in range(0, num_tasks) {
-        results.push(Thread::spawn(move|| {
+        results.push(Thread::scoped(move|| {
             stress_task(i);
         }));
     }
index 77bae87c7dd219e01d674909604b5be9db8c9c68..3003a88e972b434411e1ac9759a8dcfd5e3d8362 100644 (file)
@@ -241,7 +241,7 @@ fn parallel<'a, I, T, F>(mut iter: I, f: F)
         // boundary.
         let f = Racy(&f as *const F as *const uint);
         let raw = Racy(chunk.repr());
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             let f = f.0 as *const F;
             unsafe { (*f)(mem::transmute(raw.0)) }
         })
index f3a593472256aacc0cc1358a8f15b25ac5abf2d7..f332a40164dd8c2d2576fd6febc12956abd33115 100644 (file)
@@ -128,7 +128,7 @@ fn parallel<T, F>(v: &mut [T], f: F)
         // boundary.
         let f = Racy(&f as *const _ as *const uint);
         let raw = Racy(chunk.repr());
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             let f = f.0 as *const F;
             unsafe { (*f)(i * size, mem::transmute(raw.0)) }
         })
index 9dd1003785051e4c7a21c7e300554288d241dd56..da427b36e8d0fe2e1bf7ddfe45b5feb920d4240c 100644 (file)
@@ -46,10 +46,10 @@ fn start(n_tasks: int, token: int) {
     tx.send(token);
     for i in range(2, n_tasks + 1) {
         let (tx, next_rx) = channel();
-        Thread::spawn(move|| roundtrip(i, tx, rx)).detach();
+        Thread::spawn(move|| roundtrip(i, tx, rx));
         rx = next_rx;
     }
-    Thread::spawn(move|| roundtrip(1, tx, rx)).detach();
+    Thread::spawn(move|| roundtrip(1, tx, rx));
 }
 
 fn roundtrip(id: int, tx: Sender<int>, rx: Receiver<int>) {
index 9e78ede74ca917ef9df1b119cda056e1c29bb76e..55e8dcbb6e8fbf4af74fd0611077f366880528cd 100644 (file)
@@ -36,7 +36,7 @@ fn main() {
 fn run(repeat: int, depth: int) {
     for _ in range(0, repeat) {
         let dur = Duration::span(|| {
-            let _ = Thread::spawn(move|| {
+            let _ = Thread::scoped(move|| {
                 recurse_or_panic(depth, None)
             }).join();
         });
index 30918d49090350fc28142d902c5898e1aec9bfa4..a2a380279f34d69538c90feaa0ff5a80fddadc24 100644 (file)
@@ -35,7 +35,7 @@ fn child_generation(gens_left: uint, tx: Sender<()>) {
         } else {
             tx.send(()).unwrap()
         }
-    }).detach();
+    });
 }
 
 fn main() {
index 488a5ec9edada04ef3cdd8848b28031956e32e06..eb1e30e2846766e0a0ef3a5e9a6f49b36210c81e 100644 (file)
@@ -15,7 +15,7 @@
 fn f(n: uint) {
     let mut i = 0u;
     while i < n {
-        let _ = Thread::spawn(move|| g()).join();
+        let _ = Thread::scoped(move|| g()).join();
         i += 1u;
     }
 }
@@ -33,5 +33,5 @@ fn main() {
     };
     let n = args[1].parse().unwrap();
     let mut i = 0u;
-    while i < n { Thread::spawn(move|| f(n) ).detach(); i += 1u; }
+    while i < n { Thread::spawn(move|| f(n) ); i += 1u; }
 }
index 7edb4b8754a1fa90f848f8ed4f50703b6594bbaf..6581019fdd52061bbc7507059ada4c55fa99b83e 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 fn main() {
-    let _x: int = [1i, 2, 3]; //~ ERROR expected int, found array of 3 elements
+    let _x: isize = [1is, 2, 3]; //~ ERROR expected isize, found array of 3 elements
 
-    let x: &[int] = &[1, 2, 3];
-    let _y: &int = x; //~ ERROR expected int, found slice
+    let x: &[isize] = &[1, 2, 3];
+    let _y: &isize = x; //~ ERROR expected isize, found slice
 }
index 0f18a84cd1ae317186030e7b9639379d31fe4bd8..b56f971db7449d32ec246e7582bd7e6faa5f2592 100644 (file)
@@ -41,6 +41,6 @@ pub fn baz(x: &Foo<A=Bar>) {
 
 pub fn main() {
     let a = 42i;
-    foo1(a); //~ERROR expected uint, found struct Bar
-    baz(&a); //~ERROR expected uint, found struct Bar
+    foo1(a); //~ERROR expected usize, found struct Bar
+    baz(&a); //~ERROR expected usize, found struct Bar
 }
index b04b83e575bf445dd526a5494e34a4ca24e7e1e6..13f6dcc9fdee43bc32beb4ba39c1bcbab10ffb26 100644 (file)
@@ -17,8 +17,8 @@ trait Foo<T> {
 }
 
 fn f<T:Foo<int>>(t: &T) {
-    let u: <T as Foo<uint>>::Bar = t.get_bar();
-    //~^ ERROR the trait `Foo<uint>` is not implemented for the type `T`
+    let u: <T as Foo<usize>>::Bar = t.get_bar();
+    //~^ ERROR the trait `Foo<usize>` is not implemented for the type `T`
 }
 
 fn main() { }
index ef85fc22fe7d442808835d106899d4d229ff0fe2..9994a0c465f79fabf83cb28f75177df5d1fffeff 100644 (file)
@@ -24,29 +24,29 @@ pub fn f2<T: Foo>(a: T) -> T::A {
 }
 
 pub fn f1_int_int() {
-    f1(2i, 4i);
-    //~^ ERROR expected uint, found int
+    f1(2is, 4is);
+    //~^ ERROR expected usize, found isize
 }
 
 pub fn f1_int_uint() {
-    f1(2i, 4u);
+    f1(2is, 4us);
 }
 
 pub fn f1_uint_uint() {
-    f1(2u, 4u);
+    f1(2us, 4us);
     //~^ ERROR the trait `Foo` is not implemented
     //~| ERROR the trait `Foo` is not implemented
 }
 
 pub fn f1_uint_int() {
-    f1(2u, 4i);
+    f1(2us, 4is);
     //~^ ERROR the trait `Foo` is not implemented
     //~| ERROR the trait `Foo` is not implemented
 }
 
 pub fn f2_int() {
-    let _: int = f2(2i);
-    //~^ ERROR expected `int`, found `uint`
+    let _: int = f2(2is);
+    //~^ ERROR expected `isize`, found `usize`
 }
 
 pub fn main() { }
index db39eafc1912bb5064679d2af3ec8fecb5a8b4cc..e4b97ab5933cebe0bb2451a7f4fe0c6b9ffa49d3 100644 (file)
@@ -14,7 +14,7 @@ trait Get {
 }
 
 fn foo<T:Get>(t: T) {
-    let x = t.get(); //~ ERROR the trait `core::kinds::Sized` is not implemented
+    let x = t.get(); //~ ERROR the trait `core::marker::Sized` is not implemented
 }
 
 fn main() {
index 7aa3b30ce4919373468783639d78316033c8e4e5..bbe5af1b51675674a88c84158f8d6605b7a177e8 100644 (file)
@@ -9,24 +9,24 @@
 // except according to those terms.
 
 struct clam {
-    x: Box<int>,
-    y: Box<int>,
+    x: Box<isize>,
+    y: Box<isize>,
 }
 
 struct fish {
-    a: Box<int>,
+    a: Box<isize>,
 }
 
 fn main() {
     let a: clam = clam{x: box 1, y: box 2};
     let b: clam = clam{x: box 10, y: box 20};
-    let z: int = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<int>`
+    let z: isize = a.x + b.y; //~ ERROR binary operation `+` cannot be applied to type `Box<isize>`
     println!("{}", z);
     assert_eq!(z, 21);
     let forty: fish = fish{a: box 40};
     let two: fish = fish{a: box 2};
     let answer: int = forty.a + two.a;
-    //~^ ERROR binary operation `+` cannot be applied to type `Box<int>`
+    //~^ ERROR binary operation `+` cannot be applied to type `Box<isize>`
     println!("{}", answer);
     assert_eq!(answer, 42);
 }
index 13b19141c16cca344dd04440cc011eb4f8872dc3..2450f22669a5133045a24f23365b048521f6be0d 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:expected `collections::string::String`, found `int`
+// error-pattern:expected `collections::string::String`, found `isize`
 
-static i: String = 10i;
+static i: String = 10is;
 fn main() { println!("{}", i); }
index cf07dc02b9609cf509788b23042e05d077fd70e8..349c33a30a53196c3a01ffa02e2bdd2d6e60d749 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn foo<T:'static>() {
-    1u.bar::<T>(); //~ ERROR `core::kinds::Send` is not implemented
+    1u.bar::<T>(); //~ ERROR `core::marker::Send` is not implemented
 }
 
 trait bar {
index 4e0ad8088bee47c6d3fda00c68b4cbbbb29551db..69be6414e4c90e09657aba9d102e4dbf8f3ad69c 100644 (file)
@@ -16,8 +16,8 @@ trait Trait {}
 
 pub fn main() {
     let x: Vec<Trait + Sized> = Vec::new();
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
-    //~^^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
+    //~^^ ERROR the trait `core::marker::Sized` is not implemented
     let x: Vec<Box<RefCell<Trait + Sized>>> = Vec::new();
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
index 0a53293d67696b99f90e9949f86b9771d24140cb..0067121e6103a14d855e172e0bc2c42ebb52bfa9 100644 (file)
@@ -8,6 +8,6 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:`&&` cannot be applied to type `int`
+// error-pattern:`&&` cannot be applied to type `isize`
 
-fn main() { let x = 1i && 2i; }
+fn main() { let x = 1is && 2is; }
index 7849475ec67991cb519cf33dff826920764bfc84..efb7a5253ed3df8b3160d21ca1b2503349baa04c 100644 (file)
@@ -17,12 +17,12 @@ fn takes_imm_elt<F>(_v: &int, f: F) where F: FnOnce() {
 }
 
 fn has_mut_vec_and_does_not_try_to_change_it() {
-    let mut v = vec!(1, 2, 3);
+    let mut v: Vec<int> = vec!(1, 2, 3);
     takes_imm_elt(&v[0], || {})
 }
 
 fn has_mut_vec_but_tries_to_change_it() {
-    let mut v = vec!(1, 2, 3);
+    let mut v: Vec<int> = vec!(1, 2, 3);
     takes_imm_elt(
         &v[0],
         || { //~ ERROR cannot borrow `v` as mutable
index ea36c76ea40580d161a7117c9add3b141e99cb5b..730a0c3e235455f92dbdd42004665b2120ee20c0 100644 (file)
@@ -10,7 +10,7 @@
 
 // Ensure that moves out of static items is forbidden
 
-use std::kinds::marker;
+use std::marker;
 
 struct Foo {
     foo: int,
index 047ab93530b265fc92e0d14083bbfddac924af5c..23ef5331b495f0fabcbee953aee4da5a4f22df9e 100644 (file)
@@ -35,7 +35,7 @@ pub fn main() {
                 }
             }
             let z = tail[0].clone();
-            println!("{}", z);
+            println!("{:?}", z);
         }
         _ => {
             unreachable!();
index 23cd4d80724e0c5523b25cf3cf763b6af56c51ca..98a29f01faf1c486846e04ce6ac5d300c8568c98 100644 (file)
@@ -12,7 +12,7 @@
 // move, when the struct implements Drop.
 
 // NoCopy
-use std::kinds::marker::NoCopy as NP;
+use std::marker::NoCopy as NP;
 
 
 struct S { a: int, np: NP }
index f3b9c395e45145206dea3aecc332e1da1f4b9d3f..cd215a7373780170e02eed6cb3e3aaf30ac787b6 100644 (file)
@@ -13,9 +13,9 @@
 
 trait Foo : Send+Sync { }
 
-impl <T: Sync+'static> Foo for (T,) { } //~ ERROR the trait `core::kinds::Send` is not implemented
+impl <T: Sync+'static> Foo for (T,) { } //~ ERROR the trait `core::marker::Send` is not implemented
 
-impl <T: Send> Foo for (T,T) { } //~ ERROR the trait `core::kinds::Sync` is not implemented
+impl <T: Send> Foo for (T,T) { } //~ ERROR the trait `core::marker::Sync` is not implemented
 
 impl <T: Send+Sync> Foo for (T,T,T) { } // (ok)
 
index 76835c9955f6ea6af3ae2cf6d035414daee7e4da..138fcfa8b64fe06c1ce668c766e77c89b24acf0c 100644 (file)
@@ -22,6 +22,6 @@
 impl <T:Sync> RequiresShare for X<T> { }
 
 impl <T:Sync+'static> RequiresRequiresShareAndSend for X<T> { }
-//~^ ERROR the trait `core::kinds::Send` is not implemented
+//~^ ERROR the trait `core::marker::Send` is not implemented
 
 fn main() { }
index e77177f7f6d296ad68929b9498913dedcef45bb2..534bb6d37ec39104bdb35d53ee08069c01c74e0c 100644 (file)
@@ -12,6 +12,6 @@
 
 trait Foo : Send { }
 
-impl <T: Sync+'static> Foo for T { } //~ ERROR the trait `core::kinds::Send` is not implemented
+impl <T: Sync+'static> Foo for T { } //~ ERROR the trait `core::marker::Send` is not implemented
 
 fn main() { }
index 54dccebe69953dc720a7780766763c0bfd0ed3b0..1c7ae05961e66bf373b8650e911b308d328ba6b5 100644 (file)
@@ -10,7 +10,7 @@
 
 // Verifies all possible restrictions for statics values.
 
-use std::kinds::marker;
+use std::marker;
 
 struct WithDtor;
 
index a02d6b7f5173acc3ea6b4f4f36b03baf020f4c02..b88040cbd54a622ec02a824f06b775e286119b8c 100644 (file)
@@ -13,7 +13,7 @@ struct X<F> where F: FnOnce() + 'static + Send {
 }
 
 fn foo<F>(blk: F) -> X<F> where F: FnOnce() + 'static {
-    //~^ ERROR the trait `core::kinds::Send` is not implemented for the type
+    //~^ ERROR the trait `core::marker::Send` is not implemented for the type
     return X { field: blk };
 }
 
index 509fffc5c9a882e2806b64b587fbf15d1c73e7e5..fadaa84f19db535b6ef5096b9bc0d6dbc23f1aea 100644 (file)
@@ -21,7 +21,7 @@ fn give_any<F>(f: F) where F: FnOnce() {
 
 fn give_owned<F>(f: F) where F: FnOnce() + Send {
     take_any(f);
-    take_const_owned(f); //~ ERROR the trait `core::kinds::Sync` is not implemented for the type
+    take_const_owned(f); //~ ERROR the trait `core::marker::Sync` is not implemented for the type
 }
 
 fn main() {}
index b6b46fadb13dae444559ffddb0dea65141e5c3ff..8d48ede0e154308afc4388799985dcf596f30181 100644 (file)
@@ -11,5 +11,5 @@
 // Tests that we forbid coercion from `[T; n]` to `&[T]`
 
 fn main() {
-    let _: &[int] = [0i]; //~ERROR: mismatched types: expected `&[int]`, found `[int; 1]`
+    let _: &[isize] = [0is]; //~ERROR: mismatched types: expected `&[isize]`, found `[isize; 1]`
 }
index d88b8751ea7b02c495329b51a5a569a2924572ae..d86256a77765ee99153f57cd0a261e44fda827eb 100644 (file)
@@ -11,9 +11,9 @@
 // aux-build:coherence-lib.rs
 
 extern crate "coherence-lib" as lib;
-use lib::Remote;
+use lib::Remote1;
 
-impl<T> Remote for int { }
+impl<T> Remote1<T> for int { }
 //~^ ERROR E0117
 
 fn main() { }
index 2e535b3950938cbb2bdbf7e51ed303075d2d651b..a7962c09fb3b96a447ee95a1925cfe8b439eeea2 100644 (file)
@@ -13,5 +13,5 @@
 fn test<T: Sync>() {}
 
 fn main() {
-    test::<Receiver<int>>();   //~ ERROR: `core::kinds::Sync` is not implemented
+    test::<Receiver<int>>();   //~ ERROR: `core::marker::Sync` is not implemented
 }
index 1b1c43e4793e339c42a7a623c3a93d201a398e3b..1977438d42320d94842fc9e37d95602a26d5b159 100644 (file)
@@ -13,5 +13,5 @@
 fn test<T: Sync>() {}
 
 fn main() {
-    test::<Sender<int>>();     //~ ERROR: `core::kinds::Sync` is not implemented
+    test::<Sender<int>>();     //~ ERROR: `core::marker::Sync` is not implemented
 }
index 98cf7009f0f08f962daa4e75a3719648f677c373..01c6970506cd36543a05e3fe6b4ef58531307113 100644 (file)
@@ -27,5 +27,5 @@ fn main() {
     let x = foo(10);
     let _y = x.clone();
     //~^ ERROR does not implement any method in scope
-    println!("{}", x);
+    println!("{:?}", x);
 }
index 5e360b6ab9bad8fa2d4e40dd5fbdc022bc7ee17b..ebd0ee97efec4840196caf65991cfdf2d2737f21 100644 (file)
@@ -43,5 +43,5 @@ pub fn main() {
     let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
     let z: Box<ToBar> = box Bar1 {f: 36};
     f5.ptr = *z;
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
index cc709be99002ea2a35ca44d04f6c9823409a30fd..f52c990ca52eb8081f192184423f162644dd4fd3 100644 (file)
@@ -43,5 +43,5 @@ pub fn main() {
     let f5: &mut Fat<ToBar> = &mut Fat { f1: 5, f2: "some str", ptr: Bar1 {f :42} };
     let z: Box<ToBar> = box Bar1 {f: 36};
     f5.ptr = Bar1 {f: 36}; //~ ERROR mismatched types: expected `ToBar`, found `Bar1`
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `ToBar`
+    //~^ ERROR the trait `core::marker::Sized` is not implemented for the type `ToBar`
 }
index 75bd94331b11d591b431c31d1872106fd2d839b9..e70db87a39a4176007cf87e4061641b78debf4a0 100644 (file)
@@ -18,11 +18,11 @@ struct Fat<T: ?Sized> {
 trait Bar {}
 
 pub fn main() {
-    // With a vec of ints.
+    // With a vec of isize.
     let f1 = Fat { ptr: [1, 2, 3] };
-    let f2: &Fat<[int; 3]> = &f1;
-    let f3: &Fat<[uint]> = f2;
-    //~^ ERROR mismatched types: expected `&Fat<[uint]>`, found `&Fat<[int; 3]>`
+    let f2: &Fat<[isize; 3]> = &f1;
+    let f3: &Fat<[usize]> = f2;
+    //~^ ERROR mismatched types: expected `&Fat<[usize]>`, found `&Fat<[isize; 3]>`
 
     // With a trait.
     let f1 = Fat { ptr: Foo };
index 53ce18c73a08845e011927466a983e99f822653e..8e81eacae921ea90f4b28edd6ced111297fb8f31 100644 (file)
@@ -15,8 +15,8 @@ struct Fat<T: ?Sized> {
 }
 
 pub fn main() {
-    // With a vec of ints.
-    let f1: &Fat<[int]> = &Fat { ptr: [1, 2, 3] };
-    let f2: &Fat<[int; 3]> = f1;
-    //~^ ERROR mismatched types: expected `&Fat<[int; 3]>`, found `&Fat<[int]>`
+    // With a vec of isizes.
+    let f1: &Fat<[isize]> = &Fat { ptr: [1, 2, 3] };
+    let f2: &Fat<[isize; 3]> = f1;
+    //~^ ERROR mismatched types: expected `&Fat<[isize; 3]>`, found `&Fat<[isize]>`
 }
index b169824cb3aca2e40a44473aca31a23bee64e319..0276e2e418df852b55e5e7d66ac9302714dab491 100644 (file)
@@ -21,5 +21,5 @@ pub fn main() {
     let f: Fat<[int; 3]> = Fat { ptr: [5i, 6, 7] };
     let g: &Fat<[int]> = &f;
     let h: &Fat<Fat<[int]>> = &Fat { ptr: *g };
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
index 3c75b5b6eddb8b77cacbd767680f76ddb01c546b..87ff4291f50e2d8f3ad951f338b8452508f189e1 100644 (file)
@@ -15,22 +15,22 @@ impl Foo for str {}
 
 fn test1<T: ?Sized + Foo>(t: &T) {
     let u: &Foo = t;
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `T`
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `T`
 }
 
 fn test2<T: ?Sized + Foo>(t: &T) {
     let v: &Foo = t as &Foo;
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `T`
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `T`
 }
 
 fn test3() {
     let _: &[&Foo] = &["hi"];
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `str`
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `str`
 }
 
 fn test4() {
     let _: &Foo = "hi" as &Foo;
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `str`
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `str`
 }
 
 fn main() { }
index ea5becbf229c0e0aca0c1602e6e953783ac0b467..3436c8d488c70710743c00bedae0a006a548f3df 100644 (file)
 
 trait Foo<T> : Sized { fn take(self, x: &T) { } } // Note: T is sized
 
-impl Foo<[int]> for uint { }
-//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[int]`
+impl Foo<[isize]> for usize { }
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[isize]`
 
-impl Foo<int> for [uint] { }
-//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[uint]`
+impl Foo<isize> for [usize] { }
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[usize]`
 
 pub fn main() { }
index 3d25c7ee772f626f95963eb35bf63d26d7003355..d79b3f472d06b70bd53436e6990058290ae86071 100644 (file)
@@ -13,5 +13,5 @@
 fn check_bound<T:Copy>(_: T) {}
 
 fn main() {
-    check_bound("nocopy".to_string()); //~ ERROR the trait `core::kinds::Copy` is not implemented
+    check_bound("nocopy".to_string()); //~ ERROR the trait `core::marker::Copy` is not implemented
 }
index 3eeb4c177cad60db4639b9034cea6c3c531f5cab..06e8412ddaa23289073a5d5c086c2a8b8b332c5c 100644 (file)
 
 #![feature(unboxed_closures)]
 
-fn needs_fn<F>(x: F) where F: Fn(int) -> int {}
+fn needs_fn<F>(x: F) where F: Fn(isize) -> isize {}
 
 fn main() {
-    let _: () = (box |:_: int| {}) as Box<FnOnce(int)>; //~ ERROR object-safe
-    //~^ ERROR Box<core::ops::FnOnce(int)>
-    let _: () = (box |&:_: int, int| {}) as Box<Fn(int, int)>;
-    //~^ ERROR Box<core::ops::Fn(int, int)>
-    let _: () = (box |&mut:| -> int unimplemented!()) as Box<FnMut() -> int>;
-    //~^ ERROR Box<core::ops::FnMut() -> int>
+    let _: () = (box |:_: isize| {}) as Box<FnOnce(isize)>; //~ ERROR object-safe
+    //~^ ERROR Box<core::ops::FnOnce(isize)>
+    let _: () = (box |&:_: isize, isize| {}) as Box<Fn(isize, isize)>;
+    //~^ ERROR Box<core::ops::Fn(isize, isize)>
+    let _: () = (box |&mut:| -> isize unimplemented!()) as Box<FnMut() -> isize>;
+    //~^ ERROR Box<core::ops::FnMut() -> isize>
 
-    needs_fn(1i); //~ ERROR `core::ops::Fn(int) -> int`
+    needs_fn(1i); //~ ERROR `core::ops::Fn(isize) -> isize`
 }
index c5e7fc82cc9949aebd61a2ae0786a46c540f37b4..5ab946a53e5cc8490e000d9b5af5b6e910e97ec6 100644 (file)
@@ -11,7 +11,7 @@
 // Test that we use fully-qualified type names in error messages.
 
 fn main() {
-    let x: Option<uint>;
+    let x: Option<usize>;
     x = 5;
-    //~^ ERROR mismatched types: expected `core::option::Option<uint>`
+    //~^ ERROR mismatched types: expected `core::option::Option<usize>`
 }
index 768ae6353d225c1e520c27ba7f2581d9d0c3926a..9250444c3e6cd2ba69e4e0adbce1fa7b15d2b60e 100644 (file)
@@ -12,9 +12,9 @@
 
 use std::option::Option;
 
-fn bar(x: uint) -> Option<uint> {
+fn bar(x: usize) -> Option<usize> {
     return x;
-    //~^ ERROR mismatched types: expected `core::option::Option<uint>`
+    //~^ ERROR mismatched types: expected `core::option::Option<usize>`
 }
 
 fn main() {
index 5bdee543d738de77c87f5226a46b09855f41e62d..5769b9d7932c03d719bcea7bd02fcdfca39a8efd 100644 (file)
 
 fn main() {
     // Ensure that the printed type doesn't include the default type params...
-    let _: Foo<int> = ();
-    //~^ ERROR mismatched types: expected `Foo<int>`, found `()`
+    let _: Foo<isize> = ();
+    //~^ ERROR mismatched types: expected `Foo<isize>`, found `()`
 
     // ...even when they're present, but the same types as the defaults.
-    let _: Foo<int, B, C> = ();
-    //~^ ERROR mismatched types: expected `Foo<int>`, found `()`
+    let _: Foo<isize, B, C> = ();
+    //~^ ERROR mismatched types: expected `Foo<isize>`, found `()`
 
     // Including cases where the default is using previous type params.
-    let _: HashMap<String, int> = ();
-    //~^ ERROR mismatched types: expected `HashMap<collections::string::String, int>`, found `()`
-    let _: HashMap<String, int, Hash<String>> = ();
-    //~^ ERROR mismatched types: expected `HashMap<collections::string::String, int>`, found `()`
+    let _: HashMap<String, isize> = ();
+    //~^ ERROR mismatched types: expected `HashMap<collections::string::String, isize>`, found `()`
+    let _: HashMap<String, isize, Hash<String>> = ();
+    //~^ ERROR mismatched types: expected `HashMap<collections::string::String, isize>`, found `()`
 
     // But not when there's a different type in between.
-    let _: Foo<A, int, C> = ();
-    //~^ ERROR mismatched types: expected `Foo<A, int>`, found `()`
+    let _: Foo<A, isize, C> = ();
+    //~^ ERROR mismatched types: expected `Foo<A, isize>`, found `()`
 
     // And don't print <> at all when there's just defaults.
     let _: Foo<A, B, C> = ();
index 36a45400eec1a3e14406ae109c14025288864f2e..a1ec4a739e8cea03dbd55880b2eaf33d46eef86e 100644 (file)
@@ -16,22 +16,22 @@ fn foo(&self, x: X) { }
 }
 
 fn want_hrtb<T>()
-    where T : for<'a> Foo<&'a int>
+    where T : for<'a> Foo<&'a isize>
 {
 }
 
-// AnyInt implements Foo<&'a int> for any 'a, so it is a match.
+// AnyInt implements Foo<&'a isize> for any 'a, so it is a match.
 struct AnyInt;
-impl<'a> Foo<&'a int> for AnyInt { }
+impl<'a> Foo<&'a isize> for AnyInt { }
 fn give_any() {
     want_hrtb::<AnyInt>()
 }
 
-// StaticInt only implements Foo<&'static int>, so it is an error.
+// StaticInt only implements Foo<&'static isize>, so it is an error.
 struct StaticInt;
-impl Foo<&'static int> for StaticInt { }
+impl Foo<&'static isize> for StaticInt { }
 fn give_static() {
-    want_hrtb::<StaticInt>() //~ ERROR `for<'a> Foo<&'a int>` is not implemented
+    want_hrtb::<StaticInt>() //~ ERROR `for<'a> Foo<&'a isize>` is not implemented
 }
 
 fn main() { }
index a8ee2154fc396d5011070c69db58f74767c7d9fd..e8ecc0608fc4aeb1081bf617912250490c9123eb 100644 (file)
@@ -30,36 +30,36 @@ impl<'a,X,F> Bar<X> for &'a mut F
 }
 
 fn no_hrtb<'b,T>(mut t: T)
-    where T : Bar<&'b int>
+    where T : Bar<&'b isize>
 {
-    // OK -- `T : Bar<&'b int>`, and thus the impl above ensures that
-    // `&mut T : Bar<&'b int>`.
+    // OK -- `T : Bar<&'b isize>`, and thus the impl above ensures that
+    // `&mut T : Bar<&'b isize>`.
     no_hrtb(&mut t);
 }
 
 fn bar_hrtb<T>(mut t: T)
-    where T : for<'b> Bar<&'b int>
+    where T : for<'b> Bar<&'b isize>
 {
-    // OK -- `T : for<'b> Bar<&'b int>`, and thus the impl above
-    // ensures that `&mut T : for<'b> Bar<&'b int>`.  This is an
+    // OK -- `T : for<'b> Bar<&'b isize>`, and thus the impl above
+    // ensures that `&mut T : for<'b> Bar<&'b isize>`.  This is an
     // example of a "perfect forwarding" impl.
     bar_hrtb(&mut t);
 }
 
 fn foo_hrtb_bar_not<'b,T>(mut t: T)
-    where T : for<'a> Foo<&'a int> + Bar<&'b int>
+    where T : for<'a> Foo<&'a isize> + Bar<&'b isize>
 {
     // Not OK -- The forwarding impl for `Foo` requires that `Bar` also
     // be implemented. Thus to satisfy `&mut T : for<'a> Foo<&'a
-    // int>`, we require `T : for<'a> Bar<&'a int>`, but the where
-    // clause only specifies `T : Bar<&'b int>`.
-    foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> Bar<&'a int>` is not implemented for the type `T`
+    // isize>`, we require `T : for<'a> Bar<&'a isize>`, but the where
+    // clause only specifies `T : Bar<&'b isize>`.
+    foo_hrtb_bar_not(&mut t); //~ ERROR `for<'a> Bar<&'a isize>` is not implemented for the type `T`
 }
 
 fn foo_hrtb_bar_hrtb<T>(mut t: T)
-    where T : for<'a> Foo<&'a int> + for<'b> Bar<&'b int>
+    where T : for<'a> Foo<&'a isize> + for<'b> Bar<&'b isize>
 {
-    // OK -- now we have `T : for<'b> Bar&'b int>`.
+    // OK -- now we have `T : for<'b> Bar&'b isize>`.
     foo_hrtb_bar_hrtb(&mut t);
 }
 
index 9fe8f9ab46ddc429fe07edad9ebf3fca50a6d8cc..7bb74d6b03a33e97b4606a7082d9823aaef9075e 100644 (file)
@@ -17,7 +17,7 @@ fn foo(&self, x: X) { }
 }
 
 fn want_foo<T>()
-    where T : for<'a> Foo<&'a int>
+    where T : for<'a> Foo<&'a isize>
 {
 }
 
@@ -28,7 +28,7 @@ struct SomeStruct<X> {
     x: X
 }
 
-impl<'a,X> Foo<&'a int> for SomeStruct<X>
+impl<'a,X> Foo<&'a isize> for SomeStruct<X>
     where X : 'a
 {
 }
@@ -36,8 +36,8 @@ impl<'a,X> Foo<&'a int> for SomeStruct<X>
 fn one() {
     // In fact there is no good reason for this to be an error, but
     // whatever, I'm mostly concerned it doesn't ICE right now:
-    want_foo::<SomeStruct<uint>>();
-    //~^ ERROR requirement `for<'a> uint : 'a` is not satisfied
+    want_foo::<SomeStruct<usize>>();
+    //~^ ERROR requirement `for<'a> usize : 'a` is not satisfied
 }
 
 ///////////////////////////////////////////////////////////////////////////
@@ -47,13 +47,13 @@ struct AnotherStruct<X> {
     x: X
 }
 
-impl<'a,X:'a> Foo<&'a int> for AnotherStruct<X>
+impl<'a,X:'a> Foo<&'a isize> for AnotherStruct<X>
 {
 }
 
 fn two() {
-    want_foo::<AnotherStruct<uint>>();
-    //~^ ERROR requirement `for<'a> uint : 'a` is not satisfied
+    want_foo::<AnotherStruct<usize>>();
+    //~^ ERROR requirement `for<'a> usize : 'a` is not satisfied
 }
 
 fn main() { }
index 4a8c72c3877c52cd0a3ff6713614e211e64881a5..be54554a3c02ff7d844bfefb50dc7a1346ab7f8e 100644 (file)
@@ -9,6 +9,6 @@
 // except according to those terms.
 
 fn main() {
-    let x = if true { 10i } else { 10u };
-    //~^ ERROR if and else have incompatible types: expected `int`, found `uint`
+    let x = if true { 10is } else { 10us };
+    //~^ ERROR if and else have incompatible types: expected `isize`, found `usize`
 }
index db7f49272aac8495296f83518a3e9f6ed7ac1585..7c929d2db16e73f044b9bc17198bcac098484334 100644 (file)
@@ -46,7 +46,7 @@ fn main() {
 
     // bad syntax of the format string
 
-    format!("{"); //~ ERROR: expected `}` but string was terminated
+    format!("{"); //~ ERROR: expected `'}'` but string was terminated
 
     format!("foo } bar"); //~ ERROR: unmatched `}` found
     format!("foo }"); //~ ERROR: unmatched `}` found
diff --git a/src/test/compile-fail/impl-unused-tps-inherent.rs b/src/test/compile-fail/impl-unused-tps-inherent.rs
new file mode 100644 (file)
index 0000000..3803bb9
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+struct MyType;
+
+struct MyType1<T>(T);
+
+trait Bar {
+    type Out;
+}
+
+impl<T> MyType {
+    //~^ ERROR  the type parameter `T` is not constrained
+}
+
+impl<T> MyType1<T> {
+    // OK, T is used in `Foo<T>`.
+}
+
+impl<T,U> MyType1<T> {
+    //~^ ERROR  the type parameter `U` is not constrained
+}
+
+impl<T,U> MyType1<T> where T: Bar<Out=U> {
+    // OK, T is used in `Foo<T>`.
+}
+
+fn main() { }
diff --git a/src/test/compile-fail/impl-unused-tps.rs b/src/test/compile-fail/impl-unused-tps.rs
new file mode 100644 (file)
index 0000000..99c6c6b
--- /dev/null
@@ -0,0 +1,72 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+trait Foo<A> {
+    fn get(&self, A: &A) { }
+}
+
+trait Bar {
+    type Out;
+}
+
+impl<T> Foo<T> for [int;0] {
+    // OK, T is used in `Foo<T>`.
+}
+
+impl<T,U> Foo<T> for [int;1] {
+    //~^ ERROR the type parameter `U` is not constrained
+}
+
+impl<T,U> Foo<T> for [int;2] where T : Bar<Out=U> {
+    // OK, `U` is now constrained by the output type parameter.
+}
+
+impl<T:Bar<Out=U>,U> Foo<T> for [int;3] {
+    // OK, same as above but written differently.
+}
+
+impl<T,U> Foo<T> for U {
+    // OK, T, U are used everywhere. Note that the coherence check
+    // hasn't executed yet, so no errors about overlap.
+}
+
+impl<T,U> Bar for T {
+    //~^ ERROR the type parameter `U` is not constrained
+
+    type Out = U;
+
+    // Using `U` in an associated type within the impl is not good enough!
+}
+
+impl<T,U> Bar for T
+    where T : Bar<Out=U>
+{
+    //~^^^ ERROR the type parameter `U` is not constrained
+
+    // This crafty self-referential attempt is still no good.
+}
+
+impl<T,U,V> Foo<T> for T
+    where (T,U): Bar<Out=V>
+{
+    //~^^^ ERROR the type parameter `U` is not constrained
+    //~|   ERROR the type parameter `V` is not constrained
+
+    // Here, `V` is bound by an output type parameter, but the inputs
+    // are not themselves constrained.
+}
+
+impl<T,U,V> Foo<(T,U)> for T
+    where (T,U): Bar<Out=V>
+{
+    // As above, but both T and U ARE constrained.
+}
+
+fn main() { }
index 9ac4bd2566e8be73dc61b5f964bd3ce169b3dbff..e5edb2358f8e15b29415ff0fa41af6055bf92aa3 100644 (file)
@@ -13,7 +13,8 @@
 
 fn main() {
     fn bar<T>(_: T) {}
-    [0][0u8]; //~ ERROR: mismatched types
+    [0][0u8]; //~ ERROR: the trait `core::ops::Index<u8>` is not implemented
+    //~^ ERROR: the trait `core::ops::Index<u8>` is not implemented
 
     [0][0]; // should infer to be a uint
 
index 8b1f9eb19864fadf3a9caf31f5dcb686b4a09a4c..bbceb00abd39d3e728da025dbc134b1b218fe863 100644 (file)
 pub fn main() {
     let v: Vec<int> = vec!(0, 1, 2, 3, 4, 5);
     let s: String = "abcdef".to_string();
-    assert_eq!(v.as_slice()[3u], 3);
-    assert_eq!(v.as_slice()[3u8], 3); //~ ERROR: mismatched types
-    assert_eq!(v.as_slice()[3i8], 3); //~ ERROR: mismatched types
-    assert_eq!(v.as_slice()[3u32], 3); //~ ERROR: mismatched types
-    assert_eq!(v.as_slice()[3i32], 3); //~ ERROR: mismatched types
-    println!("{}", v.as_slice()[3u8]); //~ ERROR: mismatched types
-    assert_eq!(s.as_bytes()[3u], 'd' as u8);
-    assert_eq!(s.as_bytes()[3u8], 'd' as u8); //~ ERROR: mismatched types
-    assert_eq!(s.as_bytes()[3i8], 'd' as u8); //~ ERROR: mismatched types
-    assert_eq!(s.as_bytes()[3u32], 'd' as u8); //~ ERROR: mismatched types
-    assert_eq!(s.as_bytes()[3i32], 'd' as u8); //~ ERROR: mismatched types
-    println!("{}", s.as_bytes()[3u8]); //~ ERROR: mismatched types
+    v.as_slice()[3u];
+    v.as_slice()[3];
+    v.as_slice()[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
+    //~^ ERROR the trait `core::ops::Index<i8>` is not implemented
+    v.as_slice()[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
+    //~^ ERROR the trait `core::ops::Index<i32>` is not implemented
+    s.as_bytes()[3u];
+    s.as_bytes()[3];
+    s.as_bytes()[3u8];  //~ERROR the trait `core::ops::Index<u8>` is not implemented
+    //~^ERROR the trait `core::ops::Index<u8>` is not implemented
+    s.as_bytes()[3i8];  //~ERROR the trait `core::ops::Index<i8>` is not implemented
+    //~^ERROR the trait `core::ops::Index<i8>` is not implemented
+    s.as_bytes()[3u32]; //~ERROR the trait `core::ops::Index<u32>` is not implemented
+    //~^ERROR the trait `core::ops::Index<u32>` is not implemented
+    s.as_bytes()[3i32]; //~ERROR the trait `core::ops::Index<i32>` is not implemented
+    //~^ERROR the trait `core::ops::Index<i32>` is not implemented
 }
index f537d5cad9779fd17be230c9f2cc9444a8869b81..832cc57bd24df396049d650659ff09a7d55a335c 100644 (file)
@@ -8,9 +8,9 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn f() -> int {
+fn f() -> isize {
     (return 1, return 2)
-//~^ ERROR mismatched types: expected `int`, found `(_, _)` (expected int, found tuple)
+//~^ ERROR mismatched types: expected `isize`, found `(_, _)` (expected isize, found tuple)
 }
 
 fn main() {}
index 8f7e6470f909530117d0c527fe0f5591ac48c0ef..2913ddf395fbb8928007e4e759ba6b8191f2df29 100644 (file)
@@ -10,5 +10,5 @@
 
 fn main() {
     let nil = ();
-    let _t = nil as uint; //~ ERROR: cast from nil: `()` as `uint`
+    let _t = nil as usize; //~ ERROR: cast from nil: `()` as `usize`
 }
index 78502efdec520f17d762af200a251fa09e36e0ee..24ffc5e9ee373de30f2b032561cd17ad8e0fa984 100644 (file)
@@ -22,27 +22,28 @@ trait Stream {
     fn result(&self) -> u64;
 }
 
-trait StreamHasher<S: Stream> {
-    fn stream(&self) -> S;
+trait StreamHasher {
+    type S : Stream;
+    fn stream(&self) -> Self::S;
 }
 
 //////////////////////////////////////////////////////////////////////////////
 
-trait StreamHash<S: Stream, H: StreamHasher<S>>: Hash<H> {
-    fn input_stream(&self, stream: &mut S);
+trait StreamHash<H: StreamHasher>: Hash<H> {
+    fn input_stream(&self, stream: &mut H::S);
 }
 
-impl<S: Stream, H: StreamHasher<S>> Hash<H> for u8 {
+impl<H: StreamHasher> Hash<H> for u8 {
     fn hash2(&self, hasher: &H) -> u64 {
         let mut stream = hasher.stream();
         self.input_stream(&mut stream); //~ ERROR type annotations required
-        stream.result()
+        Stream::result(&stream)
     }
 }
 
-impl<S: Stream, H: StreamHasher<S>> StreamHash<S, H> for u8 {
-    fn input_stream(&self, stream: &mut S) {
-        stream.input(&[*self]);
+impl<H: StreamHasher> StreamHash<H> for u8 {
+    fn input_stream(&self, stream: &mut H::S) {
+        Stream::input(&*stream, &[*self]);
     }
 }
 
index 83f6fb072329d88ddc1900540bfa275e3aa09006..39957a242268f885d4fc40d6a480e55846c1c538 100644 (file)
@@ -12,6 +12,6 @@
 
 //! Test that makes sure wrongly-typed bench functions are rejected
 
-// error-pattern:expected &-ptr, found int
+// error-pattern:expected &-ptr, found isize
 #[bench]
-fn bar(x: int) { }
+fn bar(x: isize) { }
index 8dda54efc06af31ba57089d4467604791c3d2ee9..8f50786405283db62c4defc55dc76215a7c7c1bf 100644 (file)
 
 trait Itble<'r, T, I: Iterator<Item=T>> { fn iter(&'r self) -> I; }
 
-impl<'r> Itble<'r, uint, Range<uint>> for (uint, uint) {
-    fn iter(&'r self) -> Range<uint> {
+impl<'r> Itble<'r, usize, Range<usize>> for (usize, usize) {
+    fn iter(&'r self) -> Range<usize> {
         let &(min, max) = self;
         range(min, max)
     }
 }
 
-fn check<'r, I: Iterator<Item=uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool
-//~^ HELP as shown: fn check<'r, I: Iterator<Item = uint>, T: Itble<'r, uint, I>>(cont: &'r T)
+fn check<'r, I: Iterator<Item=usize>, T: Itble<'r, usize, I>>(cont: &T) -> bool
+//~^ HELP as shown: fn check<'r, I: Iterator<Item = usize>, T: Itble<'r, usize, I>>(cont: &'r T)
 {
     let cont_iter = cont.iter();
 //~^ ERROR cannot infer an appropriate lifetime for autoref due to conflicting requirements
@@ -35,5 +35,5 @@ fn check<'r, I: Iterator<Item=uint>, T: Itble<'r, uint, I>>(cont: &T) -> bool
 
 fn main() {
     check((3u, 5u));
-//~^ ERROR mismatched types: expected `&_`, found `(uint, uint)` (expected &-ptr, found tuple)
+//~^ ERROR mismatched types: expected `&_`, found `(usize, usize)` (expected &-ptr, found tuple)
 }
index 5c72c7388a9ee2d34f187885a87f97f8149fe462..25e64e070f40b6325651f0d598c0e039d8341718 100644 (file)
@@ -14,8 +14,8 @@ fn bar(_s: u32) { }
 
 fn main() {
     foo(1*(1 as int));
-    //~^ ERROR: mismatched types: expected `i16`, found `int` (expected i16, found int)
+    //~^ ERROR: mismatched types: expected `i16`, found `isize` (expected i16, found isize)
 
     bar(1*(1 as uint));
-    //~^ ERROR: mismatched types: expected `u32`, found `uint` (expected u32, found uint)
+    //~^ ERROR: mismatched types: expected `u32`, found `usize` (expected u32, found usize)
 }
index e150c1a0f2fc83f8484419a5fc311f5ca9f416e0..7d554545b5ed27c94fbbc9b786a7794eff48ff92 100644 (file)
@@ -14,8 +14,8 @@ pub fn main() {
     // The expected arm type `Option<T>` has one type parameter, while
     // the actual arm `Result<T, E>` has two. typeck should not be
     // tricked into looking up a non-existing second type parameter.
-    let _x: uint = match Some(1u) {
-        Ok(u) => u, //~ ERROR  mismatched types: expected `core::option::Option<uint>`
-        Err(e) => panic!(e)  //~ ERROR mismatched types: expected `core::option::Option<uint>`
+    let _x: usize = match Some(1us) {
+        Ok(u) => u, //~ ERROR  mismatched types: expected `core::option::Option<usize>`
+        Err(e) => panic!(e)  //~ ERROR mismatched types: expected `core::option::Option<usize>`
     };
 }
index b3a4f341f8448f30aa6b76221d14fb31dbd23b39..6a017f7bb30c1bda6de09eb42c00331fce6736fb 100644 (file)
@@ -15,7 +15,7 @@ trait Deserializable {
 }
 
 impl<'a, T: Deserializable> Deserializable for &'a str {
-    //~^ ERROR unable to infer enough type information
+    //~^ ERROR type parameter `T` is not constrained
     fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str {
     }
 }
index d03885ca7133c57609af0bbb094a4baaa4c37525..c7cac71af036125ded2fdda44ffebcb7497a4610 100644 (file)
@@ -10,5 +10,5 @@
 
 fn main() {
     let _x = "test" as &::std::any::Any;
-//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `str`
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `str`
 }
index 6515b34d964e1051ee05dfc26336e3d8c483b823..3d8ebc1ecdf19e517bb197f93fe36bbece65ca47 100644 (file)
@@ -27,5 +27,5 @@ fn yay<T: Str>(_:Option<X>, thing: &[T]) {
 
 fn main() {
     let arr = &["one", "two", "three"];
-    println!("{}", Something::yay(None::<X>, arr));
+    println!("{:?}", Something::yay(None::<X>, arr));
 }
index 8cbbfb7b83a55bd1e7abd8d14b2c266fc36c631b..142fecc31fec139ff90cf3b6e9fab5dcaca3dbb5 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 fn main() {
-    let x: Box<int> = box 0;
+    let x: Box<isize> = box 0;
 
-    println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<int>`
+    println!("{}", x + 1); //~ ERROR binary operation `+` cannot be applied to type `Box<isize>`
 }
index dd3c88b8a10b4c7709c1aa85907a0959b62c4fbd..5292848f8ee45fcc38b5c8492464f070c47b040b 100644 (file)
@@ -19,7 +19,7 @@ struct Shower<T> {
 impl<T: fmt::Show> ops::Fn<(), ()> for Shower<T> {
     fn call(&self, _args: ()) {
 //~^ ERROR `call` has an incompatible type for trait: expected "rust-call" fn, found "Rust" fn
-        println!("{}", self.x);
+        println!("{:?}", self.x);
     }
 }
 
index 5be3b960ec635711d09cdff1ecb2623836257376..c2d30224dc87f8b8f2ce045754523a41d20c038a 100644 (file)
@@ -15,7 +15,7 @@ fn dft_iter<'a, T>(arg1: Chunks<'a,T>, arg2: ChunksMut<'a,T>)
 {
     for
     &something
-//~^ ERROR the trait `core::kinds::Sized` is not implemented for the type `[T]`
+//~^ ERROR the trait `core::marker::Sized` is not implemented for the type `[T]`
     in arg2
     {
     }
index 883e79d75e0968707d0b6c6bf35fad82f966c8a4..c886c97a63607bc43143181b5f06e2f8336bb1ed 100644 (file)
@@ -11,7 +11,7 @@
 #![deny(warnings)]
 
 extern {
-    pub fn foo(x: (int)); //~ ERROR found rust type `int` in foreign module
+    pub fn foo(x: (isize)); //~ ERROR found rust type `isize` in foreign module
 }
 
 fn main() {
index 0e022834bacf2fae3bd8103b25199791ee4aeec2..af686b8681316f6dcddd5d03316d7ce77eba23dd 100644 (file)
@@ -20,6 +20,6 @@ fn foo(value: *const X) -> *const X {
 
 static foo: *const Y::X = Y::foo(Y::x as *const Y::X);
 //~^ ERROR cannot refer to other statics by value
-//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
+//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
 
 fn main() {}
index 3c784c3b770e4f847884dcedc12b5bf86e040b4c..626a442a2c355aed067f28a1af4293f34f284f73 100644 (file)
@@ -18,7 +18,7 @@ struct Col<D, C> {
 trait Collection { fn len(&self) -> uint; }
 
 impl<T, M: MatrixShape> Collection for Col<M, uint> {
-//~^ ERROR unable to infer enough type information
+//~^ ERROR type parameter `T` is not constrained
     fn len(&self) -> uint {
         unimplemented!()
     }
diff --git a/src/test/compile-fail/issue-16709.rs b/src/test/compile-fail/issue-16709.rs
deleted file mode 100644 (file)
index 327f50e..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-use std::ptr;
-use std::raw;
-
-trait Slice {}
-
-fn main() {
-  unsafe {
-    let nil: *const u8 = ptr::null();
-    let slice: raw::Slice<u8> =
-      Slice { //~ ERROR use of trait `Slice` as a struct constructor [E0159]
-        data: nil,
-        len:  0,
-      };
-  }
-}
index e5da5c5504ef3e1b728113a85abac6d621494bb7..6ae4fbca8b04ccfd175bf339f74c25647ce51c13 100644 (file)
@@ -9,16 +9,16 @@
 // except according to those terms.
 
 fn main() {
-    let _foo = &[1u, 2] as [uint];
-    //~^ ERROR cast to unsized type: `&[uint; 2]` as `[uint]`
-    //~^^ HELP consider using an implicit coercion to `&[uint]` instead
+    let _foo = &[1u, 2] as [usize];
+    //~^ ERROR cast to unsized type: `&[usize; 2]` as `[usize]`
+    //~^^ HELP consider using an implicit coercion to `&[usize]` instead
     let _bar = box 1u as std::fmt::Show;
-    //~^ ERROR cast to unsized type: `Box<uint>` as `core::fmt::Show`
+    //~^ ERROR cast to unsized type: `Box<usize>` as `core::fmt::Show`
     //~^^ HELP did you mean `Box<core::fmt::Show>`?
     let _baz = 1u as std::fmt::Show;
-    //~^ ERROR cast to unsized type: `uint` as `core::fmt::Show`
+    //~^ ERROR cast to unsized type: `usize` as `core::fmt::Show`
     //~^^ HELP consider using a box or reference as appropriate
-    let _quux = [1u, 2] as [uint];
-    //~^ ERROR cast to unsized type: `[uint; 2]` as `[uint]`
+    let _quux = [1u, 2] as [usize];
+    //~^ ERROR cast to unsized type: `[usize; 2]` as `[usize]`
     //~^^ HELP consider using a box or reference as appropriate
 }
index 55570e93a9721a8aa092c66260947063ec050616..011a9c1777638b66b3ac8aa08736f9846745b90f 100644 (file)
@@ -13,6 +13,6 @@ enum Test {
 }
 
 fn main() {
-    let _x = Test::Foo as *const int;
-    //~^ ERROR illegal cast; cast through an integer first: `Test` as `*const int`
+    let _x = Test::Foo as *const isize;
+    //~^ ERROR illegal cast; cast through an integer first: `Test` as `*const isize`
 }
index 970b14c7eb7cc612224a3e12d1bbf226bbd78c5d..589f1cf44bf16778763dafc06bd45b0087e9847c 100644 (file)
@@ -12,7 +12,7 @@
 // and rejected.
 
 fn main() {
-    (|&:| box *[0u].as_slice())();
+    (|&:| box *[0us].as_slice())();
     //~^ ERROR cannot move out of dereference
-    //~^^ ERROR cannot move a value of type [uint]
+    //~^^ ERROR cannot move a value of type [usize]
 }
index c57df9a3af4a4f88392a6f739f55f689f42fb954..4f3668b819a589046595ea778df079ee4b39eed3 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 struct Foo { nc: marker::NoCopy }
 const INIT: Foo = Foo { nc: marker::NoCopy };
index 63a40e2374b15cbee042b0f1123a6e9e2c5d6771..147bff2e9777ef835e0b38dc34b77e6f0cd9bfd8 100644 (file)
@@ -8,12 +8,12 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 struct Foo { marker: marker::NoSync }
 
 static FOO: uint = 3;
 static BAR: Foo = Foo { marker: marker::NoSync };
-//~^ ERROR: the trait `core::kinds::Sync` is not implemented
+//~^ ERROR: the trait `core::marker::Sync` is not implemented
 
 fn main() {}
index ac2eb735637fa405782dda2c5e69f55a906d2496..66ef7b807f7c652665e5e473d6d4a2a78944447e 100644 (file)
@@ -123,8 +123,8 @@ fn str_to_direction(to_parse: &str) -> RoomDirection {
 fn main() {
     let mut player = Player::new("Test player");
     let mut room = Room::new("A test room");
-    println!("Made a player: {}", player);
-    println!("Direction parse: {}", str_to_direction("east"));
+    println!("Made a player: {:?}", player);
+    println!("Direction parse: {:?}", str_to_direction("east"));
     match player.attemptTraverse(&room, "west") {
         Ok(_) => println!("Was able to move west"),
         Err(msg) => println!("Not able to move west: {}", msg)
index 2b5c0b7de2f9baa9eabbc9519125daffead42864..1418cdf403993f7865ee094ca5a1a3094f14db46 100644 (file)
 
 impl Pair<
     &str, //~ ERROR missing lifetime specifier
-    int
+    isize
 > {
-    fn say(self: &Pair<&str, int>) {
-//~^ ERROR mismatched types: expected `Pair<&'static str, int>`, found `Pair<&str, int>`
+    fn say(self: &Pair<&str, isize>) {
+//~^ ERROR mismatched types: expected `Pair<&'static str, isize>`, found `Pair<&str, isize>`
         println!("{}", self);
     }
 }
 
 fn main() {
-    let result = &Pair("shane", 1i);
+    let result = &Pair("shane", 1is);
     result.say();
 }
index 6cebf7f9da14d94a219d6293a8fd79bf9432dac8..b8249ebd4792cc118e2709ec18d70cabca651119 100644 (file)
@@ -14,7 +14,7 @@ pub trait AbstractRenderer {}
 
 fn _create_render(_: &()) ->
     AbstractRenderer
-//~^ ERROR: the trait `core::kinds::Sized` is not implemented
+//~^ ERROR: the trait `core::marker::Sized` is not implemented
 {
     match 0u {
         _ => unimplemented!()
index 95782630efc82e622f19cc7c126f8581d7dfa7d9..a662e9ca98ee812086e338e874234fd0a00a1f91 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn add_state(op: <int as HasState>::State) {
-//~^ ERROR the trait `HasState` is not implemented for the type `int`
+fn add_state(op: <isize as HasState>::State) {
+//~^ ERROR the trait `HasState` is not implemented for the type `isize`
 }
 
 trait HasState {
index 70fe6b9b6a868acac98a548e29fd31dcb6b60a48..bbc5ee6c8f36e336e453eb9c0920de56faf1e0fb 100644 (file)
@@ -18,13 +18,13 @@ trait To {
     // This is a typo, the return type should be `<Dst as From<Self>>::Output`
     fn to<Dst: From<Self>>(
         self
-        //~^ error: the trait `core::kinds::Sized` is not implemented
+        //~^ error: the trait `core::marker::Sized` is not implemented
     ) ->
         <Dst as From<Self>>::Dst
-        //~^ error: the trait `core::kinds::Sized` is not implemented
+        //~^ error: the trait `core::marker::Sized` is not implemented
     {
         From::from(
-            //~^ error: the trait `core::kinds::Sized` is not implemented
+            //~^ error: the trait `core::marker::Sized` is not implemented
             self
         )
     }
index b52f2b1b13857231b830f69492590d09114311eb..d91479a2e4e896169cb34c90d2624b69d06e589e 100644 (file)
@@ -16,9 +16,9 @@ trait From<Src> {
 
 trait To {
     fn to<Dst>(
-        self //~ error: the trait `core::kinds::Sized` is not implemented
+        self //~ error: the trait `core::marker::Sized` is not implemented
     ) -> <Dst as From<Self>>::Result where Dst: From<Self> {
-        From::from( //~ error: the trait `core::kinds::Sized` is not implemented
+        From::from( //~ error: the trait `core::marker::Sized` is not implemented
             self
         )
     }
index 981abf6cc23d8867cd58ba26874d85926034cee9..546b808a38f4725e5f6eae200f7d81bcc2d8b104 100644 (file)
@@ -17,6 +17,6 @@ struct S {
     name: int
 }
 
-fn bar(_x: Foo) {} //~ ERROR the trait `core::kinds::Sized` is not implemented
+fn bar(_x: Foo) {} //~ ERROR the trait `core::marker::Sized` is not implemented
 
 fn main() {}
index 1c5fd9be1bd4d24d1d3c26804aff580f60199f6c..1943f1e5a195481daff5c649382706d4ee9e506f 100644 (file)
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn bar(int_param: int) {}
+fn bar(int_param: usize) {}
 
 fn main() {
-    let foo: [u8; 4] = [1u8; 4u];
+    let foo: [u8; 4] = [1u8; 4us];
     bar(foo);
-    //~^ ERROR mismatched types: expected `int`, found `[u8; 4]`
-    //         (expected int, found vector)
+    //~^ ERROR mismatched types: expected `usize`, found `[u8; 4]`
+    //         (expected usize, found vector)
 }
index cf1f1f5908954541c4fe5c2b71e673dac1118146..88933c0add9292b828c610d6559c72a385f78433 100644 (file)
@@ -10,9 +10,9 @@
 
 // Regression test for issue #4968
 
-const A: (int,int) = (4,2);
+const A: (isize,isize) = (4,2);
 fn main() {
     match 42 { A => () }
-    //~^ ERROR mismatched types: expected `_`, found `(int, int)`
+    //~^ ERROR mismatched types: expected `_`, found `(isize, isize)`
     //         (expected integral variable, found tuple)
 }
index d0830ff8e4d76efda060130a8ebed5ff539128ce..9e324cdd61eb0e82f40308131b51c72d1d1ce360 100644 (file)
@@ -11,6 +11,6 @@
 trait I {}
 type K = I+'static;
 
-fn foo(_x: K) {} //~ ERROR: the trait `core::kinds::Sized` is not implemented
+fn foo(_x: K) {} //~ ERROR: the trait `core::marker::Sized` is not implemented
 
 fn main() {}
index 5082c3102dd81451e94f7c01759c218591628d83..7bf3449a664b103adb9a1ae411445e06607c992f 100644 (file)
@@ -8,5 +8,5 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-fn main() { format!("{}", None); }
+fn main() { format!("{:?}", None); }
     //~^ ERROR type annotations required
index 1691688fd84645f65d31446cae23cdd48d3e2f44..0eaa40efca22bda731c6b7ae5a66ba0d19fac370 100644 (file)
@@ -11,6 +11,6 @@
 // Regression test for issue #5239
 
 fn main() {
-    let x = |&: ref x: int| -> int { x += 1; };
-    //~^ ERROR binary assignment operation `+=` cannot be applied to type `&int`
+    let x = |&: ref x: isize| -> isize { x += 1; };
+    //~^ ERROR binary assignment operation `+=` cannot be applied to type `&isize`
 }
index f970cdb1b8304c6b797ae3f3333ea231d9331470..2d64013dc277f692cbe6724b6dcf7604049d36fa 100644 (file)
@@ -14,5 +14,5 @@ impl Foo for u8 {}
 fn main() {
     let r: Box<Foo> = box 5;
     let _m: Box<Foo> = r as Box<Foo>;
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `Foo`
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `Foo`
 }
index e6ac30139c37fba489a4bf4c19708529db799cc2..9ff957b6e6deac4904d0d5066390bd4dd53e2803 100644 (file)
@@ -15,8 +15,8 @@ struct Struct {
 }
 
 fn new_struct(r: A+'static)
-    -> Struct { //~^  ERROR the trait `core::kinds::Sized` is not implemented
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    -> Struct { //~^  ERROR the trait `core::marker::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
     Struct { r: r }
 }
 
index 07c1686a7acd2409c2b8bfea5d79aa61563e3355..0143c75bfc6045687d631f3d1779249b25aa13ee 100644 (file)
@@ -10,6 +10,6 @@
 
 fn main() {
     // Unconstrained type:
-    format!("{}", None);
+    format!("{:?}", None);
     //~^ ERROR type annotations required
 }
diff --git a/src/test/compile-fail/issue-6596-1.rs b/src/test/compile-fail/issue-6596-1.rs
new file mode 100644 (file)
index 0000000..e988f40
--- /dev/null
@@ -0,0 +1,21 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// error-pattern: unknown macro variable `nonexistent`
+
+macro_rules! e {
+    ($inp:ident) => (
+        $nonexistent
+    );
+}
+
+fn main() {
+    e!(foo);
+}
diff --git a/src/test/compile-fail/issue-6596-2.rs b/src/test/compile-fail/issue-6596-2.rs
new file mode 100644 (file)
index 0000000..0158ad4
--- /dev/null
@@ -0,0 +1,23 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+#![feature(macro_rules)]
+
+// error-pattern: unknown macro variable `nonexistent`
+
+macro_rules! g {
+    ($inp:ident) => (
+        { $inp $nonexistent }
+    );
+}
+
+fn main() {
+    g!(foo);
+}
diff --git a/src/test/compile-fail/issue-6596.rs b/src/test/compile-fail/issue-6596.rs
deleted file mode 100644 (file)
index c5be0da..0000000
+++ /dev/null
@@ -1,21 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// error-pattern: unexpected token
-
-macro_rules! e {
-    ($inp:ident) => (
-        $nonexistent
-    );
-}
-
-fn main() {
-    e!(foo);
-}
index a8a699d62d5eed33c6d8dccab6ba671b0caefe44..d2f9ee4760303484e6bdfb88479311f67e3d1cba 100644 (file)
@@ -32,6 +32,6 @@ struct A {
 
 fn main() {
     let a = A {v: box B{v: None} as Box<Foo+Send>};
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
-    //~^^ ERROR the trait `core::kinds::Send` is not implemented
+    //~^ ERROR the trait `core::marker::Send` is not implemented
+    //~^^ ERROR the trait `core::marker::Send` is not implemented
 }
index 77836143f27dd8824c8d91c7831d44f8d3b7cb64..c8c7ef4ed89d767f97cd5f1f2bfc243adfc5905f 100644 (file)
@@ -14,7 +14,7 @@
 // Regresion test for issue 7364
 static boxed: Box<RefCell<int>> = box RefCell::new(0);
 //~^ ERROR statics are not allowed to have custom pointers
-//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
-//~| ERROR: the trait `core::kinds::Sync` is not implemented for the type
+//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
+//~| ERROR: the trait `core::marker::Sync` is not implemented for the type
 
 fn main() { }
index d5a1040d4b4d929c8b5bac5b21d8fbdd78f7aede..0d5156956e56636b6e5f2bc25935055d0631cdbd 100644 (file)
 // Test the mechanism for warning about possible missing `self` declarations.
 
 trait CtxtFn {
-    fn f8(self, uint) -> uint;
-    fn f9(uint) -> uint; //~ NOTE candidate
+    fn f8(self, usize) -> usize;
+    fn f9(usize) -> usize; //~ NOTE candidate
 }
 
 trait OtherTrait {
-    fn f9(uint) -> uint; //~ NOTE candidate
+    fn f9(usize) -> usize; //~ NOTE candidate
 }
 
 // Note: this trait is not implemented, but we can't really tell
 // whether or not an impl would match anyhow without a self
-// declaration to match against, so we wind up printing it as a
+// declaration to match against, so we wind up prisizeing it as a
 // candidate. This seems not unreasonable -- perhaps the user meant to
 // implement it, after all.
 trait UnusedTrait {
-    fn f9(uint) -> uint; //~ NOTE candidate
+    fn f9(usize) -> usize; //~ NOTE candidate
 }
 
-impl CtxtFn for uint {
-    fn f8(self, i: uint) -> uint {
+impl CtxtFn for usize {
+    fn f8(self, i: usize) -> usize {
         i * 4u
     }
 
-    fn f9(i: uint) -> uint {
+    fn f9(i: usize) -> usize {
         i * 4u
     }
 }
 
-impl OtherTrait for uint {
-    fn f9(i: uint) -> uint {
+impl OtherTrait for usize {
+    fn f9(i: usize) -> usize {
         i * 8u
     }
 }
 
-struct MyInt(int);
+struct Myisize(isize);
 
-impl MyInt {
-    fn fff(i: int) -> int { //~ NOTE candidate
+impl Myisize {
+    fn fff(i: isize) -> isize { //~ NOTE candidate
         i
     }
 }
@@ -64,17 +64,17 @@ fn is_str() -> bool {
     }
 }
 
-impl ManyImplTrait for uint {}
-impl ManyImplTrait for int {}
+impl ManyImplTrait for usize {}
+impl ManyImplTrait for isize {}
 impl ManyImplTrait for char {}
-impl ManyImplTrait for MyInt {}
+impl ManyImplTrait for Myisize {}
 
-fn no_param_bound(u: uint, m: MyInt) -> uint {
+fn no_param_bound(u: usize, m: Myisize) -> usize {
     u.f8(42) + u.f9(342) + m.fff(42)
-            //~^ ERROR type `uint` does not implement any method in scope named `f9`
+            //~^ ERROR type `usize` does not implement any method in scope named `f9`
             //~^^ NOTE found defined static methods, maybe a `self` is missing?
-                        //~^^^ ERROR type `MyInt` does not implement any method in scope named `fff`
-                        //~^^^^ NOTE found defined static methods, maybe a `self` is missing?
+            //~^^^ ERROR type `Myisize` does not implement any method in scope named `fff`
+            //~^^^^ NOTE found defined static methods, maybe a `self` is missing?
 }
 
 fn param_bound<T: ManyImplTrait>(t: T) -> bool {
index f11d5972ee19122864944e53b7be1cb1f4f5efab..e459a243cc8a505b04422ee235035d9110a0a19a 100644 (file)
@@ -18,10 +18,10 @@ fn main() {
         _ => ()
     }
 
-    match &Some(42i) {
-        Some(x) => (), //~ ERROR expected `&core::option::Option<int>`,
+    match &Some(42is) {
+        Some(x) => (), //~ ERROR expected `&core::option::Option<isize>`,
                        //        found `core::option::Option<_>`
-        None => ()     //~ ERROR expected `&core::option::Option<int>`,
+        None => ()     //~ ERROR expected `&core::option::Option<isize>`,
                        //        found `core::option::Option<_>`
     }
 }
index 27369f77e883b41c190e8cc74af995fa6ea35784..3f9e92afba2b178915617868092faabd73f49594 100644 (file)
@@ -10,9 +10,9 @@
 
 enum Foo {
     A = 1i64,
-    //~^ ERROR mismatched types: expected `int`, found `i64`
+    //~^ ERROR mismatched types: expected `isize`, found `i64`
     B = 2u8
-    //~^ ERROR mismatched types: expected `int`, found `u8`
+    //~^ ERROR mismatched types: expected `isize`, found `u8`
 }
 
 fn main() {}
index 6e8f7ffb68da4285549855b1da38623942474616..b7537f2a93251d5d5efc05e97a3b6d7ba2cb27fa 100644 (file)
@@ -9,7 +9,7 @@
 // except according to those terms.
 
 #[start]
-fn start(argc: int, argv: *const *const u8, crate_map: *const u8) -> int {
+fn start(argc: isize, argv: *const *const u8, crate_map: *const u8) -> isize {
     //~^ ERROR incorrect number of function parameters
-    0
+   0
 }
index b5725249812f6ccd2edfb018b5d3fddbe9d62ded..ac088e69a28e52d15c3c7b1160615e9ff91b4ce9 100644 (file)
@@ -36,14 +36,14 @@ fn test<'a,T,U:Copy>(_: &'a int) {
     assert_copy::<&'a [int]>();
 
     // ...unless they are mutable
-    assert_copy::<&'static mut int>(); //~ ERROR `core::kinds::Copy` is not implemented
-    assert_copy::<&'a mut int>();  //~ ERROR `core::kinds::Copy` is not implemented
+    assert_copy::<&'static mut int>(); //~ ERROR `core::marker::Copy` is not implemented
+    assert_copy::<&'a mut int>();  //~ ERROR `core::marker::Copy` is not implemented
 
     // ~ pointers are not ok
-    assert_copy::<Box<int>>();   //~ ERROR `core::kinds::Copy` is not implemented
-    assert_copy::<String>();   //~ ERROR `core::kinds::Copy` is not implemented
-    assert_copy::<Vec<int> >(); //~ ERROR `core::kinds::Copy` is not implemented
-    assert_copy::<Box<&'a mut int>>(); //~ ERROR `core::kinds::Copy` is not implemented
+    assert_copy::<Box<int>>();   //~ ERROR `core::marker::Copy` is not implemented
+    assert_copy::<String>();   //~ ERROR `core::marker::Copy` is not implemented
+    assert_copy::<Vec<int> >(); //~ ERROR `core::marker::Copy` is not implemented
+    assert_copy::<Box<&'a mut int>>(); //~ ERROR `core::marker::Copy` is not implemented
 
     // borrowed object types are generally ok
     assert_copy::<&'a Dummy>();
@@ -51,11 +51,11 @@ fn test<'a,T,U:Copy>(_: &'a int) {
     assert_copy::<&'static (Dummy+Copy)>();
 
     // owned object types are not ok
-    assert_copy::<Box<Dummy>>(); //~ ERROR `core::kinds::Copy` is not implemented
-    assert_copy::<Box<Dummy+Copy>>(); //~ ERROR `core::kinds::Copy` is not implemented
+    assert_copy::<Box<Dummy>>(); //~ ERROR `core::marker::Copy` is not implemented
+    assert_copy::<Box<Dummy+Copy>>(); //~ ERROR `core::marker::Copy` is not implemented
 
     // mutable object types are not ok
-    assert_copy::<&'a mut (Dummy+Copy)>();  //~ ERROR `core::kinds::Copy` is not implemented
+    assert_copy::<&'a mut (Dummy+Copy)>();  //~ ERROR `core::marker::Copy` is not implemented
 
     // unsafe ptrs are ok
     assert_copy::<*const int>();
@@ -73,10 +73,10 @@ fn test<'a,T,U:Copy>(_: &'a int) {
     assert_copy::<MyStruct>();
 
     // structs containing non-POD are not ok
-    assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::kinds::Copy` is not implemented
+    assert_copy::<MyNoncopyStruct>(); //~ ERROR `core::marker::Copy` is not implemented
 
     // ref counted types are not ok
-    assert_copy::<Rc<int>>();   //~ ERROR `core::kinds::Copy` is not implemented
+    assert_copy::<Rc<int>>();   //~ ERROR `core::marker::Copy` is not implemented
 }
 
 pub fn main() {
index 6b25289567b27157a8042a0271222ad1fcf64e06..9e7c983195a6629a27458806c40483c798e5c469 100644 (file)
@@ -19,5 +19,5 @@ fn take_param<T:Foo>(foo: &T) { }
 fn main() {
     let x = box 3i;
     take_param(&x);
-    //~^ ERROR the trait `core::kinds::Copy` is not implemented
+    //~^ ERROR the trait `core::marker::Copy` is not implemented
 }
index 57ee4cf7cc3b03b7695db104745be532c6103293..6ecf2593d00ab4b67354c6bf5eaf623a7e2d5e44 100644 (file)
@@ -20,15 +20,15 @@ impl<T: Send + Copy> Gettable<T> for S<T> {}
 fn f<T>(val: T) {
     let t: S<T> = S;
     let a = &t as &Gettable<T>;
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
-    //~^^ ERROR the trait `core::kinds::Copy` is not implemented
+    //~^ ERROR the trait `core::marker::Send` is not implemented
+    //~^^ ERROR the trait `core::marker::Copy` is not implemented
 }
 
 fn g<T>(val: T) {
     let t: S<T> = S;
     let a: &Gettable<T> = &t;
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
-    //~^^ ERROR the trait `core::kinds::Copy` is not implemented
+    //~^ ERROR the trait `core::marker::Send` is not implemented
+    //~^^ ERROR the trait `core::marker::Copy` is not implemented
 }
 
 fn foo<'a>() {
@@ -40,13 +40,13 @@ fn foo<'a>() {
 fn foo2<'a>() {
     let t: Box<S<String>> = box S;
     let a = t as Box<Gettable<String>>;
-    //~^ ERROR the trait `core::kinds::Copy` is not implemented
+    //~^ ERROR the trait `core::marker::Copy` is not implemented
 }
 
 fn foo3<'a>() {
     let t: Box<S<String>> = box S;
     let a: Box<Gettable<String>> = t;
-    //~^ ERROR the trait `core::kinds::Copy` is not implemented
+    //~^ ERROR the trait `core::marker::Copy` is not implemented
 }
 
 fn main() { }
index d66fd0d77d6a9b6a6ef645a64e1ca8b7cbcf351b..7f610176b65695e086e898bcf3b3d4a763a95d32 100644 (file)
@@ -22,13 +22,13 @@ fn take_param<T:Foo>(foo: &T) { }
 
 fn a() {
     let x = box 3i;
-    take_param(&x); //~ ERROR `core::kinds::Copy` is not implemented
+    take_param(&x); //~ ERROR `core::marker::Copy` is not implemented
 }
 
 fn b() {
     let x = box 3i;
     let y = &x;
-    let z = &x as &Foo; //~ ERROR `core::kinds::Copy` is not implemented
+    let z = &x as &Foo; //~ ERROR `core::marker::Copy` is not implemented
 }
 
 fn main() { }
index fdd8584a8bb06b19db9f2d2ae833116536c1e4e4..a13a3f7c4ab71e56fd317e45181467ab1fb38f4a 100644 (file)
@@ -18,7 +18,7 @@ fn bar<F:FnOnce() + Send>(_: F) { }
 fn main() {
     let x = Rc::new(3u);
     bar(move|| foo(x));
-    //~^ ERROR `core::kinds::Send` is not implemented
-    //~^^ ERROR `core::kinds::Send` is not implemented
+    //~^ ERROR `core::marker::Send` is not implemented
+    //~^^ ERROR `core::marker::Send` is not implemented
 }
 
index c300096caf1e09c87bcb4f8e6c99d8e9cecbe837..7984b3b32c21391abf3ca09b47295a0e80d53b99 100644 (file)
@@ -20,11 +20,11 @@ trait Message : Send { }
 
 fn object_ref_with_static_bound_not_ok() {
     assert_send::<&'static (Dummy+'static)>();
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
+    //~^ ERROR the trait `core::marker::Send` is not implemented
 }
 
 fn box_object_with_no_bound_not_ok<'a>() {
-    assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::kinds::Send` is not implemented
+    assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::marker::Send` is not implemented
 }
 
 fn object_with_send_bound_ok() {
index d83a8031c45db51c016cb01553f53f006139d237..c781fffff2dbcb760d1be992b91d6f6bc1a9e04e 100644 (file)
@@ -18,7 +18,7 @@ trait Dummy { }
 // careful with object types, who knows what they close over...
 fn test51<'a>() {
     assert_send::<&'a Dummy>();
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
+    //~^ ERROR the trait `core::marker::Send` is not implemented
 }
 fn test52<'a>() {
     assert_send::<&'a (Dummy+Send)>();
@@ -37,7 +37,7 @@ fn test61() {
 // them not ok
 fn test_71<'a>() {
     assert_send::<Box<Dummy+'a>>();
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
+    //~^ ERROR the trait `core::marker::Send` is not implemented
 }
 
 fn main() { }
index ea8c262830633b20e1ff7c8b143dc0707106c6e6..75bae09b37f17cad3f3961e06a64230970263c91 100644 (file)
@@ -14,11 +14,11 @@ fn assert_send<T:Send>() { }
 trait Dummy { }
 
 fn test50() {
-    assert_send::<&'static Dummy>(); //~ ERROR the trait `core::kinds::Send` is not implemented
+    assert_send::<&'static Dummy>(); //~ ERROR the trait `core::marker::Send` is not implemented
 }
 
 fn test53() {
-    assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::kinds::Send` is not implemented
+    assert_send::<Box<Dummy>>(); //~ ERROR the trait `core::marker::Send` is not implemented
 }
 
 // ...unless they are properly bounded
index 4e1641025d5aec0fe480d219e5b6136324c36618..1bfd0d4a11f55548dc3d35d3887c75892754d089 100644 (file)
@@ -14,7 +14,7 @@ fn assert_send<T:Send>() { }
 
 fn test71<'a>() {
     assert_send::<*mut &'a int>();
-    //~^ ERROR the trait `core::kinds::Send` is not implemented for the type
+    //~^ ERROR the trait `core::marker::Send` is not implemented for the type
 }
 
 fn main() {
index 6c1b3ef67cc831e92c17ee81838bd1948ed8a4f7..c75c7002e5e0f95910ea14f431ab99e2d0ec53d7 100644 (file)
@@ -16,6 +16,6 @@
 }
 
 fn main() {
-    println!("{}", foo);
+    println!("{:?}", foo);
 }
 
index 0d5b562e04cdd191afd220f4e1c8099954bada8f..21e1ab4c33e1de6c5d5a0d068fc7a865f58ae0bf 100644 (file)
@@ -19,7 +19,7 @@
 struct Foo {
     x: uint,
     b: bool, //~ ERROR: struct field is never used
-    marker: std::kinds::marker::NoCopy
+    marker: std::marker::NoCopy
 }
 
 fn field_read(f: Foo) -> uint {
@@ -59,7 +59,7 @@ fn field_match_in_let(f: Bar) -> bool {
 }
 
 fn main() {
-    field_read(Foo { x: 1, b: false, marker: std::kinds::marker::NoCopy });
+    field_read(Foo { x: 1, b: false, marker: std::marker::NoCopy });
     field_match_in_patterns(XYZ::Z);
     field_match_in_let(Bar { x: 42u, b: true, _guard: () });
     let _ = Baz { x: 0 };
index 19373c806f14d4da979f7c787e3c19d7292f13c1..b6eda8635c2f400a5cba28a5d738e9580f936ad6 100644 (file)
@@ -32,7 +32,7 @@ fn main() {
     let mut buff = [0u8; 16];
     match f.read(&mut buff) {
         Ok(cnt) => println!("read this many bytes: {}", cnt),
-        Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {}", EndOfFile.to_string()),
+        Err(IoError{ kind: EndOfFile, .. }) => println!("Got end of file: {:?}", EndOfFile),
 //~^ ERROR variable `EndOfFile` should have a snake case name such as `end_of_file`
 //~^^ WARN `EndOfFile` is named the same as one of the variants of the type `std::io::IoErrorKind`
     }
index f25d2a9b00c706596f12e46226c2efbee47c1614..44d45463f19f0e21a78b2b5bf0841831419a9220 100644 (file)
@@ -9,8 +9,8 @@
 // except according to those terms.
 
 fn send<T:Send + std::fmt::Show>(ch: _chan<T>, data: T) {
-    println!("{}", ch);
-    println!("{}", data);
+    println!("{:?}", ch);
+    println!("{:?}", data);
     panic!();
 }
 
diff --git a/src/test/compile-fail/macro-input-future-proofing.rs b/src/test/compile-fail/macro-input-future-proofing.rs
new file mode 100644 (file)
index 0000000..15f6d88
--- /dev/null
@@ -0,0 +1,30 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+macro_rules! errors_everywhere {
+    ($ty:ty <) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
+    ($ty:ty < foo ,) => (); //~ ERROR `$ty:ty` is followed by `<`, which is not allowed for `ty`
+    ($ty:ty , ) => ();
+    ( ( $ty:ty ) ) => ();
+    ( { $ty:ty } ) => ();
+    ( [ $ty:ty ] ) => ();
+    ($bl:block < ) => ();
+    ($pa:pat >) => (); //~ ERROR `$pa:pat` is followed by `>`, which is not allowed for `pat`
+    ($pa:pat , ) => ();
+    ($pa:pat | ) => (); //~ ERROR `$pa:pat` is followed by `|`
+    ($pa:pat $pb:pat $ty:ty ,) => ();
+    //~^ ERROR `$pa:pat` is followed by `$pb:pat`, which is not allowed
+    //~^^ ERROR `$pb:pat` is followed by `$ty:ty`, which is not allowed
+    ($($ty:ty)* -) => (); //~ ERROR `$ty:ty` is followed by `-`
+    ($($a:ty, $b:ty)* -) => (); //~ ERROR `$b:ty` is followed by `-`
+    ($($ty:ty)-+) => (); //~ ERROR `$ty:ty` is followed by `-`, which is not allowed for `ty`
+}
+
+fn main() { }
index b1116a4cca62bbf44b08fbe8a4ab2337a4d8c469..7aafeced3a6f45edcc533230ff28abf29b4876fd 100644 (file)
@@ -19,8 +19,8 @@ impl<K, V> Map<K, V> for HashMap<K, V> {}
 // Test that trait types printed in error msgs include the type arguments.
 
 fn main() {
-    let x: Box<HashMap<int, int>> = box HashMap::new();
-    let x: Box<Map<int, int>> = x;
-    let y: Box<Map<uint, int>> = box x;
-    //~^ ERROR the trait `Map<uint, int>` is not implemented
+    let x: Box<HashMap<isize, isize>> = box HashMap::new();
+    let x: Box<Map<isize, isize>> = x;
+    let y: Box<Map<usize, isize>> = box x;
+    //~^ ERROR the trait `Map<usize, isize>` is not implemented
 }
index d620c13cc2520d15efb0d934bc44811a6dc094d4..d9e139cc9db71d86b6715fb61f67034dfc9679f0 100644 (file)
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 fn foo<P:Copy>(p: P) { }
 
 fn main()
 {
-    foo(marker::NoCopy); //~ ERROR the trait `core::kinds::Copy` is not implemented
+    foo(marker::NoCopy); //~ ERROR the trait `core::marker::Copy` is not implemented
 }
index 813e2548398b51304ab2ee03558c32a12350b9b8..032718d7e9a10a6db71cdc4147b997053a70030e 100644 (file)
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 fn foo<P:Send>(p: P) { }
 
 fn main()
 {
-    foo(marker::NoSend); //~ ERROR the trait `core::kinds::Send` is not implemented
+    foo(marker::NoSend); //~ ERROR the trait `core::marker::Send` is not implemented
 }
index 735e61fa139f0195e9bb24416af25c33af05767b..b29f7fab2ccfc25409fabcd4b2be7e7715fd6e6d 100644 (file)
@@ -8,11 +8,11 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 fn foo<P: Sync>(p: P) { }
 
 fn main()
 {
-    foo(marker::NoSync); //~ ERROR the trait `core::kinds::Sync` is not implemented
+    foo(marker::NoSync); //~ ERROR the trait `core::marker::Sync` is not implemented
 }
index 82d75b45394e3ce2be6315d38c599b0ffaa26227..178b73199766e2a49bb2cab3c3339cdd1ac0de2e 100644 (file)
@@ -20,5 +20,5 @@ fn main() {
     let x = Foo;
     Foo::bar(x); //~ERROR mismatched types: expected `&Foo`, found `Foo`
     Foo::bar(&&x); //~ERROR mismatched types: expected `&Foo`, found `&&Foo`
-    Foo::bar(&42i); //~ERROR mismatched types: expected `&Foo`, found `&int`
+    Foo::bar(&42is); //~ERROR mismatched types: expected `&Foo`, found `&isize`
 }
index 95ebb8bd882215524fe298fbe46989142cba7c91..d7529c86aa528ef791db9b665f4e50b6708beb1c 100644 (file)
@@ -15,6 +15,6 @@ fn f<T: Sync>(_: T) {}
 fn main() {
     let x = RefCell::new(0i);
     f(x);
-    //~^ ERROR `core::kinds::Sync` is not implemented
-    //~^^ ERROR `core::kinds::Sync` is not implemented
+    //~^ ERROR `core::marker::Sync` is not implemented
+    //~^^ ERROR `core::marker::Sync` is not implemented
 }
index 81985a3d6aa5b19f3da644850142c768db6288c2..443be7d7b69a5b30b4d81417ecbeae341d8c33fa 100644 (file)
@@ -9,18 +9,18 @@
 // except according to those terms.
 
 fn main() {
-    let foo = &mut 1i;
+    let foo = &mut 1is;
 
     // (separate lines to ensure the spans are accurate)
 
-    // SNAP b2085d9 uncomment this after the next snapshot
+    // SNAP 340ac04 uncomment this after the next snapshot
     // NOTE(stage0) just in case tidy doesn't check snap's in tests
-    // let &_ // ~ ERROR expected `&mut int`, found `&_`
+    // let &_ // ~ ERROR expected `&mut isize`, found `&_`
     //    = foo;
     let &mut _ = foo;
 
-    let bar = &1i;
+    let bar = &1is;
     let &_ = bar;
-    let &mut _ //~ ERROR expected `&int`, found `&mut _`
+    let &mut _ //~ ERROR expected `&isize`, found `&mut _`
          = bar;
 }
index af9c5256040dd2a97e524f9645b7f9a6e47b1440..f90bb610d374178c87c5b27d0243ccf97f6fb8fc 100644 (file)
@@ -11,7 +11,7 @@
 // Tests that an `&` pointer to something inherently mutable is itself
 // to be considered mutable.
 
-use std::kinds::marker;
+use std::marker;
 
 enum Foo { A(marker::NoSync) }
 
@@ -19,5 +19,5 @@ fn bar<T: Sync>(_: T) {}
 
 fn main() {
     let x = Foo::A(marker::NoSync);
-    bar(&x); //~ ERROR the trait `core::kinds::Sync` is not implemented
+    bar(&x); //~ ERROR the trait `core::marker::Sync` is not implemented
 }
index 9e56b27a05b6b5280d9cd583cc193eb5e8580724..551953af13520e724db3bdc3dd4856f77b133217 100644 (file)
@@ -36,9 +36,9 @@ fn foo(x: Port<()>) -> foo {
     let x = foo(Port(Rc::new(())));
 
     Thread::spawn(move|| {
-        //~^ ERROR `core::kinds::Send` is not implemented
-        //~^^ ERROR `core::kinds::Send` is not implemented
+        //~^ ERROR `core::marker::Send` is not implemented
+        //~^^ ERROR `core::marker::Send` is not implemented
         let y = x;
-        println!("{}", y);
+        println!("{:?}", y);
     });
 }
index 8b409cfe89dd8a80f31bc0e59cb87f8a24dd2271..cf1f13e8bb8683d1eb28f312518b7495dacea205 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 enum Foo {
     A(marker::NoSend)
@@ -19,5 +19,5 @@ fn bar<T: Send>(_: T) {}
 fn main() {
     let x = Foo::A(marker::NoSend);
     bar(x);
-    //~^ ERROR `core::kinds::Send` is not implemented
+    //~^ ERROR `core::marker::Send` is not implemented
 }
index 004921b1db0d2ab4b82045208be02aafef8b62a1..95855ed584bc9aa9ad46646cebcebb78301e81cf 100644 (file)
@@ -15,6 +15,6 @@ fn bar<T: Send>(_: T) {}
 fn main() {
     let x = Rc::new(5i);
     bar(x);
-    //~^ ERROR `core::kinds::Send` is not implemented
-    //~^^ ERROR `core::kinds::Send` is not implemented
+    //~^ ERROR `core::marker::Send` is not implemented
+    //~^^ ERROR `core::marker::Send` is not implemented
 }
index 6e84578e92e3b9d0ea29ba92fa324be45fc846d5..c2d6f04c7d49c20b449f0f6697da70749b0bea38 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 struct Foo {
     a: int,
@@ -20,5 +20,5 @@ fn bar<T: Send>(_: T) {}
 fn main() {
     let x = Foo { a: 5, ns: marker::NoSend };
     bar(x);
-    //~^ ERROR the trait `core::kinds::Send` is not implemented
+    //~^ ERROR the trait `core::marker::Send` is not implemented
 }
index cb8ecd7259bb75e27e36ba875d5370bafa5fbab7..33222eef44e74122765b3251a237fd5bf9dd1239 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 enum Foo { A(marker::NoSync) }
 
@@ -17,5 +17,5 @@ fn bar<T: Sync>(_: T) {}
 fn main() {
     let x = Foo::A(marker::NoSync);
     bar(x);
-    //~^ ERROR the trait `core::kinds::Sync` is not implemented
+    //~^ ERROR the trait `core::marker::Sync` is not implemented
 }
index ac3b456def526cbfe8f25d6dc40e3cfb39acbd30..0f3573e0ad5a98513b69aa2dd62c8aef5384bb28 100644 (file)
@@ -16,6 +16,6 @@ fn bar<T: Sync>(_: T) {}
 fn main() {
     let x = Rc::new(RefCell::new(5i));
     bar(x);
-    //~^ ERROR the trait `core::kinds::Sync` is not implemented
-    //~^^ ERROR the trait `core::kinds::Sync` is not implemented
+    //~^ ERROR the trait `core::marker::Sync` is not implemented
+    //~^^ ERROR the trait `core::marker::Sync` is not implemented
 }
index 1379a9f7382b006678b007d268ecf93238a305eb..59864b63b04940a7a6ef5686d5be234c04064885 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 struct Foo { a: int, m: marker::NoSync }
 
@@ -17,5 +17,5 @@ fn bar<T: Sync>(_: T) {}
 fn main() {
     let x = Foo { a: 5, m: marker::NoSync };
     bar(x);
-    //~^ ERROR the trait `core::kinds::Sync` is not implemented
+    //~^ ERROR the trait `core::marker::Sync` is not implemented
 }
index 7e113d4a8c4cd49b40ff36a4de763b128d483f26..4081792b6544ae37d636114f83fc87b81aba654d 100644 (file)
@@ -18,5 +18,5 @@ fn main() {
     // because the def_id associated with the type was
     // not convertible to a path.
   let x: int = noexporttypelib::foo();
-    //~^ ERROR expected `int`, found `core::option::Option<int>`
+    //~^ ERROR expected `isize`, found `core::option::Option<isize>`
 }
index aceec2aafdfa35bc37d051e1efe2142c595a1f41..ec8369d6736fb0af32f6d62f0e2af61b6093034b 100644 (file)
@@ -42,5 +42,5 @@ fn foo(i:int) -> foo {
 fn main() {
     let x = foo(10);
     let _y = x.clone(); //~ ERROR does not implement any method in scope
-    println!("{}", x);
+    println!("{:?}", x);
 }
index 4aae8fa87daffbd7e6abcd8eb6e1ccf4ddbb6b4f..9e425fa8f2e7d2dfda66e02e820b69e14afa5a81 100644 (file)
@@ -30,7 +30,7 @@ impl Copy for IWantToCopyThis {}
 
 enum CantCopyThisEither {
     A,
-    B(::std::kinds::marker::NoCopy),
+    B(::std::marker::NoCopy),
 }
 
 enum IWantToCopyThisToo {
index 5c0aba42b9683221374078f66c47d8a707eae9ae..38177d076455d5bae99415e117762b32f291e42c 100644 (file)
@@ -34,6 +34,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 91c6776e52eddb06db8dd37b5cf4a0e204dd5f4a..200c8a5137a8b46ff89bed6ed5e9fa7a543e5557 100644 (file)
@@ -33,6 +33,6 @@ fn main() {
     let foo = Foo { bar: 1, baz: 10 };
     unsafe {
         let oof: Oof = mem::transmute(foo);
-        println!("{}", oof);
+        println!("{:?}", oof);
     }
 }
index ebda4e9103d604669547d28dd73e1d4e2a2aef8f..b33b89be35d828970eed1d1293d51865c28693d2 100644 (file)
@@ -11,9 +11,9 @@
 fn let_in<T, F>(x: T, f: F) where F: FnOnce(T) {}
 
 fn main() {
-    let_in(3u, |i| { assert!(i == 3i); });
-    //~^ ERROR expected `uint`, found `int`
+    let_in(3u, |i| { assert!(i == 3is); });
+    //~^ ERROR expected `usize`, found `isize`
 
-    let_in(3i, |i| { assert!(i == 3u); });
-    //~^ ERROR expected `int`, found `uint`
+    let_in(3i, |i| { assert!(i == 3us); });
+    //~^ ERROR expected `isize`, found `usize`
 }
index 4af748661fd12e43b115e1cf3c9e50639506415c..0ade29750442bcf14f3b6dda11ef681c71bff0d5 100644 (file)
@@ -23,5 +23,5 @@ pub fn main() {
     // Unsized type.
     let arr: &[_] = &[1u, 2, 3];
     let range = (*arr)..;
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
index 4dd028b78845996e18acfdb6f65d1a0446260bac..4d31d2c8e6927e02a98d4bc53de4e857dbcf54c3 100644 (file)
@@ -14,7 +14,7 @@
 // Note: see variance-regions-*.rs for the tests that check that the
 // variance inference works in the first place.
 
-use std::kinds::marker;
+use std::marker;
 
 // This is contravariant with respect to 'a, meaning that
 // Contravariant<'foo> <: Contravariant<'static> because
index 93c06aecd30ecffdaf5ad5d732071fa44c06f59b..1c3b7bb5960e1d92dc08ac6979349434f32ec14c 100644 (file)
@@ -14,7 +14,7 @@
 // Note: see variance-regions-*.rs for the tests that check that the
 // variance inference works in the first place.
 
-use std::kinds::marker;
+use std::marker;
 
 struct Covariant<'a> {
     marker: marker::CovariantLifetime<'a>
index ad5ad143b15bcbeed8dbc2979313515f5fd251d6..5f4a1af6bf90f1c4ea1f6c3e8e742c3e5265ea99 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 
 struct invariant<'a> {
     marker: marker::InvariantLifetime<'a>
index f93907f5e5cb00497d4a6c17d2b9850bb664e1df..0d441380e81447676d44db87a11fc4fb6a471f6b 100644 (file)
@@ -12,7 +12,7 @@
 // Check that we correctly infer that b and c must be region
 // parameterized because they reference a which requires a region.
 
-type a<'a> = &'a int;
+type a<'a> = &'a isize;
 type b<'a> = Box<a<'a>>;
 
 struct c<'a> {
@@ -30,7 +30,8 @@ fn set_f_ok(&mut self, b: Box<b<'a>>) {
     }
 
     fn set_f_bad(&mut self, b: Box<b>) {
-        self.f = b; //~ ERROR mismatched types: expected `Box<Box<&'a int>>`, found `Box<Box<&int>>`
+        self.f = b;
+        //~^ ERROR mismatched types: expected `Box<Box<&'a isize>>`, found `Box<Box<&isize>>`
     }
 }
 
index d3126cf44d1b152fcd01e39cfcd1f1bc09283832..762c976a943973b29652b917a30902da00475f90 100644 (file)
@@ -25,5 +25,5 @@ fn drop(&mut self) {
 fn main() {
     let a = Foo { x: 3 };
     let _ = [ a; 5 ];
-    //~^ ERROR the trait `core::kinds::Copy` is not implemented for the type `Foo`
+    //~^ ERROR the trait `core::marker::Copy` is not implemented for the type `Foo`
 }
index 3b0ef0c293af75c260e724a1195c3d2e3913862b..f851a8244f61e71748672c8a1d36ffb487b297ed 100644 (file)
@@ -15,13 +15,13 @@ fn main() {
     let a = [0; n]; //~ ERROR expected constant integer for repeat count, found variable
     let b = [0; ()];
 //~^ ERROR expected constant integer for repeat count, found non-constant expression
-//~^^ ERROR: expected `uint`, found `()`
+//~^^ ERROR: expected `usize`, found `()`
     let c = [0; true]; //~ ERROR expected positive integer for repeat count, found boolean
-    //~^ ERROR: expected `uint`, found `bool`
+    //~^ ERROR: expected `usize`, found `bool`
     let d = [0; 0.5]; //~ ERROR expected positive integer for repeat count, found float
-    //~^ ERROR: expected `uint`, found `_`
+    //~^ ERROR: expected `usize`, found `_`
     let e = [0; "foo"]; //~ ERROR expected positive integer for repeat count, found string
-    //~^ ERROR: expected `uint`, found `&'static str`
+    //~^ ERROR: expected `usize`, found `&'static str`
     let f = [0; -4];
     //~^ ERROR expected positive integer for repeat count, found negative integer
     let f = [0u; -1];
index d0339745c9eafc9cb4e43599c967b8cb5ec2f47e..903760caf1a1eb64bf73184e490c8ed8e24e1d72 100644 (file)
@@ -14,6 +14,6 @@
 
 fn main() {
     let x = Foo;
-    x[..]; //~ ERROR incorrect slicing expression: `[..]`
-    //~^ NOTE use `expr[]` to construct a slice of the whole of expr
+    &x[..]; //~ ERROR incorrect slicing expression: `[..]`
+    //~^ NOTE use `&expr[]` to construct a slice of the whole of expr
 }
index 24f710d2ae3f4140f044457c9e98c5eb2d89ddd3..a03693b5fada086f4a26d6644cf12cfcea3cc26c 100644 (file)
@@ -16,8 +16,8 @@
 
 fn main() {
     let x = Foo;
-    x[]; //~ ERROR cannot take a slice of a value with type `Foo`
-    x[Foo..]; //~ ERROR cannot take a slice of a value with type `Foo`
-    x[..Foo]; //~ ERROR cannot take a slice of a value with type `Foo`
-    x[Foo..Foo]; //~ ERROR cannot take a slice of a value with 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 00783b71ea11da2c12f7ca2548e7dccfe09b44fe..aab187f97515a0c693e88b55891a5374963b366d 100644 (file)
@@ -16,6 +16,6 @@ fn main() {
     let y;
     {
         let x: &[int] = &[1, 2, 3, 4, 5]; //~ ERROR borrowed value does not live long enough
-        y = x[1..];
+        y = &x[1..];
     }
 }
index 8970bcfd153a13b8b3bb2546eb6e7ef8e249b7e4..1dedb0cf888e56ff5cce65856f57094e7725465c 100644 (file)
@@ -16,5 +16,5 @@ fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     // Can't mutably slice an immutable slice
     let slice: &mut [int] = &mut [0, 1];
-    x[2..4] = slice; //~ ERROR cannot borrow
+    let _ = &mut x[2..4]; //~ERROR cannot borrow immutable dereference of `&`-pointer `*x` as mutabl
 }
index ad6b384d74701423207c8a3e360b48718c4e4a23..f0f525a553576e7de57f9e66d2b46fa6f95b582c 100644 (file)
@@ -15,5 +15,5 @@
 fn main() {
     let x: &[int] = &[1, 2, 3, 4, 5];
     // Immutable slices are not mutable.
-    let y: &mut[_] = x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutabl
+    let y: &mut[_] = &x[2..4]; //~ ERROR cannot borrow immutable dereference of `&`-pointer as mutab
 }
index 28e73f74ff3fcebe738ecd30d95dea7e9e7e1543..14ad1b3041f5bc6626c38d08fe7ac1746d2d33e2 100644 (file)
@@ -10,7 +10,7 @@
 
 // Verifies that static items can't be moved
 
-use std::kinds::marker;
+use std::marker;
 
 struct Foo {
     foo: int,
index d58e89e7767e813e0c380b0a34bf3d1c96355399..460154f25d7fcb5354b27b7a32b717cc279f4751 100644 (file)
@@ -53,9 +53,9 @@ fn state_iter() -> StateMachineIter<'static> {
 
 fn main() {
     let mut it = state_iter();
-    println!("{}",it.next());
-    println!("{}",it.next());
-    println!("{}",it.next());
-    println!("{}",it.next());
-    println!("{}",it.next());
+    println!("{:?}",it.next());
+    println!("{:?}",it.next());
+    println!("{:?}",it.next());
+    println!("{:?}",it.next());
+    println!("{:?}",it.next());
 }
index 424ffed989b3ce6b9aaccf7d98db5ebcdc5280bf..ddd2a4eeedf76f4f6b5107bcd8ed5f27a2737e2e 100644 (file)
@@ -10,5 +10,6 @@
 
 pub fn main() {
     let s: &str = "hello";
-    let c: u8 = s[4]; //~ ERROR cannot index a value of type `&str`
+    let c: u8 = s[4]; //~ ERROR the trait `core::ops::Index<_>` is not implemented
+    //~^ ERROR the trait `core::ops::Index<_>` is not implemented
 }
index a0a481401bd214e5bf65b68f430093944ab878c8..fb84c1e2ebe9a265ab362887edddc617a2af4890 100644 (file)
@@ -24,33 +24,33 @@ struct Pair<T,U> {
 
 fn main() {
     let pt = PointF {
-        //~^ ERROR expected f32, found int
-        x: 1i,
-        y: 2i,
+        //~^ ERROR expected f32, found isize
+        x: 1is,
+        y: 2is,
     };
 
     let pt2 = Point::<f32> {
-        //~^ ERROR expected f32, found int
-        x: 3i,
-        y: 4i,
+        //~^ ERROR expected f32, found isize
+        x: 3is,
+        y: 4is,
     };
 
     let pair = PairF {
-        //~^ ERROR expected f32, found int
-        x: 5i,
-        y: 6i,
+        //~^ ERROR expected f32, found isize
+        x: 5is,
+        y: 6is,
     };
 
-    let pair2 = PairF::<int> {
-        //~^ ERROR expected f32, found int
-        x: 7i,
-        y: 8i,
+    let pair2 = PairF::<isize> {
+        //~^ ERROR expected f32, found isize
+        x: 7is,
+        y: 8is,
     };
 
-    let pt3 = PointF::<int> {
+    let pt3 = PointF::<isize> {
         //~^ ERROR wrong number of type arguments
-        x: 9i,
-        y: 10i,
+        x: 9is,
+        y: 10is,
     };
 }
 
index e6dc712137f4218f96a3491a189f8cd56cf239d1..a7ca5e3bf093a02046a0f4d30e44e4e65d7ddf65 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::Send;
+use std::marker::Send;
 
 struct TestType;
 
index 3c84bc26298fdc23b3e948551c761268ff824c6c..1ab79f5c80ecc7253102943c6c138e2760867da5 100644 (file)
@@ -10,7 +10,7 @@
 
 #![feature(optin_builtin_traits)]
 
-use std::kinds::Send;
+use std::marker::Send;
 
 struct TestType;
 
index f673c3b797809803e0d1d7c5bb3bc57e0ded9f87..fe31d81983e16ad137adefe4a8ecafda3c21b28c 100644 (file)
@@ -16,6 +16,6 @@ fn test_send<S: Send>() {}
 
 pub fn main() {
     test_send::<rand::ThreadRng>();
-    //~^ ERROR `core::kinds::Send` is not implemented
-    //~^^ ERROR `core::kinds::Send` is not implemented
+    //~^ ERROR `core::marker::Send` is not implemented
+    //~^^ ERROR `core::marker::Send` is not implemented
 }
index eec116855c98662c6f3466aab5c17ecfd6809d05..5fc80d5660d04cd1c722b30eb20f667fc0061d7b 100644 (file)
@@ -29,7 +29,7 @@ trait Foo {
     fn test_error8_fn<T: B>(&self);
 }
 
-impl Foo for int {
+impl Foo for isize {
     // invalid bound for T, was defined as Eq in trait
     fn test_error1_fn<T: Ord>(&self) {}
     //~^ ERROR in method `test_error1_fn`, type parameter 0 requires bound `core::cmp::Ord`
@@ -66,12 +66,12 @@ fn test_error8_fn<T: C>(&self) {}
 trait Getter<T> { }
 
 trait Trait {
-    fn method<G:Getter<int>>();
+    fn method<G:Getter<isize>>();
 }
 
-impl Trait for uint {
-    fn method<G: Getter<uint>>() {}
-    //~^ ERROR in method `method`, type parameter 0 requires bound `Getter<uint>`
+impl Trait for usize {
+    fn method<G: Getter<usize>>() {}
+    //~^ ERROR in method `method`, type parameter 0 requires bound `Getter<usize>`
 }
 
 fn main() {}
index 85a2761172d6136d6973d940217826eabeb99be2..434d803d718e7bcc143339e29bdfcbfeb069b473 100644 (file)
@@ -14,7 +14,7 @@ trait Foo {
 // This should emit the less confusing error, not the more confusing one.
 
 fn foo(_x: Foo + Send) {
-    //~^ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ERROR the trait `core::marker::Sized` is not implemented
 }
 
 fn main() { }
index fcfd079997734abe0a5ad7383854a55369fb214c..e6ea8e10b22cc11e03b1d6ccffdd9ed876469234 100644 (file)
@@ -24,7 +24,7 @@ fn f(&self, x: &'static str) {
 }
 
 fn main() {
-    let s: Box<Trait<int>> = box Struct { person: "Fred" };
-    //~^ ERROR the trait `Trait<int>` is not implemented for the type `Struct`
+    let s: Box<Trait<isize>> = box Struct { person: "Fred" };
+    //~^ ERROR the trait `Trait<isize>` is not implemented for the type `Struct`
     s.f(1);
 }
index 5e2ebc3e620d631c5c3e951952ae8e625d1de8ff..44b478bfb152b1d35e34b1a471bccbb44bbdc33d 100644 (file)
@@ -21,6 +21,6 @@ fn foo(&self) {}
 impl T for int {}
 
 fn main() {
-    let x = &42i;
-    x.foo(); //~ERROR: type `&int` does not implement any method in scope named `foo`
+    let x = &42is;
+    x.foo(); //~ERROR: type `&isize` does not implement any method in scope named `foo`
 }
index d0c2faed4b29d83e16da691941140c945849450d..7f073a7bfdbbaa2675070c7a39e50f88bf2f3789 100644 (file)
 
 // Issue #6155
 
-fn first((value, _): (int, f64)) -> int { value }
+fn first((value, _): (isize, f64)) -> isize { value }
 
 fn main() {
     let y = first ((1,2.0,3));
     //~^ ERROR expected a tuple with 2 elements, found one with 3 elements
 
     let y = first ((1,));
-    //~^ ERROR expected `(int, f64)`, found `(int,)`
+    //~^ ERROR expected `(isize, f64)`, found `(isize,)`
 }
index 609e34f2274b763e034b22e47c04653f0209b726..20dd71e3bdf447355a90b4d59c9032eb474ef782 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct Point(int, int);
+struct Point(isize, isize);
 
 fn main() {
     let origin = Point(0, 0);
@@ -16,9 +16,9 @@ fn main() {
     origin.1;
     origin.2;
     //~^ ERROR attempted out-of-bounds tuple index `2` on type `Point`
-    let tuple = (0i, 0i);
+    let tuple = (0is, 0is);
     tuple.0;
     tuple.1;
     tuple.2;
-    //~^ ERROR attempted out-of-bounds tuple index `2` on type `(int, int)`
+    //~^ ERROR attempted out-of-bounds tuple index `2` on type `(isize, isize)`
 }
index c1be54b3f75e1256d94b3e911eb876caf61e031d..85ad302f3ed4dde28977bd102b192e2962fb25d2 100644 (file)
@@ -21,12 +21,12 @@ fn identity_u16(n: u16) -> u16 { n }
     identity_u16(y);
     //~^ ERROR mismatched types: expected `u16`, found `i32`
 
-    let a = 3i;
+    let a = 3is;
 
-    fn identity_i(n: int) -> int { n }
+    fn identity_i(n: isize) -> int { n }
 
     identity_i(a); // ok
     identity_u16(a);
-    //~^ ERROR mismatched types: expected `u16`, found `int`
+    //~^ ERROR mismatched types: expected `u16`, found `isize`
 
 }
index 74071f286651790dc992729fc51e52c086454699..8b0897565fb918f6767e94ab3610b6a23b7358c7 100644 (file)
@@ -10,6 +10,6 @@
 
 // Checking that the compiler reports multiple type errors at once
 // error-pattern:mismatched types: expected `bool`
-// error-pattern:mismatched types: expected `int`
+// error-pattern:mismatched types: expected `isize`
 
-fn main() { let a: bool = 1i; let b: int = true; }
+fn main() { let a: bool = 1is; let b: isize = true; }
index a7911eb791eb2338d836be4d377ebc6e1f6776a2..5166a4e96540d152a99dcc32c55928869ffcf1f0 100644 (file)
@@ -13,7 +13,7 @@
 // ignore-tidy-linelength
 
 use std::cell::UnsafeCell;
-use std::kinds::marker;
+use std::marker;
 
 struct MySync<T> {
     u: UnsafeCell<T>
@@ -30,17 +30,17 @@ fn test<T: Sync>(s: T){
 fn main() {
     let us = UnsafeCell::new(MySync{u: UnsafeCell::new(0i)});
     test(us);
-    //~^ ERROR `core::kinds::Sync` is not implemented
+    //~^ ERROR `core::marker::Sync` is not implemented
 
     let uns = UnsafeCell::new(NoSync{m: marker::NoSync});
     test(uns);
-    //~^ ERROR `core::kinds::Sync` is not implemented
+    //~^ ERROR `core::marker::Sync` is not implemented
 
     let ms = MySync{u: uns};
     test(ms);
-    //~^ ERROR `core::kinds::Sync` is not implemented
+    //~^ ERROR `core::marker::Sync` is not implemented
 
     let ns = NoSync{m: marker::NoSync};
     test(ns);
-    //~^ ERROR `core::kinds::Sync` is not implemented
+    //~^ ERROR `core::marker::Sync` is not implemented
 }
index aa7b551afc56acc004da76c543c4efd0c11444e2..92740cf5082a65ef11a45c37b2672f8f98754dd6 100644 (file)
@@ -18,12 +18,12 @@ pub fn main() {
 }
 
 fn test1() {
-    let x: Foo<_> = Bar::<uint>;
-    //~^ ERROR mismatched types: expected `Foo<_>`, found `Bar<uint>`
-    let y: Foo<uint> = x;
+    let x: Foo<_> = Bar::<usize>;
+    //~^ ERROR mismatched types: expected `Foo<_>`, found `Bar<usize>`
+    let y: Foo<usize> = x;
 }
 
 fn test2() {
-    let x: Foo<_> = Bar::<uint>;
-    //~^ ERROR mismatched types: expected `Foo<_>`, found `Bar<uint>`
+    let x: Foo<_> = Bar::<usize>;
+    //~^ ERROR mismatched types: expected `Foo<_>`, found `Bar<usize>`
 }
index 5ace9e115ec78bc79b1adafe3b6615e1135ae94b..e0783b09cbdf5dbd50ad46d5bc80414a42f8e549 100644 (file)
@@ -15,7 +15,7 @@
 #![feature(unboxed_closures)]
 #![allow(dead_code)]
 
-use std::kinds::marker;
+use std::marker;
 
 trait Foo<'a,T,U> {
     fn dummy(&'a self) -> &'a (T,U);
index 704d8c568c421284126b256ebede10e9a4453dba..d306d171ca85556d32d93b1cf0be1ee2f3b58a6e 100644 (file)
@@ -20,5 +20,5 @@ fn drop(&mut self) {}
 fn main() {
     let i = box r { b: true };
     let _j = i.clone(); //~ ERROR not implement
-    println!("{}", i);
+    println!("{:?}", i);
 }
index 48d5028f4357d2111f1324f5e57a23e6df7fb40a..49cebbf52552ba33883070a7b67148378e805756 100644 (file)
@@ -17,6 +17,6 @@ fn f<T:Send>(_i: T) {
 fn main() {
     let i = box Rc::new(100i);
     f(i);
-    //~^ ERROR `core::kinds::Send` is not implemented
-    //~^^ ERROR `core::kinds::Send` is not implemented
+    //~^ ERROR `core::marker::Send` is not implemented
+    //~^^ ERROR `core::marker::Send` is not implemented
 }
index 8aabc9b042f7ec06e5f53b26b27a4387303f48b5..4848c988300abde3142d8a357e568eb2fb6c25e9 100644 (file)
@@ -39,6 +39,6 @@ fn main() {
     f(clone(&r1), clone(&r2));
     //~^ ERROR the trait `core::clone::Clone` is not implemented for the type
     //~^^ ERROR the trait `core::clone::Clone` is not implemented for the type
-    println!("{}", (r2, i1.get()));
-    println!("{}", (r1, i2.get()));
+    println!("{:?}", (r2, i1.get()));
+    println!("{:?}", (r1, i2.get()));
 }
index 993df8e59f3e041e1b6de10f1381e657ea7f81a7..96f36af53aad22a7b06bcabe9c3a0e6fc24edeca 100644 (file)
@@ -30,7 +30,7 @@ fn foo(i:int, j: Rc<String>) -> foo {
 fn main() {
   let cat = "kitty".to_string();
   let (tx, _) = channel();
-  //~^ ERROR `core::kinds::Send` is not implemented
-  //~^^ ERROR `core::kinds::Send` is not implemented
+  //~^ ERROR `core::marker::Send` is not implemented
+  //~^^ ERROR `core::marker::Send` is not implemented
   tx.send(foo(42, Rc::new(cat)));
 }
index 2de490e018b44de240f5a898585840aac5946ce5..e28c082c80c4aebf54f5401cdc2163091fe71486 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 fn bar<T: Sized>() { }
-fn foo<T: ?Sized>() { bar::<T>() } //~ ERROR the trait `core::kinds::Sized` is not implemented
+fn foo<T: ?Sized>() { bar::<T>() } //~ ERROR the trait `core::marker::Sized` is not implemented
 fn main() { }
index aea236c9268157928593407a3e2bc85a4ccd4bbe..df961978086e7aa6958f01371247025757499b23 100644 (file)
@@ -15,14 +15,14 @@ fn not_sized<T: ?Sized>() { }
 enum Foo<U> { FooSome(U), FooNone }
 fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
 fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
-//~^ ERROR the trait `core::kinds::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
 //
 // Not OK: `T` is not sized.
 
 enum Bar<U: ?Sized> { BarSome(U), BarNone }
 fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
 fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
-//~^ ERROR the trait `core::kinds::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
 //
 // Not OK: `Bar<T>` is not sized, but it should be.
 
index 89c711036977a68addd796bfedd63652ad312293..7b9fc2b468b78fbf34cb751441dba2bea0ef7626 100644 (file)
@@ -15,14 +15,14 @@ fn not_sized<T: ?Sized>() { }
 struct Foo<T> { data: T }
 fn foo1<T>() { not_sized::<Foo<T>>() } // Hunky dory.
 fn foo2<T: ?Sized>() { not_sized::<Foo<T>>() }
-//~^ ERROR the trait `core::kinds::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
 //
 // Not OK: `T` is not sized.
 
 struct Bar<T: ?Sized> { data: T }
 fn bar1<T: ?Sized>() { not_sized::<Bar<T>>() }
 fn bar2<T: ?Sized>() { is_sized::<Bar<T>>() }
-//~^ ERROR the trait `core::kinds::Sized` is not implemented
+//~^ ERROR the trait `core::marker::Sized` is not implemented
 //
 // Not OK: `Bar<T>` is not sized, but it should be.
 
index 7ae74fc2600c84d71416e431f997c6840278b901..ac8043d6852a9b37927cc1e5c787c502c6cfe14f 100644 (file)
@@ -15,7 +15,7 @@ trait T2<Z> {
 }
 struct S4<Y: ?Sized>;
 impl<X: ?Sized> T2<X> for S4<X> {
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `X`
 }
 
 fn main() { }
index 9b7d10b0d0f761a3c4f6edf45bb8c0361aa4b06b..2d330654881ba73e031aac1759f5d38114af77dc 100644 (file)
@@ -14,7 +14,7 @@
 // Unbounded.
 fn f1<X: ?Sized>(x: &X) {
     f2::<X>(x);
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
 fn f2<X>(x: &X) {
 }
@@ -23,7 +23,7 @@ fn f2<X>(x: &X) {
 trait T {}
 fn f3<X: ?Sized + T>(x: &X) {
     f4::<X>(x);
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
 fn f4<X: T>(x: &X) {
 }
@@ -37,7 +37,7 @@ fn f5<Y>(x: &Y) {}
 fn f6<X: ?Sized>(x: &X) {}
 fn f7<X: ?Sized>(x1: &E<X>, x2: &E<X>) {
     f5(x1);
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
     f6(x2); // ok
 }
 
@@ -49,19 +49,19 @@ struct S<X: ?Sized> {
 
 fn f8<X: ?Sized>(x1: &S<X>, x2: &S<X>) {
     f5(x1);
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
     f6(x2); // ok
 }
 
 // Test some tuples.
 fn f9<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
     f5(&(*x1, 34i));
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
 
 fn f10<X: ?Sized>(x1: Box<S<X>>, x2: Box<E<X>>) {
     f5(&(32i, *x2));
-    //~^ ERROR the trait `core::kinds::Sized` is not implemented
+    //~^ ERROR the trait `core::marker::Sized` is not implemented
 }
 
 pub fn main() {
index f7477d746fae42faac883697deb0af0e5b681b28..026d496aa43c763e92066d0a3750861697772d63 100644 (file)
@@ -8,30 +8,30 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Test `Sized?` types not allowed in fields (except the last one).
+// Test `?Sized` types not allowed in fields (except the last one).
 
 struct S1<X: ?Sized> {
-    f1: X, //~ ERROR `core::kinds::Sized` is not implemented
+    f1: X, //~ ERROR `core::marker::Sized` is not implemented
     f2: int,
 }
 struct S2<X: ?Sized> {
     f: int,
-    g: X, //~ ERROR `core::kinds::Sized` is not implemented
+    g: X, //~ ERROR `core::marker::Sized` is not implemented
     h: int,
 }
 struct S3 {
-    f: str, //~ ERROR `core::kinds::Sized` is not implemented
+    f: str, //~ ERROR `core::marker::Sized` is not implemented
     g: [uint]
 }
 struct S4 {
-    f: str, //~ ERROR `core::kinds::Sized` is not implemented
+    f: str, //~ ERROR `core::marker::Sized` is not implemented
     g: uint
 }
 enum E<X: ?Sized> {
-    V1(X, int), //~ERROR `core::kinds::Sized` is not implemented
+    V1(X, int), //~ERROR `core::marker::Sized` is not implemented
 }
 enum F<X: ?Sized> {
-    V2{f1: X, f: int}, //~ERROR `core::kinds::Sized` is not implemented
+    V2{f1: X, f: int}, //~ERROR `core::marker::Sized` is not implemented
 }
 
 pub fn main() {
index b4f0a4912cf3019152bb6b9d1c1f359a9dc803aa..02f3404b72b11cc161757411821e1588c5580783 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Test `Sized?` local variables.
+// Test `?Sized` local variables.
 
 
 trait T {}
@@ -16,27 +16,27 @@ trait T {}
 fn f1<X: ?Sized>(x: &X) {
     let _: X; // <-- this is OK, no bindings created, no initializer.
     let _: (int, (X, int)); // same
-    let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
-    let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
+    let y: X; //~ERROR the trait `core::marker::Sized` is not implemented
+    let y: (int, (X, int)); //~ERROR the trait `core::marker::Sized` is not implemented
 }
 fn f2<X: ?Sized + T>(x: &X) {
-    let y: X; //~ERROR the trait `core::kinds::Sized` is not implemented
-    let y: (int, (X, int)); //~ERROR the trait `core::kinds::Sized` is not implemented
+    let y: X; //~ERROR the trait `core::marker::Sized` is not implemented
+    let y: (int, (X, int)); //~ERROR the trait `core::marker::Sized` is not implemented
 }
 
 fn f3<X: ?Sized>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-    let y: X = *x1; //~ERROR the trait `core::kinds::Sized` is not implemented
-    let y = *x2; //~ERROR the trait `core::kinds::Sized` is not implemented
-    let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
+    let y: X = *x1; //~ERROR the trait `core::marker::Sized` is not implemented
+    let y = *x2; //~ERROR the trait `core::marker::Sized` is not implemented
+    let (y, z) = (*x3, 4i); //~ERROR the trait `core::marker::Sized` is not implemented
 }
 fn f4<X: ?Sized + T>(x1: Box<X>, x2: Box<X>, x3: Box<X>) {
-    let y: X = *x1;         //~ERROR the trait `core::kinds::Sized` is not implemented
-    let y = *x2;            //~ERROR the trait `core::kinds::Sized` is not implemented
-    let (y, z) = (*x3, 4i); //~ERROR the trait `core::kinds::Sized` is not implemented
+    let y: X = *x1;         //~ERROR the trait `core::marker::Sized` is not implemented
+    let y = *x2;            //~ERROR the trait `core::marker::Sized` is not implemented
+    let (y, z) = (*x3, 4i); //~ERROR the trait `core::marker::Sized` is not implemented
 }
 
-fn g1<X: ?Sized>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
-fn g2<X: ?Sized + T>(x: X) {} //~ERROR the trait `core::kinds::Sized` is not implemented
+fn g1<X: ?Sized>(x: X) {} //~ERROR the trait `core::marker::Sized` is not implemented
+fn g2<X: ?Sized + T>(x: X) {} //~ERROR the trait `core::marker::Sized` is not implemented
 
 pub fn main() {
 }
index 8a54771112f8e4189c77abee87a57b0428ac23d7..6fc547c0b8e8610b2c2d073fcf58182525b8fec9 100644 (file)
@@ -18,7 +18,7 @@ trait T1<Z: T> {
 }
 struct S3<Y: ?Sized>;
 impl<X: ?Sized + T> T1<X> for S3<X> {
-    //~^ ERROR `core::kinds::Sized` is not implemented for the type `X`
+    //~^ ERROR `core::marker::Sized` is not implemented for the type `X`
 }
 
 fn main() { }
index 3f2f43b0c9b84de267baef50c57e99b1860731b7..364bfc42985990862bbd42429967f35ec566051a 100644 (file)
@@ -16,7 +16,7 @@ struct Number {
     n: i64
 }
 
-impl fmt::Show for Number {
+impl fmt::String for Number {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}", self.n)
     }
index 17a17dcdcf8d6c5119769ec98dffc389b7e1c57e..702702990c244fc720697bf8a5693945fd3b74d3 100644 (file)
 }
 
 extern {
-    fn foo(f: int, x: u8, ...);
+    fn foo(f: isize, x: u8, ...);
 }
 
-extern "C" fn bar(f: int, x: u8) {}
+extern "C" fn bar(f: isize, x: u8) {}
 
 fn main() {
     unsafe {
         foo(); //~ ERROR: this function takes at least 2 parameters but 0 parameters were supplied
         foo(1); //~ ERROR: this function takes at least 2 parameters but 1 parameter was supplied
 
-        let x: unsafe extern "C" fn(f: int, x: u8) = foo;
-        //~^ ERROR: mismatched types: expected `unsafe extern "C" fn(int, u8)`
-        //         , found `unsafe extern "C" fn(int, u8, ...)`
+        let x: unsafe extern "C" fn(f: isize, x: u8) = foo;
+        //~^ ERROR: mismatched types: expected `unsafe extern "C" fn(isize, u8)`
+        //         , found `unsafe extern "C" fn(isize, u8, ...)`
         //          (expected non-variadic fn, found variadic function)
 
-        let y: unsafe extern "C" fn(f: int, x: u8, ...) = bar;
-        //~^ ERROR: mismatched types: expected `unsafe extern "C" fn(int, u8, ...)`
-        //         , found `extern "C" extern fn(int, u8)`
+        let y: unsafe extern "C" fn(f: isize, x: u8, ...) = bar;
+        //~^ ERROR: mismatched types: expected `unsafe extern "C" fn(isize, u8, ...)`
+        //         , found `extern "C" extern fn(isize, u8)`
         //          (expected variadic fn, found non-variadic function)
 
         foo(1, 2, 3f32); //~ ERROR: can't pass an f32 to variadic function, cast to c_double
index 28a7ceeeaa2cdba28d5b83714562a71880f3c834..dc166f9fd9d26d99c2fe22795c1d5d58d58f829c 100644 (file)
@@ -25,5 +25,5 @@ fn main() {
     let j = vec!(r(1));
     let k = i + j;
     //~^ ERROR binary operation `+` cannot be applied to type
-    println!("{}", j);
+    println!("{:?}", j);
 }
index 5f7a2f69c4f918e27c510d61306e8ac1d5495c40..9ff0f011e1dc795f622c6fae10d52b37dca5ad87 100644 (file)
@@ -13,9 +13,9 @@
 
 mod xx {
     extern {
-        pub fn strlen(str: *const u8) -> uint; //~ ERROR found rust type `uint`
-        pub fn foo(x: int, y: uint); //~ ERROR found rust type `int`
-        //~^ ERROR found rust type `uint`
+        pub fn strlen(str: *const u8) -> usize; //~ ERROR found rust type `usize`
+        pub fn foo(x: isize, y: usize); //~ ERROR found rust type `isize`
+        //~^ ERROR found rust type `usize`
     }
 }
 
index 8d72e260a18f7485be40045d2f984290d04ecb3a..74342cfedd3298261807b6cc1fe6c08b883fc026 100644 (file)
@@ -21,7 +21,7 @@ fn needs_copy(self) where T: Copy {
 
     fn fails_copy(self) {
         require_copy(self.x);
-        //~^ ERROR the trait `core::kinds::Copy` is not implemented for the type `T`
+        //~^ ERROR the trait `core::marker::Copy` is not implemented for the type `T`
     }
 }
 
index 096b53a1ea6244ba30127f17b15ed90817c632b5..8e01e89b6870782085d0aa7f86e91c20d4c039b1 100644 (file)
@@ -26,7 +26,7 @@ fn needs_copy(self) where T: Copy {
 
     fn fails_copy(self) {
         require_copy(self.x);
-        //~^ ERROR the trait `core::kinds::Copy` is not implemented for the type `T`
+        //~^ ERROR the trait `core::marker::Copy` is not implemented for the type `T`
     }
 }
 
index 9e81703787f3e0f011c5b7c298c187797bf80832..148473f898798a61675b15b3cae709113ad75fc6 100644 (file)
@@ -8,17 +8,36 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-struct A;
+fn equal<T>(_: &T, _: &T) -> bool where int : Eq {
+    true //~^ ERROR cannot bound type `isize`, where clause bounds may only be attached
+}
+
+// This should be fine involves a type parameter.
+fn test<T: Eq>() -> bool where Option<T> : Eq {}
+
+// This should be rejected as well.
+fn test2() -> bool where Option<int> : Eq {}
+//~^ ERROR cannot bound type `core::option::Option<isize>`, where clause bounds
 
-trait U {}
+#[derive(PartialEq)]
+//~^ ERROR cannot bound type `isize`, where clause bounds
+enum Foo<T> where int : Eq { MkFoo }
+//~^ ERROR cannot bound type `isize`, where clause bounds
 
-// impl U for A {}
+fn test3<T: Eq>() -> bool where Option<Foo<T>> : Eq {}
+
+fn test4() -> bool where Option<Foo<int>> : Eq {}
+//~^ ERROR cannot bound type `core::option::Option<Foo<isize>>`, where clause bounds
+
+trait Baz<T> where int : Eq {
+    fn baz() where String : Eq;
+}
 
-fn equal<T>(_: &T, _: &T) -> bool where A : U {
-    true
+impl Baz<int> for int where int : Eq {
+    //~^ ERROR cannot bound type `isize`, where clause bounds
+    fn baz() where String : Eq {}
 }
 
 fn main() {
     equal(&0i, &0i);
-    //~^ ERROR the trait `U` is not implemented for the type `A`
 }
index 4251f22b291470cef15d41a0ecf391a4f5dfad59..e9f801c5f050e3c4a4f90ce026e61020c9467914 100644 (file)
@@ -16,7 +16,7 @@
 // gdb-command:whatis 'basic-types-globals-metadata::B'
 // gdb-check:type = bool
 // gdb-command:whatis 'basic-types-globals-metadata::I'
-// gdb-check:type = int
+// gdb-check:type = isize
 // gdb-command:whatis 'basic-types-globals-metadata::C'
 // gdb-check:type = char
 // gdb-command:whatis 'basic-types-globals-metadata::I8'
@@ -28,7 +28,7 @@
 // gdb-command:whatis 'basic-types-globals-metadata::I64'
 // gdb-check:type = i64
 // gdb-command:whatis 'basic-types-globals-metadata::U'
-// gdb-check:type = uint
+// gdb-check:type = usize
 // gdb-command:whatis 'basic-types-globals-metadata::U8'
 // gdb-check:type = u8
 // gdb-command:whatis 'basic-types-globals-metadata::U16'
index 6aa228ec51bfce93cae3939bffa7ed31c6bfbb8f..5e2497043da7a4bf7dff5b8c75eb4f6d7bc5ef32 100644 (file)
@@ -18,7 +18,7 @@
 // gdb-command:whatis b
 // gdb-check:type = bool
 // gdb-command:whatis i
-// gdb-check:type = int
+// gdb-check:type = isize
 // gdb-command:whatis c
 // gdb-check:type = char
 // gdb-command:whatis i8
@@ -30,7 +30,7 @@
 // gdb-command:whatis i64
 // gdb-check:type = i64
 // gdb-command:whatis u
-// gdb-check:type = uint
+// gdb-check:type = usize
 // gdb-command:whatis u8
 // gdb-check:type = u8
 // gdb-command:whatis u16
 fn main() {
     let unit: () = ();
     let b: bool = false;
-    let i: int = -1;
+    let i: isize = -1;
     let c: char = 'a';
     let i8: i8 = 68;
     let i16: i16 = -16;
     let i32: i32 = -32;
     let i64: i64 = -64;
-    let u: uint = 1;
+    let u: usize = 1;
     let u8: u8 = 100;
     let u16: u16 = 16;
     let u32: u32 = 32;
index 64c120e1ab3a9a6566f59f9830afadbf708a9969..4b2628b2a1f738202bd1cbeddd89e763faa031cf 100644 (file)
 // gdb-command: print nested_variant2
 // gdb-check:$16 = NestedVariant2 = {abc = NestedStruct = {regular_struct = RegularStruct = {the_first_field = 117, the_second_field = 118.5, the_third_field = false, the_fourth_field = "NestedStructString10"}, tuple_struct = TupleStruct = {119.5, 120}, empty_struct = EmptyStruct, c_style_enum = CStyleEnumVar3, mixed_enum = MixedEnumStructVar = {field1 = 121.5, field2 = -122}}}
 
+// gdb-command: print none_check1
+// gdb-check:$17 = None
+
+// gdb-command: print none_check2
+// gdb-check:$18 = None
+
 use self::CStyleEnum::{CStyleEnumVar1, CStyleEnumVar2, CStyleEnumVar3};
 use self::MixedEnum::{MixedEnumCStyleVar, MixedEnumTupleVar, MixedEnumStructVar};
 use self::NestedEnum::{NestedVariant1, NestedVariant2};
@@ -170,6 +176,9 @@ fn main() {
         }
     };
 
+    let none_check1: Option<(uint, Vec<uint>)> = None;
+    let none_check2: Option<String> = None;
+
     zzz(); // #break
 }
 
index 908968fd6b32acbd97265b9c2bd24c37195e1d0c..a81230599fa71376ca46290245a37b642d2eada9 100644 (file)
 // lldb-command:run
 
 // lldb-command:print int_int
-// lldb-check:[...]$0 = AGenericStruct<int, int> { key: 0, value: 1 }
+// lldb-check:[...]$0 = AGenericStruct<isize, isize> { key: 0, value: 1 }
 // lldb-command:print int_float
-// lldb-check:[...]$1 = AGenericStruct<int, f64> { key: 2, value: 3.5 }
+// lldb-check:[...]$1 = AGenericStruct<isize, f64> { key: 2, value: 3.5 }
 // lldb-command:print float_int
-// lldb-check:[...]$2 = AGenericStruct<f64, int> { key: 4.5, value: 5 }
+// lldb-check:[...]$2 = AGenericStruct<f64, isize> { key: 4.5, value: 5 }
 
 // lldb-command:print float_int_float
-// lldb-check:[...]$3 = AGenericStruct<f64, generic-struct::AGenericStruct<int, f64>> { key: 6.5, value: AGenericStruct<int, f64> { key: 7, value: 8.5 } }
+// lldb-check:[...]$3 = AGenericStruct<f64, generic-struct::AGenericStruct<isize, f64>> { key: 6.5, value: AGenericStruct<isize, f64> { key: 7, value: 8.5 } }
 
 
 #![omit_gdb_pretty_printer_section]
index 333ad602cf1301a55c21082689f79007a42f15b3..71c235c878cc11904ae8a6a826506c65bae3bae2 100644 (file)
 // gdb-check:$3 = {RUST$ENCODED$ENUM$1$Empty = {454545, 0x87654321, 9988}}
 
 // gdb-command:print empty_gdb->discr
-// gdb-check:$4 = (int *) 0x0
+// gdb-check:$4 = (isize *) 0x0
 
 // gdb-command:print droid
 // gdb-check:$5 = {RUST$ENCODED$ENUM$2$Void = {id = 675675, range = 10000001, internals = 0x43218765}}
 
 // gdb-command:print void_droid_gdb->internals
-// gdb-check:$6 = (int *) 0x0
+// gdb-check:$6 = (isize *) 0x0
 
 // gdb-command:continue
 
 // this case (by casting the value to a memory-equivalent struct).
 
 enum MoreFields<'a> {
-    Full(u32, &'a int, i16),
+    Full(u32, &'a isize, i16),
     Empty
 }
 
 struct MoreFieldsRepr<'a> {
     a: u32,
-    discr: &'a int,
+    discr: &'a isize,
     b: i16
 }
 
 enum NamedFields<'a> {
-    Droid { id: i32, range: i64, internals: &'a int },
+    Droid { id: i32, range: i64, internals: &'a isize },
     Void
 }
 
 struct NamedFieldsRepr<'a> {
     id: i32,
     range: i64,
-    internals: &'a int
+    internals: &'a isize
 }
 
 fn main() {
index aac5824af00507e6731cc860e5b2762f7e47c7f8..b508da73f4addfd7a5e30a716b72262d38611681 100644 (file)
@@ -24,7 +24,7 @@
 // gdb-check:type = struct GenericStruct<type-names::Mod1::Struct2, type-names::Mod1::Mod2::Struct3>
 
 // gdb-command:whatis generic_struct2
-// gdb-check:type = struct GenericStruct<type-names::Struct1, extern "fastcall" fn(int) -> uint>
+// gdb-check:type = struct GenericStruct<type-names::Struct1, extern "fastcall" fn(isize) -> usize>
 
 // gdb-command:whatis mod_struct
 // gdb-check:type = struct Struct2
 
 // RAW POINTERS
 // gdb-command:whatis mut_ptr1
-// gdb-check:type = struct (*mut type-names::Struct1, int)
+// gdb-check:type = struct (*mut type-names::Struct1, isize)
 
 // gdb-command:whatis mut_ptr2
-// gdb-check:type = struct (*mut int, int)
+// gdb-check:type = struct (*mut isize, isize)
 
 // gdb-command:whatis mut_ptr3
-// gdb-check:type = struct (*mut type-names::Mod1::Mod2::Enum3<type-names::Struct1>, int)
+// gdb-check:type = struct (*mut type-names::Mod1::Mod2::Enum3<type-names::Struct1>, isize)
 
 // gdb-command:whatis const_ptr1
-// gdb-check:type = struct (*const type-names::Struct1, int)
+// gdb-check:type = struct (*const type-names::Struct1, isize)
 
 // gdb-command:whatis const_ptr2
-// gdb-check:type = struct (*const int, int)
+// gdb-check:type = struct (*const isize, isize)
 
 // gdb-command:whatis const_ptr3
-// gdb-check:type = struct (*const type-names::Mod1::Mod2::Enum3<type-names::Struct1>, int)
+// gdb-check:type = struct (*const type-names::Mod1::Mod2::Enum3<type-names::Struct1>, isize)
 
 
 // VECTORS
 // gdb-check:type = struct ([type-names::Struct1; 3], i16)
 
 // gdb-command:whatis fixed_size_vec2
-// gdb-check:type = struct ([uint; 3], i16)
+// gdb-check:type = struct ([usize; 3], i16)
 
 // gdb-command:whatis slice1
-// gdb-check:type = struct &[uint]
+// gdb-check:type = struct &[usize]
 
 // gdb-command:whatis slice2
 // gdb-check:type = struct &[type-names::Mod1::Enum2]
 // gdb-check:type = struct &Trait2<type-names::Struct1, type-names::Struct1>
 
 // gdb-command:whatis generic_mut_ref_trait
-// gdb-check:type = struct &mut Trait2<type-names::Mod1::Mod2::Struct3, type-names::GenericStruct<uint, int>>
+// gdb-check:type = struct &mut Trait2<type-names::Mod1::Mod2::Struct3, type-names::GenericStruct<usize, isize>>
 
 
 // BARE FUNCTIONS
 // gdb-command:whatis rust_fn
-// gdb-check:type = struct (fn(core::option::Option<int>, core::option::Option<&type-names::Mod1::Struct2>), uint)
+// gdb-check:type = struct (fn(core::option::Option<isize>, core::option::Option<&type-names::Mod1::Struct2>), usize)
 
 // gdb-command:whatis extern_c_fn
-// gdb-check:type = struct (extern "C" fn(int), uint)
+// gdb-check:type = struct (extern "C" fn(isize), usize)
 
 // gdb-command:whatis unsafe_fn
-// gdb-check:type = struct (unsafe fn(core::result::Result<char, f64>), uint)
+// gdb-check:type = struct (unsafe fn(core::result::Result<char, f64>), usize)
 
 // gdb-command:whatis extern_stdcall_fn
-// gdb-check:type = struct (extern "stdcall" fn(), uint)
+// gdb-check:type = struct (extern "stdcall" fn(), usize)
 
 // gdb-command:whatis rust_fn_with_return_value
-// gdb-check:type = struct (fn(f64) -> uint, uint)
+// gdb-check:type = struct (fn(f64) -> usize, usize)
 
 // gdb-command:whatis extern_c_fn_with_return_value
-// gdb-check:type = struct (extern "C" fn() -> type-names::Struct1, uint)
+// gdb-check:type = struct (extern "C" fn() -> type-names::Struct1, usize)
 
 // gdb-command:whatis unsafe_fn_with_return_value
-// gdb-check:type = struct (unsafe fn(type-names::GenericStruct<u16, u8>) -> type-names::Mod1::Struct2, uint)
+// gdb-check:type = struct (unsafe fn(type-names::GenericStruct<u16, u8>) -> type-names::Mod1::Struct2, usize)
 
 // gdb-command:whatis extern_stdcall_fn_with_return_value
-// gdb-check:type = struct (extern "stdcall" fn(Box<int>) -> uint, uint)
+// gdb-check:type = struct (extern "stdcall" fn(Box<isize>) -> usize, usize)
 
 // gdb-command:whatis generic_function_int
-// gdb-check:type = struct (fn(int) -> int, uint)
+// gdb-check:type = struct (fn(isize) -> isize, usize)
 
 // gdb-command:whatis generic_function_struct3
-// gdb-check:type = struct (fn(type-names::Mod1::Mod2::Struct3) -> type-names::Mod1::Mod2::Struct3, uint)
+// gdb-check:type = struct (fn(type-names::Mod1::Mod2::Struct3) -> type-names::Mod1::Mod2::Struct3, usize)
 
 // gdb-command:whatis variadic_function
-// gdb-check:type = struct (unsafe extern "C" fn(*const u8, ...) -> int, uint)
+// gdb-check:type = struct (unsafe extern "C" fn(*const u8, ...) -> isize, usize)
 
 
 // CLOSURES
 // gdb-command:whatis closure1
-// gdb-check:type = struct (closure, uint)
+// gdb-check:type = struct (closure, usize)
 
 // gdb-command:whatis closure2
-// gdb-check:type = struct (closure, uint)
+// gdb-check:type = struct (closure, usize)
 
 #![omit_gdb_pretty_printer_section]
 
 
 enum Enum1 {
     Variant1_1,
-    Variant1_2(int)
+    Variant1_2(isize)
 }
 
 mod Mod1 {
@@ -209,23 +209,23 @@ pub enum Enum3<T> {
 trait Trait1 { }
 trait Trait2<T1, T2> { }
 
-impl Trait1 for int {}
-impl<T1, T2> Trait2<T1, T2> for int {}
+impl Trait1 for isize {}
+impl<T1, T2> Trait2<T1, T2> for isize {}
 
-fn rust_fn(_: Option<int>, _: Option<&Mod1::Struct2>) {}
-extern "C" fn extern_c_fn(_: int) {}
+fn rust_fn(_: Option<isize>, _: Option<&Mod1::Struct2>) {}
+extern "C" fn extern_c_fn(_: isize) {}
 unsafe fn unsafe_fn(_: Result<char, f64>) {}
 extern "stdcall" fn extern_stdcall_fn() {}
 
-fn rust_fn_with_return_value(_: f64) -> uint { 4 }
+fn rust_fn_with_return_value(_: f64) -> usize { 4 }
 extern "C" fn extern_c_fn_with_return_value() -> Struct1 { Struct1 }
 unsafe fn unsafe_fn_with_return_value(_: GenericStruct<u16, u8>) -> Mod1::Struct2 { Mod1::Struct2 }
-extern "stdcall" fn extern_stdcall_fn_with_return_value(_: Box<int>) -> uint { 0 }
+extern "stdcall" fn extern_stdcall_fn_with_return_value(_: Box<isize>) -> usize { 0 }
 
 fn generic_function<T>(x: T) -> T { x }
 
 extern {
-    fn printf(_:*const u8, ...) -> int;
+    fn printf(_:*const u8, ...) -> isize;
 }
 
 // In many of the cases below, the type that is actually under test is wrapped
@@ -240,7 +240,7 @@ fn main() {
     // Structs
     let simple_struct = Struct1;
     let generic_struct1: GenericStruct<Mod1::Struct2, Mod1::Mod2::Struct3> = GenericStruct;
-    let generic_struct2: GenericStruct<Struct1, extern "fastcall" fn(int) -> uint> = GenericStruct;
+    let generic_struct2: GenericStruct<Struct1, extern "fastcall" fn(isize) -> usize> = GenericStruct;
     let mod_struct = Mod1::Struct2;
 
     // Enums
@@ -269,13 +269,13 @@ fn main() {
     let mut_ref2 = (&mut mut_generic_struct, 0i32);
 
     // Raw Pointers
-    let mut_ptr1: (*mut Struct1, int) = (ptr::null_mut(), 0);
-    let mut_ptr2: (*mut int, int) = (ptr::null_mut(), 0);
-    let mut_ptr3: (*mut Mod1::Mod2::Enum3<Struct1>, int) = (ptr::null_mut(), 0);
+    let mut_ptr1: (*mut Struct1, isize) = (ptr::null_mut(), 0);
+    let mut_ptr2: (*mut isize, isize) = (ptr::null_mut(), 0);
+    let mut_ptr3: (*mut Mod1::Mod2::Enum3<Struct1>, isize) = (ptr::null_mut(), 0);
 
-    let const_ptr1: (*const Struct1, int) = (ptr::null(), 0);
-    let const_ptr2: (*const int, int) = (ptr::null(), 0);
-    let const_ptr3: (*const Mod1::Mod2::Enum3<Struct1>, int) = (ptr::null(), 0);
+    let const_ptr1: (*const Struct1, isize) = (ptr::null(), 0);
+    let const_ptr2: (*const isize, isize) = (ptr::null(), 0);
+    let const_ptr3: (*const Mod1::Mod2::Enum3<Struct1>, isize) = (ptr::null(), 0);
 
     // Vectors
     let fixed_size_vec1 = ([Struct1, Struct1, Struct1], 0i16);
@@ -297,7 +297,7 @@ fn main() {
 
     let mut generic_mut_ref_trait_impl = 0i;
     let generic_mut_ref_trait = (&mut generic_mut_ref_trait_impl) as
-        &mut Trait2<Mod1::Mod2::Struct3, GenericStruct<uint, int>>;
+        &mut Trait2<Mod1::Mod2::Struct3, GenericStruct<usize, isize>>;
 
     // Bare Functions
     let rust_fn = (rust_fn, 0u);
@@ -310,7 +310,7 @@ fn main() {
     let unsafe_fn_with_return_value = (unsafe_fn_with_return_value, 0u);
     let extern_stdcall_fn_with_return_value = (extern_stdcall_fn_with_return_value, 0u);
 
-    let generic_function_int = (generic_function::<int>, 0u);
+    let generic_function_int = (generic_function::<isize>, 0u);
     let generic_function_struct3 = (generic_function::<Mod1::Mod2::Struct3>, 0u);
 
     let variadic_function = (printf, 0u);
@@ -321,7 +321,7 @@ 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:int| {}, 0u);
+    let closure1 = (|&: x:isize| {}, 0u);
     let closure2 = (|&: x:i8, y: f32| { (x as f32) + y }, 0u);
 
     zzz(); // #break
index 70211d74d885d9534bd600a8bc80b70fb7324774..14f1dbb9d651cb88fbffce15e5e7b8b4f269735e 100644 (file)
@@ -93,7 +93,7 @@ fn main() {
     let empty: &[i64] = &[];
     let singleton: &[i64] = &[1];
     let multiple: &[i64] = &[2, 3, 4, 5];
-    let slice_of_slice = multiple[1..3];
+    let slice_of_slice = &multiple[1..3];
 
     let padded_tuple: &[(i32, i16)] = &[(6, 7), (8, 9)];
 
index 500305f597075a6048b1ebaaf9f70ef489fff19e..f20087ef677f23a9efca115a008008513a8bb699 100644 (file)
@@ -20,18 +20,18 @@ use std::prelude::v1::*;
 
 // #4264 fixed-length vector types
 
-pub fn foo(_: [int; (3 as uint)]) { }
+pub fn foo(_: [isize; (3 as usize)]) { }
 
 pub fn bar() {
-    const FOO: uint = ((5u as uint) - (4u as uint) as uint);
-    let _: [(); (FOO as uint)] = ([(() as ())] as [(); 1]);
+    const FOO: usize = ((5us as usize) - (4us as usize) as usize);
+    let _: [(); (FOO as usize)] = ([(() as ())] as [(); 1]);
 
-    let _: [(); (1u as uint)] = ([(() as ())] as [(); 1]);
+    let _: [(); (1us as usize)] = ([(() as ())] as [(); 1]);
 
     let _ =
-        (((&((([(1i as int), (2 as int), (3 as int)] as [int; 3])) as
-                [int; 3]) as &[int; 3]) as *const _ as *const [int; 3]) as
-            *const [int; (3u as uint)] as *const [int; 3]);
+        (((&((([(1is as isize), (2 as isize), (3 as isize)] as [isize; 3])) as
+                [isize; 3]) as &[isize; 3]) as *const _ as *const [isize; 3])
+            as *const [isize; (3us as usize)] as *const [isize; 3]);
 
 
 
@@ -81,18 +81,19 @@ pub fn bar() {
                                                                                              core::fmt::Arguments<'_>))
         as collections::string::String);
 }
-pub type Foo = [int; (3u as uint)];
+pub type Foo = [isize; (3us as usize)];
 pub struct Bar {
-    pub x: [int; (3u as uint)],
+    pub x: [isize; (3us as usize)],
 }
-pub struct TupleBar([int; (4u as uint)]);
-pub enum Baz { BazVariant([int; (5u as uint)]), }
+pub struct TupleBar([isize; (4us as usize)]);
+pub enum Baz { BazVariant([isize; (5us as usize)]), }
 pub fn id<T>(x: T) -> T { (x as T) }
 pub fn use_id() {
     let _ =
-        ((id::<[int; (3u as uint)]> as
-             fn([int; 3]) -> [int; 3] {id})(([(1 as int), (2 as int),
-                                              (3 as int)] as [int; 3])) as
-            [int; 3]);
+        ((id::<[isize; (3us as usize)]> as
+             fn([isize; 3]) -> [isize; 3] {id})(([(1 as isize), (2 as isize),
+                                                  (3 as isize)] as
+                                                    [isize; 3])) as
+            [isize; 3]);
 }
 fn main() { }
index b481e109e1a3d4e30e7eda1ec7d79a5a4a79a0ec..75be2f23c2b20003b2426543bdaf6afb6398c1fd 100644 (file)
 
 // #4264 fixed-length vector types
 
-pub fn foo(_: [int; 3]) {}
+pub fn foo(_: [isize; 3]) {}
 
 pub fn bar() {
-    const FOO: uint = 5u - 4u;
+    const FOO: usize = 5us - 4us;
     let _: [(); FOO] = [()];
 
-    let _ : [(); 1u] = [()];
+    let _ : [(); 1us] = [()];
 
-    let _ = &([1i,2,3]) as *const _ as *const [int; 3u];
+    let _ = &([1is,2,3]) as *const _ as *const [isize; 3us];
 
     format!("test");
 }
 
-pub type Foo = [int; 3u];
+pub type Foo = [isize; 3us];
 
 pub struct Bar {
-    pub x: [int; 3u]
+    pub x: [isize; 3us]
 }
 
-pub struct TupleBar([int; 4u]);
+pub struct TupleBar([isize; 4us]);
 
 pub enum Baz {
-    BazVariant([int; 5u])
+    BazVariant([isize; 5us])
 }
 
 pub fn id<T>(x: T) -> T { x }
 
 pub fn use_id() {
-    let _ = id::<[int; 3u]>([1,2,3]);
+    let _ = id::<[isize; 3us]>([1,2,3]);
 }
 
 
index fb069e61bd2a1b571a2bd36367cbabbf74ae6ac7..59e79fe9266f0aa7e28edd81a746c98f5409727b 100644 (file)
@@ -8,8 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:assertion failed: 1i == 2
+// error-pattern:assertion failed: 1is == 2
 
 fn main() {
-    assert!(1i == 2);
+    assert!(1is == 2);
 }
index 69ed025070b4f95d088f3d08c3c739733abef32b..4b1a420cb788087fafbee2a077c3e5d15f886b44 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14`, right: `15`)
+// error-pattern:assertion failed: `(left == right) && (right == left)` (left: `14i`, right: `15i`)
 
 fn main() {
     assert_eq!(14i,15i);
index c943dfe9f0c604b9351b11b309b8e930df259b9c..9beee3b1843f3b98bf97440450aea479463f6573 100644 (file)
@@ -13,7 +13,7 @@
 use std::thread::Thread;
 
 fn main() {
-    let r: Result<int,_> = Thread::spawn(move|| {
+    let r: Result<int,_> = Thread::scoped(move|| {
         panic!("test");
         1i
     }).join();
index 57901ebcfc622d176cae53eb995060407711bf20..714cec6fb3d2091f3245315f7120eda9fe95fca9 100644 (file)
@@ -13,7 +13,7 @@
 use std::thread::Builder;
 
 fn main() {
-    let r: Result<int,_> = Builder::new().name("owned name".to_string()).spawn(move|| {
+    let r: Result<int,_> = Builder::new().name("owned name".to_string()).scoped(move|| {
         panic!("test");
         1i
     }).join();
index 54ccc98bcd9243d61f8c19eb01c855113358534c..dd4c58f176c84ad8e1691800fd646eeb3a1b108d 100644 (file)
@@ -8,8 +8,5 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-
-
-
-// error-pattern:1i == 2
-fn main() { assert!((1i == 2)); }
+// error-pattern:1is == 2
+fn main() { assert!((1is == 2)); }
index 8aade64163056e1c26ec7349f91e43dfd4930dea..d58148810da1fd22109596710d7035307732943b 100644 (file)
@@ -15,7 +15,7 @@
 fn main() {
     // the purpose of this test is to make sure that task::spawn()
     // works when provided with a bare function:
-    let r = Thread::spawn(startfn).join();
+    let r = Thread::scoped(startfn).join();
     if r.is_err() {
         panic!()
     }
index c5455ab90dc8b585a7ba0786899c3c2ea7ee0705..694a06ed83a6f6353cafcea4f207f43cb6fab108 100644 (file)
@@ -1,9 +1,9 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 1i"];
-    N3[label="stmt 1i;"];
-    N4[label="block { 1i; }"];
+    N2[label="expr 1is"];
+    N3[label="stmt 1is;"];
+    N4[label="block { 1is; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 1986c27ad439ba93f37ddf563de9c48fc524fb73..efa2c6404a25fbffd8144c2257b22656c1c49bfd 100644 (file)
@@ -1,11 +1,11 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 3i"];
+    N2[label="expr 3is"];
     N3[label="expr 4"];
-    N4[label="expr 3i + 4"];
-    N5[label="stmt 3i + 4;"];
-    N6[label="block { 3i + 4; }"];
+    N4[label="expr 3is + 4"];
+    N5[label="stmt 3is + 4;"];
+    N6[label="block { 3is + 4; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 82cdcb39fbfd47f70e9404e9b4af6c72d80d3810..1f375b767ce49440315ee26862c8e784462dbfb1 100644 (file)
@@ -1,10 +1,10 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 4i"];
+    N2[label="expr 4is"];
     N3[label="local _x"];
-    N4[label="stmt let _x = 4i;"];
-    N5[label="block { let _x = 4i; }"];
+    N4[label="stmt let _x = 4is;"];
+    N5[label="block { let _x = 4is; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 8a27d536ffc80b5e001dfbc98289ab354ff1b9b8..8c9a930098aa6514106f4e0c61e55be58c42211c 100644 (file)
@@ -1,14 +1,14 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 5i"];
-    N3[label="expr 55i"];
-    N4[label="expr (5i, 55i)"];
+    N2[label="expr 5is"];
+    N3[label="expr 55is"];
+    N4[label="expr (5is, 55is)"];
     N5[label="local _x"];
     N6[label="local _y"];
     N7[label="pat (_x, _y)"];
-    N8[label="stmt let (_x, _y) = (5i, 55i);"];
-    N9[label="block { let (_x, _y) = (5i, 55i); }"];
+    N8[label="stmt let (_x, _y) = (5is, 55is);"];
+    N9[label="block { let (_x, _y) = (5is, 55is); }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 4c6383324e5f9b85bf85162d6c270e7f06a81484..da7d5759b7edeb6e1f18dd1fd94b6c4fb029d571 100644 (file)
@@ -1,12 +1,12 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 7i"];
-    N3[label="expr 77i"];
-    N4[label="expr 777i"];
-    N5[label="expr 7777i"];
-    N6[label="expr [7i, 77i, 777i, 7777i]"];
-    N7[label="expr match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y, }"];
+    N2[label="expr 7is"];
+    N3[label="expr 77is"];
+    N4[label="expr 777is"];
+    N5[label="expr 7777is"];
+    N6[label="expr [7is, 77is, 777is, 7777is]"];
+    N7[label="expr match [7is, 77is, 777is, 7777is] { [x, y, ..] => x + y, }"];
     N8[label="(dummy_node)"];
     N9[label="local x"];
     N10[label="local y"];
@@ -15,8 +15,8 @@ digraph block {
     N13[label="expr x"];
     N14[label="expr y"];
     N15[label="expr x + y"];
-    N16[label="stmt match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y, };"];
-    N17[label="block { match [7i, 77i, 777i, 7777i] { [x, y, ..] => x + y, }; }"];
+    N16[label="stmt match [7is, 77is, 777is, 7777is] { [x, y, ..] => x + y, };"];
+    N17[label="block { match [7is, 77is, 777is, 7777is] { [x, y, ..] => x + y, }; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 27a240ed18255c5c864e25242fb2c6546b56eec0..ac1972424dc957547956542913c681980ce3150b 100644 (file)
@@ -1,21 +1,21 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 8i"];
+    N2[label="expr 8is"];
     N3[label="local x"];
-    N4[label="stmt let x = 8i;"];
+    N4[label="stmt let x = 8is;"];
     N5[label="local _y"];
     N6[label="stmt let _y;"];
     N7[label="expr x"];
-    N8[label="expr 88i"];
-    N9[label="expr x > 88i"];
-    N10[label="expr 888i"];
+    N8[label="expr 88is"];
+    N9[label="expr x > 88is"];
+    N10[label="expr 888is"];
     N11[label="expr _y"];
-    N12[label="expr _y = 888i"];
-    N13[label="stmt _y = 888i;"];
-    N14[label="block { _y = 888i; }"];
-    N15[label="expr if x > 88i { _y = 888i; }"];
-    N16[label="block { let x = 8i; let _y; if x > 88i { _y = 888i; } }"];
+    N12[label="expr _y = 888is"];
+    N13[label="stmt _y = 888is;"];
+    N14[label="block { _y = 888is; }"];
+    N15[label="expr if x > 88is { _y = 888is; }"];
+    N16[label="block { let x = 8is; let _y; if x > 88is { _y = 888is; } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index d2c58c6d59aeb7719fbe1d5f62a884bb6a9e8587..0dc3ff14fba757c05e13ba6c72337b7a519f5ed5 100644 (file)
@@ -1,29 +1,29 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 91i"];
+    N2[label="expr 91is"];
     N3[label="local x"];
-    N4[label="stmt let x = 91i;"];
+    N4[label="stmt let x = 91is;"];
     N5[label="local _y"];
     N6[label="stmt let _y;"];
     N7[label="expr x"];
-    N8[label="expr 92i"];
-    N9[label="expr x > 92i"];
-    N10[label="expr 93i"];
+    N8[label="expr 92is"];
+    N9[label="expr x > 92is"];
+    N10[label="expr 93is"];
     N11[label="expr _y"];
-    N12[label="expr _y = 93i"];
-    N13[label="stmt _y = 93i;"];
-    N14[label="block { _y = 93i; }"];
-    N15[label="expr 94i"];
-    N16[label="expr 95i"];
-    N17[label="expr 94i + 95i"];
+    N12[label="expr _y = 93is"];
+    N13[label="stmt _y = 93is;"];
+    N14[label="block { _y = 93is; }"];
+    N15[label="expr 94is"];
+    N16[label="expr 95is"];
+    N17[label="expr 94is + 95is"];
     N18[label="expr _y"];
-    N19[label="expr _y = 94i + 95i"];
-    N20[label="stmt _y = 94i + 95i;"];
-    N21[label="block { _y = 94i + 95i; }"];
-    N22[label="expr { _y = 94i + 95i; }"];
-    N23[label="expr if x > 92i { _y = 93i; } else { _y = 94i + 95i; }"];
-    N24[label="block { let x = 91i; let _y; if x > 92i { _y = 93i; } else { _y = 94i + 95i; } }"];
+    N19[label="expr _y = 94is + 95is"];
+    N20[label="stmt _y = 94is + 95is;"];
+    N21[label="block { _y = 94is + 95is; }"];
+    N22[label="expr { _y = 94is + 95is; }"];
+    N23[label="expr if x > 92is { _y = 93is; } else { _y = 94is + 95is; }"];
+    N24[label="block {\l    let x = 91is;\l    let _y;\l    if x > 92is { _y = 93is; } else { _y = 94is + 95is; }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index cfe5f4f37d60fd438e23505e1a38a40951548410..184772e7d5166bfe3d32f3a59b4f33c3fedfea27 100644 (file)
@@ -9,10 +9,10 @@
 // except according to those terms.
 
 pub fn expr_if_twoarm_9() {
-    let x = 91i; let _y;
-    if x > 92i {
-        _y = 93i;
+    let x = 91is; let _y;
+    if x > 92is {
+        _y = 93is;
     } else {
-        _y = 94i+95i;
+        _y = 94is+95is;
     }
 }
index 421a79fd136b3fbd69a71d28e089df4c68706179..37606ddac70f78c70977504632302d65589afb63 100644 (file)
@@ -1,20 +1,20 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 10i"];
+    N2[label="expr 10is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 10i;"];
+    N4[label="stmt let mut x = 10is;"];
     N5[label="(dummy_node)"];
     N6[label="expr x"];
-    N7[label="expr 0i"];
-    N8[label="expr x > 0i"];
-    N9[label="expr while x > 0i { x -= 1i; }"];
-    N10[label="expr 1i"];
+    N7[label="expr 0is"];
+    N8[label="expr x > 0is"];
+    N9[label="expr while x > 0is { x -= 1is; }"];
+    N10[label="expr 1is"];
     N11[label="expr x"];
-    N12[label="expr x -= 1i"];
-    N13[label="stmt x -= 1i;"];
-    N14[label="block { x -= 1i; }"];
-    N15[label="block { let mut x = 10i; while x > 0i { x -= 1i; } }"];
+    N12[label="expr x -= 1is"];
+    N13[label="stmt x -= 1is;"];
+    N14[label="block { x -= 1is; }"];
+    N15[label="block { let mut x = 10is; while x > 0is { x -= 1is; } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index b928058fed99c6afe5e34072eb603f4663075bdf..39a55f1a0926bf301063d48db0bef468e78a7a69 100644 (file)
@@ -1,20 +1,20 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 11i"];
+    N2[label="expr 11is"];
     N3[label="local mut _x"];
-    N4[label="stmt let mut _x = 11i;"];
+    N4[label="stmt let mut _x = 11is;"];
     N5[label="(dummy_node)"];
-    N6[label="expr loop  { _x -= 1i; }"];
-    N7[label="expr 1i"];
+    N6[label="expr loop  { _x -= 1is; }"];
+    N7[label="expr 1is"];
     N8[label="expr _x"];
-    N9[label="expr _x -= 1i"];
-    N10[label="stmt _x -= 1i;"];
-    N11[label="block { _x -= 1i; }"];
-    N12[label="stmt loop  { _x -= 1i; }"];
+    N9[label="expr _x -= 1is"];
+    N10[label="stmt _x -= 1is;"];
+    N11[label="block { _x -= 1is; }"];
+    N12[label="stmt loop  { _x -= 1is; }"];
     N13[label="expr \"unreachable\""];
     N14[label="stmt \"unreachable\";"];
-    N15[label="block { let mut _x = 11i; loop  { _x -= 1i; } \"unreachable\"; }"];
+    N15[label="block { let mut _x = 11is; loop  { _x -= 1is; } \"unreachable\"; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index d89a37308de062686dcf30e3c36a066a64cc3f52..e9cd07c0356f89b1329be12def22a2abf723ea11 100644 (file)
@@ -1,27 +1,27 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 12i"];
+    N2[label="expr 12is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 12i;"];
+    N4[label="stmt let mut x = 12is;"];
     N5[label="(dummy_node)"];
-    N6[label="expr loop  { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"];
-    N7[label="expr 1i"];
+    N6[label="expr loop  { x -= 1is; if x == 2is { break ; \"unreachable\"; } }"];
+    N7[label="expr 1is"];
     N8[label="expr x"];
-    N9[label="expr x -= 1i"];
-    N10[label="stmt x -= 1i;"];
+    N9[label="expr x -= 1is"];
+    N10[label="stmt x -= 1is;"];
     N11[label="expr x"];
-    N12[label="expr 2i"];
-    N13[label="expr x == 2i"];
+    N12[label="expr 2is"];
+    N13[label="expr x == 2is"];
     N14[label="expr break"];
     N15[label="(dummy_node)"];
     N16[label="stmt break ;"];
     N17[label="expr \"unreachable\""];
     N18[label="stmt \"unreachable\";"];
     N19[label="block { break ; \"unreachable\"; }"];
-    N20[label="expr if x == 2i { break ; \"unreachable\"; }"];
-    N21[label="block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"];
-    N22[label="block { let mut x = 12i; loop  { x -= 1i; if x == 2i { break ; \"unreachable\"; } } }"];
+    N20[label="expr if x == 2is { break ; \"unreachable\"; }"];
+    N21[label="block { x -= 1is; if x == 2is { break ; \"unreachable\"; } }"];
+    N22[label="block {\l    let mut x = 12is;\l    loop  { x -= 1is; if x == 2is { break ; \"unreachable\"; } }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -34,7 +34,7 @@ digraph block {
     N11 -> N12;
     N12 -> N13;
     N13 -> N14;
-    N14 -> N6[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2i { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1i; if x == 2i { break ; \"unreachable\"; } }"];
+    N14 -> N6[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 2is { break ; \"unreachable\"; },\lexiting scope_4 block { x -= 1is; if x == 2is { break ; \"unreachable\"; } }"];
     N15 -> N16;
     N16 -> N17;
     N17 -> N18;
index bdb2c133badf870b81eb2dd439bc64850583a612..ac1a631eb56ed955b975bfb72fcf2926a228c039 100644 (file)
@@ -1,20 +1,20 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 14i"];
+    N2[label="expr 14is"];
     N3[label="local x"];
-    N4[label="stmt let x = 14i;"];
+    N4[label="stmt let x = 14is;"];
     N5[label="expr x"];
-    N6[label="expr 1i"];
-    N7[label="expr x > 1i"];
+    N6[label="expr 1is"];
+    N7[label="expr x > 1is"];
     N8[label="expr return"];
     N9[label="(dummy_node)"];
     N10[label="stmt return;"];
     N11[label="expr \"unreachable\""];
     N12[label="stmt \"unreachable\";"];
     N13[label="block { return; \"unreachable\"; }"];
-    N14[label="expr if x > 1i { return; \"unreachable\"; }"];
-    N15[label="block { let x = 14i; if x > 1i { return; \"unreachable\"; } }"];
+    N14[label="expr if x > 1is { return; \"unreachable\"; }"];
+    N15[label="block { let x = 14is; if x > 1is { return; \"unreachable\"; } }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index 4bd9fc9ec1ad1bc5204429f1feb414d8e13be504..7b01c606083ff1d602f978a13a11b8a88911323b 100644 (file)
@@ -1,54 +1,54 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 15i"];
+    N2[label="expr 15is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 15i;"];
-    N5[label="expr 151i"];
+    N4[label="stmt let mut x = 15is;"];
+    N5[label="expr 151is"];
     N6[label="local mut y"];
-    N7[label="stmt let mut y = 151i;"];
+    N7[label="stmt let mut y = 151is;"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { break \'outer ; \"unreachable\"; }\l                if y >= 2i { break ; \"unreachable\"; }\l                y -= 3i;\l            }\l        y -= 4i;\l        x -= 5i;\l    }\l"];
+    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { break \'outer ; \"unreachable\"; }\l                if y >= 2is { break ; \"unreachable\"; }\l                y -= 3is;\l            }\l        y -= 4is;\l        x -= 5is;\l    }\l"];
     N10[label="(dummy_node)"];
-    N11[label="expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { break ; \"unreachable\"; }\l        y -= 3i;\l    }\l"];
+    N11[label="expr \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { break ; \"unreachable\"; }\l        y -= 3is;\l    }\l"];
     N12[label="expr x"];
-    N13[label="expr 1i"];
-    N14[label="expr x == 1i"];
+    N13[label="expr 1is"];
+    N14[label="expr x == 1is"];
     N15[label="expr break \'outer"];
     N16[label="(dummy_node)"];
     N17[label="stmt break \'outer ;"];
     N18[label="expr \"unreachable\""];
     N19[label="stmt \"unreachable\";"];
     N20[label="block { break \'outer ; \"unreachable\"; }"];
-    N21[label="expr if x == 1i { break \'outer ; \"unreachable\"; }"];
-    N22[label="stmt if x == 1i { break \'outer ; \"unreachable\"; }"];
+    N21[label="expr if x == 1is { break \'outer ; \"unreachable\"; }"];
+    N22[label="stmt if x == 1is { break \'outer ; \"unreachable\"; }"];
     N23[label="expr y"];
-    N24[label="expr 2i"];
-    N25[label="expr y >= 2i"];
+    N24[label="expr 2is"];
+    N25[label="expr y >= 2is"];
     N26[label="expr break"];
     N27[label="(dummy_node)"];
     N28[label="stmt break ;"];
     N29[label="expr \"unreachable\""];
     N30[label="stmt \"unreachable\";"];
     N31[label="block { break ; \"unreachable\"; }"];
-    N32[label="expr if y >= 2i { break ; \"unreachable\"; }"];
-    N33[label="stmt if y >= 2i { break ; \"unreachable\"; }"];
-    N34[label="expr 3i"];
+    N32[label="expr if y >= 2is { break ; \"unreachable\"; }"];
+    N33[label="stmt if y >= 2is { break ; \"unreachable\"; }"];
+    N34[label="expr 3is"];
     N35[label="expr y"];
-    N36[label="expr y -= 3i"];
-    N37[label="stmt y -= 3i;"];
-    N38[label="block {\l    if x == 1i { break \'outer ; \"unreachable\"; }\l    if y >= 2i { break ; \"unreachable\"; }\l    y -= 3i;\l}\l"];
-    N39[label="stmt \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { break ; \"unreachable\"; }\l        y -= 3i;\l    }\l"];
-    N40[label="expr 4i"];
+    N36[label="expr y -= 3is"];
+    N37[label="stmt y -= 3is;"];
+    N38[label="block {\l    if x == 1is { break \'outer ; \"unreachable\"; }\l    if y >= 2is { break ; \"unreachable\"; }\l    y -= 3is;\l}\l"];
+    N39[label="stmt \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { break ; \"unreachable\"; }\l        y -= 3is;\l    }\l"];
+    N40[label="expr 4is"];
     N41[label="expr y"];
-    N42[label="expr y -= 4i"];
-    N43[label="stmt y -= 4i;"];
-    N44[label="expr 5i"];
+    N42[label="expr y -= 4is"];
+    N43[label="stmt y -= 4is;"];
+    N44[label="expr 5is"];
     N45[label="expr x"];
-    N46[label="expr x -= 5i"];
-    N47[label="stmt x -= 5i;"];
-    N48[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\"; }\l            if y >= 2i { break ; \"unreachable\"; }\l            y -= 3i;\l        }\l    y -= 4i;\l    x -= 5i;\l}\l"];
-    N49[label="block {\l    let mut x = 15i;\l    let mut y = 151i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { break \'outer ; \"unreachable\"; }\l                    if y >= 2i { break ; \"unreachable\"; }\l                    y -= 3i;\l                }\l            y -= 4i;\l            x -= 5i;\l        }\l}\l"];
+    N46[label="expr x -= 5is"];
+    N47[label="stmt x -= 5is;"];
+    N48[label="block {\l    \'inner:\l        loop  {\l            if x == 1is { break \'outer ; \"unreachable\"; }\l            if y >= 2is { break ; \"unreachable\"; }\l            y -= 3is;\l        }\l    y -= 4is;\l    x -= 5is;\l}\l"];
+    N49[label="block {\l    let mut x = 15is;\l    let mut y = 151is;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1is { break \'outer ; \"unreachable\"; }\l                    if y >= 2is { break ; \"unreachable\"; }\l                    y -= 3is;\l                }\l            y -= 4is;\l            x -= 5is;\l        }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -61,7 +61,7 @@ digraph block {
     N12 -> N13;
     N13 -> N14;
     N14 -> N15;
-    N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { break \'outer ; \"unreachable\"; }\l    if y >= 2i { break ; \"unreachable\"; }\l    y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { break ; \"unreachable\"; }\l        y -= 3i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { break ; \"unreachable\"; }\l        y -= 3i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\"; }\l            if y >= 2i { break ; \"unreachable\"; }\l            y -= 3i;\l        }\l    y -= 4i;\l    x -= 5i;\l}\l"];
+    N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1is { break \'outer ; \"unreachable\"; }\l    if y >= 2is { break ; \"unreachable\"; }\l    y -= 3is;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { break ; \"unreachable\"; }\l        y -= 3is;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { break ; \"unreachable\"; }\l        y -= 3is;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1is { break \'outer ; \"unreachable\"; }\l            if y >= 2is { break ; \"unreachable\"; }\l            y -= 3is;\l        }\l    y -= 4is;\l    x -= 5is;\l}\l"];
     N16 -> N17;
     N17 -> N18;
     N18 -> N19;
@@ -73,7 +73,7 @@ digraph block {
     N23 -> N24;
     N24 -> N25;
     N25 -> N26;
-    N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 2i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 2i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { break \'outer ; \"unreachable\"; }\l    if y >= 2i { break ; \"unreachable\"; }\l    y -= 3i;\l}\l"];
+    N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 2is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 2is { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1is { break \'outer ; \"unreachable\"; }\l    if y >= 2is { break ; \"unreachable\"; }\l    y -= 3is;\l}\l"];
     N27 -> N28;
     N28 -> N29;
     N29 -> N30;
index 16b871bd844bf21779eb275fcabfc8a193a5ec60..2123185a083869415ef98d716fa46d6f5decb85e 100644 (file)
@@ -1,57 +1,57 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 16i"];
+    N2[label="expr 16is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 16i;"];
-    N5[label="expr 16i"];
+    N4[label="stmt let mut x = 16is;"];
+    N5[label="expr 16is"];
     N6[label="local mut y"];
-    N7[label="stmt let mut y = 16i;"];
+    N7[label="stmt let mut y = 16is;"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\"; }\l                if y >= 1i { break ; \"unreachable\"; }\l                y -= 1i;\l            }\l        y -= 1i;\l        x -= 1i;\l    }\l"];
+    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { continue \'outer ; \"unreachable\"; }\l                if y >= 1is { break ; \"unreachable\"; }\l                y -= 1is;\l            }\l        y -= 1is;\l        x -= 1is;\l    }\l"];
     N10[label="(dummy_node)"];
-    N11[label="expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 1i { break ; \"unreachable\"; }\l        y -= 1i;\l    }\l"];
+    N11[label="expr \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 1is { break ; \"unreachable\"; }\l        y -= 1is;\l    }\l"];
     N12[label="expr x"];
-    N13[label="expr 1i"];
-    N14[label="expr x == 1i"];
+    N13[label="expr 1is"];
+    N14[label="expr x == 1is"];
     N15[label="expr continue \'outer"];
     N16[label="(dummy_node)"];
     N17[label="stmt continue \'outer ;"];
     N18[label="expr \"unreachable\""];
     N19[label="stmt \"unreachable\";"];
     N20[label="block { continue \'outer ; \"unreachable\"; }"];
-    N21[label="expr if x == 1i { continue \'outer ; \"unreachable\"; }"];
-    N22[label="stmt if x == 1i { continue \'outer ; \"unreachable\"; }"];
+    N21[label="expr if x == 1is { continue \'outer ; \"unreachable\"; }"];
+    N22[label="stmt if x == 1is { continue \'outer ; \"unreachable\"; }"];
     N23[label="expr y"];
-    N24[label="expr 1i"];
-    N25[label="expr y >= 1i"];
+    N24[label="expr 1is"];
+    N25[label="expr y >= 1is"];
     N26[label="expr break"];
     N27[label="(dummy_node)"];
     N28[label="stmt break ;"];
     N29[label="expr \"unreachable\""];
     N30[label="stmt \"unreachable\";"];
     N31[label="block { break ; \"unreachable\"; }"];
-    N32[label="expr if y >= 1i { break ; \"unreachable\"; }"];
-    N33[label="stmt if y >= 1i { break ; \"unreachable\"; }"];
-    N34[label="expr 1i"];
+    N32[label="expr if y >= 1is { break ; \"unreachable\"; }"];
+    N33[label="stmt if y >= 1is { break ; \"unreachable\"; }"];
+    N34[label="expr 1is"];
     N35[label="expr y"];
-    N36[label="expr y -= 1i"];
-    N37[label="stmt y -= 1i;"];
-    N38[label="block {\l    if x == 1i { continue \'outer ; \"unreachable\"; }\l    if y >= 1i { break ; \"unreachable\"; }\l    y -= 1i;\l}\l"];
-    N39[label="stmt \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 1i { break ; \"unreachable\"; }\l        y -= 1i;\l    }\l"];
-    N40[label="expr 1i"];
+    N36[label="expr y -= 1is"];
+    N37[label="stmt y -= 1is;"];
+    N38[label="block {\l    if x == 1is { continue \'outer ; \"unreachable\"; }\l    if y >= 1is { break ; \"unreachable\"; }\l    y -= 1is;\l}\l"];
+    N39[label="stmt \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 1is { break ; \"unreachable\"; }\l        y -= 1is;\l    }\l"];
+    N40[label="expr 1is"];
     N41[label="expr y"];
-    N42[label="expr y -= 1i"];
-    N43[label="stmt y -= 1i;"];
-    N44[label="expr 1i"];
+    N42[label="expr y -= 1is"];
+    N43[label="stmt y -= 1is;"];
+    N44[label="expr 1is"];
     N45[label="expr x"];
-    N46[label="expr x -= 1i"];
-    N47[label="stmt x -= 1i;"];
-    N48[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\"; }\l            if y >= 1i { break ; \"unreachable\"; }\l            y -= 1i;\l        }\l    y -= 1i;\l    x -= 1i;\l}\l"];
-    N49[label="stmt \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\"; }\l                if y >= 1i { break ; \"unreachable\"; }\l                y -= 1i;\l            }\l        y -= 1i;\l        x -= 1i;\l    }\l"];
+    N46[label="expr x -= 1is"];
+    N47[label="stmt x -= 1is;"];
+    N48[label="block {\l    \'inner:\l        loop  {\l            if x == 1is { continue \'outer ; \"unreachable\"; }\l            if y >= 1is { break ; \"unreachable\"; }\l            y -= 1is;\l        }\l    y -= 1is;\l    x -= 1is;\l}\l"];
+    N49[label="stmt \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { continue \'outer ; \"unreachable\"; }\l                if y >= 1is { break ; \"unreachable\"; }\l                y -= 1is;\l            }\l        y -= 1is;\l        x -= 1is;\l    }\l"];
     N50[label="expr \"unreachable\""];
     N51[label="stmt \"unreachable\";"];
-    N52[label="block {\l    let mut x = 16i;\l    let mut y = 16i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { continue \'outer ; \"unreachable\"; }\l                    if y >= 1i { break ; \"unreachable\"; }\l                    y -= 1i;\l                }\l            y -= 1i;\l            x -= 1i;\l        }\l    \"unreachable\";\l}\l"];
+    N52[label="block {\l    let mut x = 16is;\l    let mut y = 16is;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1is { continue \'outer ; \"unreachable\"; }\l                    if y >= 1is { break ; \"unreachable\"; }\l                    y -= 1is;\l                }\l            y -= 1is;\l            x -= 1is;\l        }\l    \"unreachable\";\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -64,7 +64,7 @@ digraph block {
     N12 -> N13;
     N13 -> N14;
     N14 -> N15;
-    N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { continue \'outer ; \"unreachable\"; }\l    if y >= 1i { break ; \"unreachable\"; }\l    y -= 1i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 1i { break ; \"unreachable\"; }\l        y -= 1i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 1i { break ; \"unreachable\"; }\l        y -= 1i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\"; }\l            if y >= 1i { break ; \"unreachable\"; }\l            y -= 1i;\l        }\l    y -= 1i;\l    x -= 1i;\l}\l"];
+    N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1is { continue \'outer ; \"unreachable\"; }\l    if y >= 1is { break ; \"unreachable\"; }\l    y -= 1is;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 1is { break ; \"unreachable\"; }\l        y -= 1is;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 1is { break ; \"unreachable\"; }\l        y -= 1is;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1is { continue \'outer ; \"unreachable\"; }\l            if y >= 1is { break ; \"unreachable\"; }\l            y -= 1is;\l        }\l    y -= 1is;\l    x -= 1is;\l}\l"];
     N16 -> N17;
     N17 -> N18;
     N18 -> N19;
@@ -76,7 +76,7 @@ digraph block {
     N23 -> N24;
     N24 -> N25;
     N25 -> N26;
-    N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 1i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 1i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { continue \'outer ; \"unreachable\"; }\l    if y >= 1i { break ; \"unreachable\"; }\l    y -= 1i;\l}\l"];
+    N26 -> N11[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y >= 1is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y >= 1is { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1is { continue \'outer ; \"unreachable\"; }\l    if y >= 1is { break ; \"unreachable\"; }\l    y -= 1is;\l}\l"];
     N27 -> N28;
     N28 -> N29;
     N29 -> N30;
index c78224c00df8a552bd7cb300ac081362003e0ca0..7941b4f7ce540daee6eba3f28f0321a9b377cdb7 100644 (file)
@@ -1,13 +1,13 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 1i"];
-    N3[label="expr 7i"];
-    N4[label="expr 17i"];
-    N5[label="expr [1i, 7i, 17i]"];
+    N2[label="expr 1is"];
+    N3[label="expr 7is"];
+    N4[label="expr 17is"];
+    N5[label="expr [1is, 7is, 17is]"];
     N6[label="local _v"];
-    N7[label="stmt let _v = [1i, 7i, 17i];"];
-    N8[label="block { let _v = [1i, 7i, 17i]; }"];
+    N7[label="stmt let _v = [1is, 7is, 17is];"];
+    N8[label="block { let _v = [1is, 7is, 17is]; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index a625a1a0026fa254c52bd1753c217ef33ba7a4fc..c9e4b41c8126935c34914c3b8fc595729c6ec6bc 100644 (file)
@@ -1,17 +1,17 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 2u"];
-    N3[label="expr 0u"];
-    N4[label="expr 20u"];
-    N5[label="expr [2u, 0u, 20u]"];
+    N2[label="expr 2us"];
+    N3[label="expr 0us"];
+    N4[label="expr 20us"];
+    N5[label="expr [2us, 0us, 20us]"];
     N6[label="local v"];
-    N7[label="stmt let v = [2u, 0u, 20u];"];
+    N7[label="stmt let v = [2us, 0us, 20us];"];
     N8[label="expr v"];
-    N9[label="expr 20u"];
-    N10[label="expr v[20u]"];
-    N11[label="stmt v[20u];"];
-    N12[label="block { let v = [2u, 0u, 20u]; v[20u]; }"];
+    N9[label="expr 20us"];
+    N10[label="expr v[20us]"];
+    N11[label="stmt v[20us];"];
+    N12[label="block { let v = [2us, 0us, 20us]; v[20us]; }"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
index ad2ef60ce29183d7040f09abcc1de7dcefe9700f..e7a2cf2ff732f97e8d800858207ccf8f3f273b85 100644 (file)
@@ -1,52 +1,52 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 15i"];
+    N2[label="expr 15is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 15i;"];
-    N5[label="expr 151i"];
+    N4[label="stmt let mut x = 15is;"];
+    N5[label="expr 151is"];
     N6[label="local mut y"];
-    N7[label="stmt let mut y = 151i;"];
+    N7[label="stmt let mut y = 151is;"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { break \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                y -= 3i;\l                x -= 5i;\l            }\l        \"unreachable\";\l    }\l"];
+    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { break \'outer ; \"unreachable\"; }\l                if y >= 2is { return; \"unreachable\"; }\l                y -= 3is;\l                x -= 5is;\l            }\l        \"unreachable\";\l    }\l"];
     N10[label="(dummy_node)"];
-    N11[label="expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l"];
+    N11[label="expr \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        y -= 3is;\l        x -= 5is;\l    }\l"];
     N12[label="expr x"];
-    N13[label="expr 1i"];
-    N14[label="expr x == 1i"];
+    N13[label="expr 1is"];
+    N14[label="expr x == 1is"];
     N15[label="expr break \'outer"];
     N16[label="(dummy_node)"];
     N17[label="stmt break \'outer ;"];
     N18[label="expr \"unreachable\""];
     N19[label="stmt \"unreachable\";"];
     N20[label="block { break \'outer ; \"unreachable\"; }"];
-    N21[label="expr if x == 1i { break \'outer ; \"unreachable\"; }"];
-    N22[label="stmt if x == 1i { break \'outer ; \"unreachable\"; }"];
+    N21[label="expr if x == 1is { break \'outer ; \"unreachable\"; }"];
+    N22[label="stmt if x == 1is { break \'outer ; \"unreachable\"; }"];
     N23[label="expr y"];
-    N24[label="expr 2i"];
-    N25[label="expr y >= 2i"];
+    N24[label="expr 2is"];
+    N25[label="expr y >= 2is"];
     N26[label="expr return"];
     N27[label="(dummy_node)"];
     N28[label="stmt return;"];
     N29[label="expr \"unreachable\""];
     N30[label="stmt \"unreachable\";"];
     N31[label="block { return; \"unreachable\"; }"];
-    N32[label="expr if y >= 2i { return; \"unreachable\"; }"];
-    N33[label="stmt if y >= 2i { return; \"unreachable\"; }"];
-    N34[label="expr 3i"];
+    N32[label="expr if y >= 2is { return; \"unreachable\"; }"];
+    N33[label="stmt if y >= 2is { return; \"unreachable\"; }"];
+    N34[label="expr 3is"];
     N35[label="expr y"];
-    N36[label="expr y -= 3i"];
-    N37[label="stmt y -= 3i;"];
-    N38[label="expr 5i"];
+    N36[label="expr y -= 3is"];
+    N37[label="stmt y -= 3is;"];
+    N38[label="expr 5is"];
     N39[label="expr x"];
-    N40[label="expr x -= 5i"];
-    N41[label="stmt x -= 5i;"];
-    N42[label="block {\l    if x == 1i { break \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    y -= 3i;\l    x -= 5i;\l}\l"];
-    N43[label="stmt \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l"];
+    N40[label="expr x -= 5is"];
+    N41[label="stmt x -= 5is;"];
+    N42[label="block {\l    if x == 1is { break \'outer ; \"unreachable\"; }\l    if y >= 2is { return; \"unreachable\"; }\l    y -= 3is;\l    x -= 5is;\l}\l"];
+    N43[label="stmt \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        y -= 3is;\l        x -= 5is;\l    }\l"];
     N44[label="expr \"unreachable\""];
     N45[label="stmt \"unreachable\";"];
-    N46[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            y -= 3i;\l            x -= 5i;\l        }\l    \"unreachable\";\l}\l"];
-    N47[label="block {\l    let mut x = 15i;\l    let mut y = 151i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { break \'outer ; \"unreachable\"; }\l                    if y >= 2i { return; \"unreachable\"; }\l                    y -= 3i;\l                    x -= 5i;\l                }\l            \"unreachable\";\l        }\l}\l"];
+    N46[label="block {\l    \'inner:\l        loop  {\l            if x == 1is { break \'outer ; \"unreachable\"; }\l            if y >= 2is { return; \"unreachable\"; }\l            y -= 3is;\l            x -= 5is;\l        }\l    \"unreachable\";\l}\l"];
+    N47[label="block {\l    let mut x = 15is;\l    let mut y = 151is;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1is { break \'outer ; \"unreachable\"; }\l                    if y >= 2is { return; \"unreachable\"; }\l                    y -= 3is;\l                    x -= 5is;\l                }\l            \"unreachable\";\l        }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -59,7 +59,7 @@ digraph block {
     N12 -> N13;
     N13 -> N14;
     N14 -> N15;
-    N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { break \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    y -= 3i;\l    x -= 5i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { break \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            y -= 3i;\l            x -= 5i;\l        }\l    \"unreachable\";\l}\l"];
+    N15 -> N9[label="exiting scope_0 expr break \'outer,\lexiting scope_1 stmt break \'outer ;,\lexiting scope_2 block { break \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { break \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1is { break \'outer ; \"unreachable\"; }\l    if y >= 2is { return; \"unreachable\"; }\l    y -= 3is;\l    x -= 5is;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        y -= 3is;\l        x -= 5is;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        y -= 3is;\l        x -= 5is;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1is { break \'outer ; \"unreachable\"; }\l            if y >= 2is { return; \"unreachable\"; }\l            y -= 3is;\l            x -= 5is;\l        }\l    \"unreachable\";\l}\l"];
     N16 -> N17;
     N17 -> N18;
     N18 -> N19;
@@ -71,7 +71,7 @@ digraph block {
     N23 -> N24;
     N24 -> N25;
     N25 -> N26;
-    N26 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1i { break \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        y -= 3i;\l        x -= 5i;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { break \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                y -= 3i;\l                x -= 5i;\l            }\l        \"unreachable\";\l    }\l"];
+    N26 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1is { break \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        y -= 3is;\l        x -= 5is;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { break \'outer ; \"unreachable\"; }\l                if y >= 2is { return; \"unreachable\"; }\l                y -= 3is;\l                x -= 5is;\l            }\l        \"unreachable\";\l    }\l"];
     N27 -> N28;
     N28 -> N29;
     N29 -> N30;
index dcceb5bb937dac5548de1e1100de6d2eb3bfb8f0..edd39b40b36a3a7b13df891ed2a585d7e88259eb 100644 (file)
@@ -1,55 +1,55 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 15i"];
+    N2[label="expr 15is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 15i;"];
-    N5[label="expr 151i"];
+    N4[label="stmt let mut x = 15is;"];
+    N5[label="expr 151is"];
     N6[label="local mut y"];
-    N7[label="stmt let mut y = 151i;"];
+    N7[label="stmt let mut y = 151is;"];
     N8[label="(dummy_node)"];
-    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                x -= 1i;\l                y -= 3i;\l            }\l        \"unreachable\";\l    }\l"];
+    N9[label="expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { continue \'outer ; \"unreachable\"; }\l                if y >= 2is { return; \"unreachable\"; }\l                x -= 1is;\l                y -= 3is;\l            }\l        \"unreachable\";\l    }\l"];
     N10[label="(dummy_node)"];
-    N11[label="expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l"];
+    N11[label="expr \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        x -= 1is;\l        y -= 3is;\l    }\l"];
     N12[label="expr x"];
-    N13[label="expr 1i"];
-    N14[label="expr x == 1i"];
+    N13[label="expr 1is"];
+    N14[label="expr x == 1is"];
     N15[label="expr continue \'outer"];
     N16[label="(dummy_node)"];
     N17[label="stmt continue \'outer ;"];
     N18[label="expr \"unreachable\""];
     N19[label="stmt \"unreachable\";"];
     N20[label="block { continue \'outer ; \"unreachable\"; }"];
-    N21[label="expr if x == 1i { continue \'outer ; \"unreachable\"; }"];
-    N22[label="stmt if x == 1i { continue \'outer ; \"unreachable\"; }"];
+    N21[label="expr if x == 1is { continue \'outer ; \"unreachable\"; }"];
+    N22[label="stmt if x == 1is { continue \'outer ; \"unreachable\"; }"];
     N23[label="expr y"];
-    N24[label="expr 2i"];
-    N25[label="expr y >= 2i"];
+    N24[label="expr 2is"];
+    N25[label="expr y >= 2is"];
     N26[label="expr return"];
     N27[label="(dummy_node)"];
     N28[label="stmt return;"];
     N29[label="expr \"unreachable\""];
     N30[label="stmt \"unreachable\";"];
     N31[label="block { return; \"unreachable\"; }"];
-    N32[label="expr if y >= 2i { return; \"unreachable\"; }"];
-    N33[label="stmt if y >= 2i { return; \"unreachable\"; }"];
-    N34[label="expr 1i"];
+    N32[label="expr if y >= 2is { return; \"unreachable\"; }"];
+    N33[label="stmt if y >= 2is { return; \"unreachable\"; }"];
+    N34[label="expr 1is"];
     N35[label="expr x"];
-    N36[label="expr x -= 1i"];
-    N37[label="stmt x -= 1i;"];
-    N38[label="expr 3i"];
+    N36[label="expr x -= 1is"];
+    N37[label="stmt x -= 1is;"];
+    N38[label="expr 3is"];
     N39[label="expr y"];
-    N40[label="expr y -= 3i"];
-    N41[label="stmt y -= 3i;"];
-    N42[label="block {\l    if x == 1i { continue \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    x -= 1i;\l    y -= 3i;\l}\l"];
-    N43[label="stmt \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l"];
+    N40[label="expr y -= 3is"];
+    N41[label="stmt y -= 3is;"];
+    N42[label="block {\l    if x == 1is { continue \'outer ; \"unreachable\"; }\l    if y >= 2is { return; \"unreachable\"; }\l    x -= 1is;\l    y -= 3is;\l}\l"];
+    N43[label="stmt \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        x -= 1is;\l        y -= 3is;\l    }\l"];
     N44[label="expr \"unreachable\""];
     N45[label="stmt \"unreachable\";"];
-    N46[label="block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            x -= 1i;\l            y -= 3i;\l        }\l    \"unreachable\";\l}\l"];
-    N47[label="stmt \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                x -= 1i;\l                y -= 3i;\l            }\l        \"unreachable\";\l    }\l"];
+    N46[label="block {\l    \'inner:\l        loop  {\l            if x == 1is { continue \'outer ; \"unreachable\"; }\l            if y >= 2is { return; \"unreachable\"; }\l            x -= 1is;\l            y -= 3is;\l        }\l    \"unreachable\";\l}\l"];
+    N47[label="stmt \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { continue \'outer ; \"unreachable\"; }\l                if y >= 2is { return; \"unreachable\"; }\l                x -= 1is;\l                y -= 3is;\l            }\l        \"unreachable\";\l    }\l"];
     N48[label="expr \"unreachable\""];
     N49[label="stmt \"unreachable\";"];
-    N50[label="block {\l    let mut x = 15i;\l    let mut y = 151i;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1i { continue \'outer ; \"unreachable\"; }\l                    if y >= 2i { return; \"unreachable\"; }\l                    x -= 1i;\l                    y -= 3i;\l                }\l            \"unreachable\";\l        }\l    \"unreachable\";\l}\l"];
+    N50[label="block {\l    let mut x = 15is;\l    let mut y = 151is;\l    \'outer:\l        loop  {\l            \'inner:\l                loop  {\l                    if x == 1is { continue \'outer ; \"unreachable\"; }\l                    if y >= 2is { return; \"unreachable\"; }\l                    x -= 1is;\l                    y -= 3is;\l                }\l            \"unreachable\";\l        }\l    \"unreachable\";\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -62,7 +62,7 @@ digraph block {
     N12 -> N13;
     N13 -> N14;
     N14 -> N15;
-    N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1i { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1i { continue \'outer ; \"unreachable\"; }\l    if y >= 2i { return; \"unreachable\"; }\l    x -= 1i;\l    y -= 3i;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1i { continue \'outer ; \"unreachable\"; }\l            if y >= 2i { return; \"unreachable\"; }\l            x -= 1i;\l            y -= 3i;\l        }\l    \"unreachable\";\l}\l"];
+    N15 -> N8[label="exiting scope_0 expr continue \'outer,\lexiting scope_1 stmt continue \'outer ;,\lexiting scope_2 block { continue \'outer ; \"unreachable\"; },\lexiting scope_3 expr if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_4 stmt if x == 1is { continue \'outer ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 1is { continue \'outer ; \"unreachable\"; }\l    if y >= 2is { return; \"unreachable\"; }\l    x -= 1is;\l    y -= 3is;\l}\l,\lexiting scope_6 expr \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        x -= 1is;\l        y -= 3is;\l    }\l,\lexiting scope_7 stmt \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        x -= 1is;\l        y -= 3is;\l    }\l,\lexiting scope_8 block {\l    \'inner:\l        loop  {\l            if x == 1is { continue \'outer ; \"unreachable\"; }\l            if y >= 2is { return; \"unreachable\"; }\l            x -= 1is;\l            y -= 3is;\l        }\l    \"unreachable\";\l}\l"];
     N16 -> N17;
     N17 -> N18;
     N18 -> N19;
@@ -74,7 +74,7 @@ digraph block {
     N23 -> N24;
     N24 -> N25;
     N25 -> N26;
-    N26 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1i { continue \'outer ; \"unreachable\"; }\l        if y >= 2i { return; \"unreachable\"; }\l        x -= 1i;\l        y -= 3i;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1i { continue \'outer ; \"unreachable\"; }\l                if y >= 2i { return; \"unreachable\"; }\l                x -= 1i;\l                y -= 3i;\l            }\l        \"unreachable\";\l    }\l"];
+    N26 -> N1[label="exiting scope_0 expr \'inner:\l    loop  {\l        if x == 1is { continue \'outer ; \"unreachable\"; }\l        if y >= 2is { return; \"unreachable\"; }\l        x -= 1is;\l        y -= 3is;\l    }\l,\lexiting scope_1 expr \'outer:\l    loop  {\l        \'inner:\l            loop  {\l                if x == 1is { continue \'outer ; \"unreachable\"; }\l                if y >= 2is { return; \"unreachable\"; }\l                x -= 1is;\l                y -= 3is;\l            }\l        \"unreachable\";\l    }\l"];
     N27 -> N28;
     N28 -> N29;
     N29 -> N30;
index 034ecfb7f2099d2a74fe09266f93caf5ad2413e4..2b5c5cdff44e33eb69d60ef07ab9a9904aa40998 100644 (file)
@@ -1,57 +1,57 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 23i"];
+    N2[label="expr 23is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 23i;"];
-    N5[label="expr 23i"];
+    N4[label="stmt let mut x = 23is;"];
+    N5[label="expr 23is"];
     N6[label="local mut y"];
-    N7[label="stmt let mut y = 23i;"];
-    N8[label="expr 23i"];
+    N7[label="stmt let mut y = 23is;"];
+    N8[label="expr 23is"];
     N9[label="local mut z"];
-    N10[label="stmt let mut z = 23i;"];
+    N10[label="stmt let mut z = 23is;"];
     N11[label="(dummy_node)"];
     N12[label="expr x"];
-    N13[label="expr 0i"];
-    N14[label="expr x > 0i"];
-    N15[label="expr while x > 0i {\l    x -= 1i;\l    while y > 0i {\l        y -= 1i;\l        while z > 0i { z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
-    N16[label="expr 1i"];
+    N13[label="expr 0is"];
+    N14[label="expr x > 0is"];
+    N15[label="expr while x > 0is {\l    x -= 1is;\l    while y > 0is {\l        y -= 1is;\l        while z > 0is { z -= 1is; }\l        if x > 10is { return; \"unreachable\"; }\l    }\l}\l"];
+    N16[label="expr 1is"];
     N17[label="expr x"];
-    N18[label="expr x -= 1i"];
-    N19[label="stmt x -= 1i;"];
+    N18[label="expr x -= 1is"];
+    N19[label="stmt x -= 1is;"];
     N20[label="(dummy_node)"];
     N21[label="expr y"];
-    N22[label="expr 0i"];
-    N23[label="expr y > 0i"];
-    N24[label="expr while y > 0i {\l    y -= 1i;\l    while z > 0i { z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
-    N25[label="expr 1i"];
+    N22[label="expr 0is"];
+    N23[label="expr y > 0is"];
+    N24[label="expr while y > 0is {\l    y -= 1is;\l    while z > 0is { z -= 1is; }\l    if x > 10is { return; \"unreachable\"; }\l}\l"];
+    N25[label="expr 1is"];
     N26[label="expr y"];
-    N27[label="expr y -= 1i"];
-    N28[label="stmt y -= 1i;"];
+    N27[label="expr y -= 1is"];
+    N28[label="stmt y -= 1is;"];
     N29[label="(dummy_node)"];
     N30[label="expr z"];
-    N31[label="expr 0i"];
-    N32[label="expr z > 0i"];
-    N33[label="expr while z > 0i { z -= 1i; }"];
-    N34[label="expr 1i"];
+    N31[label="expr 0is"];
+    N32[label="expr z > 0is"];
+    N33[label="expr while z > 0is { z -= 1is; }"];
+    N34[label="expr 1is"];
     N35[label="expr z"];
-    N36[label="expr z -= 1i"];
-    N37[label="stmt z -= 1i;"];
-    N38[label="block { z -= 1i; }"];
-    N39[label="stmt while z > 0i { z -= 1i; }"];
+    N36[label="expr z -= 1is"];
+    N37[label="stmt z -= 1is;"];
+    N38[label="block { z -= 1is; }"];
+    N39[label="stmt while z > 0is { z -= 1is; }"];
     N40[label="expr x"];
-    N41[label="expr 10i"];
-    N42[label="expr x > 10i"];
+    N41[label="expr 10is"];
+    N42[label="expr x > 10is"];
     N43[label="expr return"];
     N44[label="(dummy_node)"];
     N45[label="stmt return;"];
     N46[label="expr \"unreachable\""];
     N47[label="stmt \"unreachable\";"];
     N48[label="block { return; \"unreachable\"; }"];
-    N49[label="expr if x > 10i { return; \"unreachable\"; }"];
-    N50[label="block { y -= 1i; while z > 0i { z -= 1i; } if x > 10i { return; \"unreachable\"; } }"];
-    N51[label="block {\l    x -= 1i;\l    while y > 0i {\l        y -= 1i;\l        while z > 0i { z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
-    N52[label="block {\l    let mut x = 23i;\l    let mut y = 23i;\l    let mut z = 23i;\l    while x > 0i {\l        x -= 1i;\l        while y > 0i {\l            y -= 1i;\l            while z > 0i { z -= 1i; }\l            if x > 10i { return; \"unreachable\"; }\l        }\l    }\l}\l"];
+    N49[label="expr if x > 10is { return; \"unreachable\"; }"];
+    N50[label="block {\l    y -= 1is;\l    while z > 0is { z -= 1is; }\l    if x > 10is { return; \"unreachable\"; }\l}\l"];
+    N51[label="block {\l    x -= 1is;\l    while y > 0is {\l        y -= 1is;\l        while z > 0is { z -= 1is; }\l        if x > 10is { return; \"unreachable\"; }\l    }\l}\l"];
+    N52[label="block {\l    let mut x = 23is;\l    let mut y = 23is;\l    let mut z = 23is;\l    while x > 0is {\l        x -= 1is;\l        while y > 0is {\l            y -= 1is;\l            while z > 0is { z -= 1is; }\l            if x > 10is { return; \"unreachable\"; }\l        }\l    }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -95,7 +95,7 @@ digraph block {
     N40 -> N41;
     N41 -> N42;
     N42 -> N43;
-    N43 -> N1[label="exiting scope_0 expr while y > 0i {\l    y -= 1i;\l    while z > 0i { z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0i {\l    x -= 1i;\l    while y > 0i {\l        y -= 1i;\l        while z > 0i { z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
+    N43 -> N1[label="exiting scope_0 expr while y > 0is {\l    y -= 1is;\l    while z > 0is { z -= 1is; }\l    if x > 10is { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0is {\l    x -= 1is;\l    while y > 0is {\l        y -= 1is;\l        while z > 0is { z -= 1is; }\l        if x > 10is { return; \"unreachable\"; }\l    }\l}\l"];
     N44 -> N45;
     N45 -> N46;
     N46 -> N47;
index ddb5b865c2edb1bbd53de287e27bab725440ae73..ee3fe7ced6cd71d6b4d0fa691c67e8233106aa15 100644 (file)
@@ -1,81 +1,81 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 24i"];
+    N2[label="expr 24is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 24i;"];
-    N5[label="expr 24i"];
+    N4[label="stmt let mut x = 24is;"];
+    N5[label="expr 24is"];
     N6[label="local mut y"];
-    N7[label="stmt let mut y = 24i;"];
-    N8[label="expr 24i"];
+    N7[label="stmt let mut y = 24is;"];
+    N8[label="expr 24is"];
     N9[label="local mut z"];
-    N10[label="stmt let mut z = 24i;"];
+    N10[label="stmt let mut z = 24is;"];
     N11[label="(dummy_node)"];
-    N12[label="expr loop  {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
+    N12[label="expr loop  {\l    if x == 0is { break ; \"unreachable\"; }\l    x -= 1is;\l    loop  {\l        if y == 0is { break ; \"unreachable\"; }\l        y -= 1is;\l        loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l        if x > 10is { return; \"unreachable\"; }\l    }\l}\l"];
     N13[label="expr x"];
-    N14[label="expr 0i"];
-    N15[label="expr x == 0i"];
+    N14[label="expr 0is"];
+    N15[label="expr x == 0is"];
     N16[label="expr break"];
     N17[label="(dummy_node)"];
     N18[label="stmt break ;"];
     N19[label="expr \"unreachable\""];
     N20[label="stmt \"unreachable\";"];
     N21[label="block { break ; \"unreachable\"; }"];
-    N22[label="expr if x == 0i { break ; \"unreachable\"; }"];
-    N23[label="stmt if x == 0i { break ; \"unreachable\"; }"];
-    N24[label="expr 1i"];
+    N22[label="expr if x == 0is { break ; \"unreachable\"; }"];
+    N23[label="stmt if x == 0is { break ; \"unreachable\"; }"];
+    N24[label="expr 1is"];
     N25[label="expr x"];
-    N26[label="expr x -= 1i"];
-    N27[label="stmt x -= 1i;"];
+    N26[label="expr x -= 1is"];
+    N27[label="stmt x -= 1is;"];
     N28[label="(dummy_node)"];
-    N29[label="expr loop  {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
+    N29[label="expr loop  {\l    if y == 0is { break ; \"unreachable\"; }\l    y -= 1is;\l    loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l    if x > 10is { return; \"unreachable\"; }\l}\l"];
     N30[label="expr y"];
-    N31[label="expr 0i"];
-    N32[label="expr y == 0i"];
+    N31[label="expr 0is"];
+    N32[label="expr y == 0is"];
     N33[label="expr break"];
     N34[label="(dummy_node)"];
     N35[label="stmt break ;"];
     N36[label="expr \"unreachable\""];
     N37[label="stmt \"unreachable\";"];
     N38[label="block { break ; \"unreachable\"; }"];
-    N39[label="expr if y == 0i { break ; \"unreachable\"; }"];
-    N40[label="stmt if y == 0i { break ; \"unreachable\"; }"];
-    N41[label="expr 1i"];
+    N39[label="expr if y == 0is { break ; \"unreachable\"; }"];
+    N40[label="stmt if y == 0is { break ; \"unreachable\"; }"];
+    N41[label="expr 1is"];
     N42[label="expr y"];
-    N43[label="expr y -= 1i"];
-    N44[label="stmt y -= 1i;"];
+    N43[label="expr y -= 1is"];
+    N44[label="stmt y -= 1is;"];
     N45[label="(dummy_node)"];
-    N46[label="expr loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
+    N46[label="expr loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
     N47[label="expr z"];
-    N48[label="expr 0i"];
-    N49[label="expr z == 0i"];
+    N48[label="expr 0is"];
+    N49[label="expr z == 0is"];
     N50[label="expr break"];
     N51[label="(dummy_node)"];
     N52[label="stmt break ;"];
     N53[label="expr \"unreachable\""];
     N54[label="stmt \"unreachable\";"];
     N55[label="block { break ; \"unreachable\"; }"];
-    N56[label="expr if z == 0i { break ; \"unreachable\"; }"];
-    N57[label="stmt if z == 0i { break ; \"unreachable\"; }"];
-    N58[label="expr 1i"];
+    N56[label="expr if z == 0is { break ; \"unreachable\"; }"];
+    N57[label="stmt if z == 0is { break ; \"unreachable\"; }"];
+    N58[label="expr 1is"];
     N59[label="expr z"];
-    N60[label="expr z -= 1i"];
-    N61[label="stmt z -= 1i;"];
-    N62[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
-    N63[label="stmt loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
+    N60[label="expr z -= 1is"];
+    N61[label="stmt z -= 1is;"];
+    N62[label="block { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
+    N63[label="stmt loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
     N64[label="expr x"];
-    N65[label="expr 10i"];
-    N66[label="expr x > 10i"];
+    N65[label="expr 10is"];
+    N66[label="expr x > 10is"];
     N67[label="expr return"];
     N68[label="(dummy_node)"];
     N69[label="stmt return;"];
     N70[label="expr \"unreachable\""];
     N71[label="stmt \"unreachable\";"];
     N72[label="block { return; \"unreachable\"; }"];
-    N73[label="expr if x > 10i { return; \"unreachable\"; }"];
-    N74[label="block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
-    N75[label="block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
-    N76[label="block {\l    let mut x = 24i;\l    let mut y = 24i;\l    let mut z = 24i;\l    loop  {\l        if x == 0i { break ; \"unreachable\"; }\l        x -= 1i;\l        loop  {\l            if y == 0i { break ; \"unreachable\"; }\l            y -= 1i;\l            loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l            if x > 10i { return; \"unreachable\"; }\l        }\l    }\l}\l"];
+    N73[label="expr if x > 10is { return; \"unreachable\"; }"];
+    N74[label="block {\l    if y == 0is { break ; \"unreachable\"; }\l    y -= 1is;\l    loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l    if x > 10is { return; \"unreachable\"; }\l}\l"];
+    N75[label="block {\l    if x == 0is { break ; \"unreachable\"; }\l    x -= 1is;\l    loop  {\l        if y == 0is { break ; \"unreachable\"; }\l        y -= 1is;\l        loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l        if x > 10is { return; \"unreachable\"; }\l    }\l}\l"];
+    N76[label="block {\l    let mut x = 24is;\l    let mut y = 24is;\l    let mut z = 24is;\l    loop  {\l        if x == 0is { break ; \"unreachable\"; }\l        x -= 1is;\l        loop  {\l            if y == 0is { break ; \"unreachable\"; }\l            y -= 1is;\l            loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l            if x > 10is { return; \"unreachable\"; }\l        }\l    }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -90,7 +90,7 @@ digraph block {
     N13 -> N14;
     N14 -> N15;
     N15 -> N16;
-    N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
+    N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0is { break ; \"unreachable\"; }\l    x -= 1is;\l    loop  {\l        if y == 0is { break ; \"unreachable\"; }\l        y -= 1is;\l        loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l        if x > 10is { return; \"unreachable\"; }\l    }\l}\l"];
     N17 -> N18;
     N18 -> N19;
     N19 -> N20;
@@ -107,7 +107,7 @@ digraph block {
     N30 -> N31;
     N31 -> N32;
     N32 -> N33;
-    N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l"];
+    N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0is { break ; \"unreachable\"; }\l    y -= 1is;\l    loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l    if x > 10is { return; \"unreachable\"; }\l}\l"];
     N34 -> N35;
     N35 -> N36;
     N36 -> N37;
@@ -124,7 +124,7 @@ digraph block {
     N47 -> N48;
     N48 -> N49;
     N49 -> N50;
-    N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
+    N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0is { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
     N51 -> N52;
     N52 -> N53;
     N53 -> N54;
@@ -143,7 +143,7 @@ digraph block {
     N64 -> N65;
     N65 -> N66;
     N66 -> N67;
-    N67 -> N1[label="exiting scope_0 expr loop  {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop  {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { return; \"unreachable\"; }\l    }\l}\l"];
+    N67 -> N1[label="exiting scope_0 expr loop  {\l    if y == 0is { break ; \"unreachable\"; }\l    y -= 1is;\l    loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l    if x > 10is { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop  {\l    if x == 0is { break ; \"unreachable\"; }\l    x -= 1is;\l    loop  {\l        if y == 0is { break ; \"unreachable\"; }\l        y -= 1is;\l        loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l        if x > 10is { return; \"unreachable\"; }\l    }\l}\l"];
     N68 -> N69;
     N69 -> N70;
     N70 -> N71;
index 9fd4dbfc395533a2af883b4303ead75beb20c957..82799c724b0bde59299236539d819b70c33a3603 100644 (file)
@@ -1,81 +1,81 @@
 digraph block {
     N0[label="entry"];
     N1[label="exit"];
-    N2[label="expr 25i"];
+    N2[label="expr 25is"];
     N3[label="local mut x"];
-    N4[label="stmt let mut x = 25i;"];
-    N5[label="expr 25i"];
+    N4[label="stmt let mut x = 25is;"];
+    N5[label="expr 25is"];
     N6[label="local mut y"];
-    N7[label="stmt let mut y = 25i;"];
-    N8[label="expr 25i"];
+    N7[label="stmt let mut y = 25is;"];
+    N8[label="expr 25is"];
     N9[label="local mut z"];
-    N10[label="stmt let mut z = 25i;"];
+    N10[label="stmt let mut z = 25is;"];
     N11[label="(dummy_node)"];
-    N12[label="expr \'a:\l    loop  {\l        if x == 0i { break ; \"unreachable\"; }\l        x -= 1i;\l        \'a:\l            loop  {\l                if y == 0i { break ; \"unreachable\"; }\l                y -= 1i;\l                \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l                if x > 10i { continue \'a ; \"unreachable\"; }\l            }\l    }\l"];
+    N12[label="expr \'a:\l    loop  {\l        if x == 0is { break ; \"unreachable\"; }\l        x -= 1is;\l        \'a:\l            loop  {\l                if y == 0is { break ; \"unreachable\"; }\l                y -= 1is;\l                \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l                if x > 10is { continue \'a ; \"unreachable\"; }\l            }\l    }\l"];
     N13[label="expr x"];
-    N14[label="expr 0i"];
-    N15[label="expr x == 0i"];
+    N14[label="expr 0is"];
+    N15[label="expr x == 0is"];
     N16[label="expr break"];
     N17[label="(dummy_node)"];
     N18[label="stmt break ;"];
     N19[label="expr \"unreachable\""];
     N20[label="stmt \"unreachable\";"];
     N21[label="block { break ; \"unreachable\"; }"];
-    N22[label="expr if x == 0i { break ; \"unreachable\"; }"];
-    N23[label="stmt if x == 0i { break ; \"unreachable\"; }"];
-    N24[label="expr 1i"];
+    N22[label="expr if x == 0is { break ; \"unreachable\"; }"];
+    N23[label="stmt if x == 0is { break ; \"unreachable\"; }"];
+    N24[label="expr 1is"];
     N25[label="expr x"];
-    N26[label="expr x -= 1i"];
-    N27[label="stmt x -= 1i;"];
+    N26[label="expr x -= 1is"];
+    N27[label="stmt x -= 1is;"];
     N28[label="(dummy_node)"];
-    N29[label="expr \'a:\l    loop  {\l        if y == 0i { break ; \"unreachable\"; }\l        y -= 1i;\l        \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l        if x > 10i { continue \'a ; \"unreachable\"; }\l    }\l"];
+    N29[label="expr \'a:\l    loop  {\l        if y == 0is { break ; \"unreachable\"; }\l        y -= 1is;\l        \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l        if x > 10is { continue \'a ; \"unreachable\"; }\l    }\l"];
     N30[label="expr y"];
-    N31[label="expr 0i"];
-    N32[label="expr y == 0i"];
+    N31[label="expr 0is"];
+    N32[label="expr y == 0is"];
     N33[label="expr break"];
     N34[label="(dummy_node)"];
     N35[label="stmt break ;"];
     N36[label="expr \"unreachable\""];
     N37[label="stmt \"unreachable\";"];
     N38[label="block { break ; \"unreachable\"; }"];
-    N39[label="expr if y == 0i { break ; \"unreachable\"; }"];
-    N40[label="stmt if y == 0i { break ; \"unreachable\"; }"];
-    N41[label="expr 1i"];
+    N39[label="expr if y == 0is { break ; \"unreachable\"; }"];
+    N40[label="stmt if y == 0is { break ; \"unreachable\"; }"];
+    N41[label="expr 1is"];
     N42[label="expr y"];
-    N43[label="expr y -= 1i"];
-    N44[label="stmt y -= 1i;"];
+    N43[label="expr y -= 1is"];
+    N44[label="stmt y -= 1is;"];
     N45[label="(dummy_node)"];
-    N46[label="expr \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
+    N46[label="expr \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
     N47[label="expr z"];
-    N48[label="expr 0i"];
-    N49[label="expr z == 0i"];
+    N48[label="expr 0is"];
+    N49[label="expr z == 0is"];
     N50[label="expr break"];
     N51[label="(dummy_node)"];
     N52[label="stmt break ;"];
     N53[label="expr \"unreachable\""];
     N54[label="stmt \"unreachable\";"];
     N55[label="block { break ; \"unreachable\"; }"];
-    N56[label="expr if z == 0i { break ; \"unreachable\"; }"];
-    N57[label="stmt if z == 0i { break ; \"unreachable\"; }"];
-    N58[label="expr 1i"];
+    N56[label="expr if z == 0is { break ; \"unreachable\"; }"];
+    N57[label="stmt if z == 0is { break ; \"unreachable\"; }"];
+    N58[label="expr 1is"];
     N59[label="expr z"];
-    N60[label="expr z -= 1i"];
-    N61[label="stmt z -= 1i;"];
-    N62[label="block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
-    N63[label="stmt \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
+    N60[label="expr z -= 1is"];
+    N61[label="stmt z -= 1is;"];
+    N62[label="block { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
+    N63[label="stmt \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
     N64[label="expr x"];
-    N65[label="expr 10i"];
-    N66[label="expr x > 10i"];
+    N65[label="expr 10is"];
+    N66[label="expr x > 10is"];
     N67[label="expr continue \'a"];
     N68[label="(dummy_node)"];
     N69[label="stmt continue \'a ;"];
     N70[label="expr \"unreachable\""];
     N71[label="stmt \"unreachable\";"];
     N72[label="block { continue \'a ; \"unreachable\"; }"];
-    N73[label="expr if x > 10i { continue \'a ; \"unreachable\"; }"];
-    N74[label="block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"];
-    N75[label="block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    \'a:\l        loop  {\l            if y == 0i { break ; \"unreachable\"; }\l            y -= 1i;\l            \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l            if x > 10i { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
-    N76[label="block {\l    let mut x = 25i;\l    let mut y = 25i;\l    let mut z = 25i;\l    \'a:\l        loop  {\l            if x == 0i { break ; \"unreachable\"; }\l            x -= 1i;\l            \'a:\l                loop  {\l                    if y == 0i { break ; \"unreachable\"; }\l                    y -= 1i;\l                    \'a:\l                        loop  {\l                            if z == 0i { break ; \"unreachable\"; }\l                            z -= 1i;\l                        }\l                    if x > 10i { continue \'a ; \"unreachable\"; }\l                }\l        }\l}\l"];
+    N73[label="expr if x > 10is { continue \'a ; \"unreachable\"; }"];
+    N74[label="block {\l    if y == 0is { break ; \"unreachable\"; }\l    y -= 1is;\l    \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l    if x > 10is { continue \'a ; \"unreachable\"; }\l}\l"];
+    N75[label="block {\l    if x == 0is { break ; \"unreachable\"; }\l    x -= 1is;\l    \'a:\l        loop  {\l            if y == 0is { break ; \"unreachable\"; }\l            y -= 1is;\l            \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l            if x > 10is { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
+    N76[label="block {\l    let mut x = 25is;\l    let mut y = 25is;\l    let mut z = 25is;\l    \'a:\l        loop  {\l            if x == 0is { break ; \"unreachable\"; }\l            x -= 1is;\l            \'a:\l                loop  {\l                    if y == 0is { break ; \"unreachable\"; }\l                    y -= 1is;\l                    \'a:\l                        loop  {\l                            if z == 0is { break ; \"unreachable\"; }\l                            z -= 1is;\l                        }\l                    if x > 10is { continue \'a ; \"unreachable\"; }\l                }\l        }\l}\l"];
     N0 -> N2;
     N2 -> N3;
     N3 -> N4;
@@ -90,7 +90,7 @@ digraph block {
     N13 -> N14;
     N14 -> N15;
     N15 -> N16;
-    N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0i { break ; \"unreachable\"; }\l    x -= 1i;\l    \'a:\l        loop  {\l            if y == 0i { break ; \"unreachable\"; }\l            y -= 1i;\l            \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l            if x > 10i { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
+    N16 -> N12[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if x == 0is { break ; \"unreachable\"; }\l    x -= 1is;\l    \'a:\l        loop  {\l            if y == 0is { break ; \"unreachable\"; }\l            y -= 1is;\l            \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l            if x > 10is { continue \'a ; \"unreachable\"; }\l        }\l}\l"];
     N17 -> N18;
     N18 -> N19;
     N19 -> N20;
@@ -107,7 +107,7 @@ digraph block {
     N30 -> N31;
     N31 -> N32;
     N32 -> N33;
-    N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0i { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"];
+    N33 -> N29[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0is { break ; \"unreachable\"; },\lexiting scope_5 block {\l    if y == 0is { break ; \"unreachable\"; }\l    y -= 1is;\l    \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l    if x > 10is { continue \'a ; \"unreachable\"; }\l}\l"];
     N34 -> N35;
     N35 -> N36;
     N36 -> N37;
@@ -124,7 +124,7 @@ digraph block {
     N47 -> N48;
     N48 -> N49;
     N49 -> N50;
-    N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0i { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0i { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0i { break ; \"unreachable\"; } z -= 1i; }"];
+    N50 -> N46[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0is { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0is { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0is { break ; \"unreachable\"; } z -= 1is; }"];
     N51 -> N52;
     N52 -> N53;
     N53 -> N54;
@@ -143,7 +143,7 @@ digraph block {
     N64 -> N65;
     N65 -> N66;
     N66 -> N67;
-    N67 -> N28[label="exiting scope_0 expr continue \'a,\lexiting scope_1 stmt continue \'a ;,\lexiting scope_2 block { continue \'a ; \"unreachable\"; },\lexiting scope_3 expr if x > 10i { continue \'a ; \"unreachable\"; },\lexiting scope_4 block {\l    if y == 0i { break ; \"unreachable\"; }\l    y -= 1i;\l    \'a: loop  { if z == 0i { break ; \"unreachable\"; } z -= 1i; }\l    if x > 10i { continue \'a ; \"unreachable\"; }\l}\l"];
+    N67 -> N28[label="exiting scope_0 expr continue \'a,\lexiting scope_1 stmt continue \'a ;,\lexiting scope_2 block { continue \'a ; \"unreachable\"; },\lexiting scope_3 expr if x > 10is { continue \'a ; \"unreachable\"; },\lexiting scope_4 block {\l    if y == 0is { break ; \"unreachable\"; }\l    y -= 1is;\l    \'a: loop  { if z == 0is { break ; \"unreachable\"; } z -= 1is; }\l    if x > 10is { continue \'a ; \"unreachable\"; }\l}\l"];
     N68 -> N69;
     N69 -> N70;
     N70 -> N71;
index faac858e76e0b34aca046641d6fa04ecb821c18e..bd88cb19aa7c0bf1f9a264024a446860169f6ee5 100644 (file)
@@ -22,7 +22,7 @@ fn drop(&mut self) {
 }
 
 fn main() {
-    Thread::spawn(move|| {
+    Thread::scoped(move|| {
         let _a = A;
         lib::callback(|| panic!());
         1i
index 23228d499951cc1af871d6b7583636e2eb215cf2..aeb6a89a98ea6e2c50030096399f7546c5b1ffec 100644 (file)
@@ -21,6 +21,7 @@ fn syntax_extension(cx: &ExtCtxt) {
     let _toks_1 = vec![quote_tokens!(cx, /** comment */ fn foo() {})];
     let name = quote_tokens!(cx, bar);
     let _toks_2 = vec![quote_item!(cx, static $name:int = 2;)];
+    let _toks_4 = quote_tokens!(cx, $name:static $name:sizeof);
     let _toks_3 = vec![quote_item!(cx,
         /// comment
         fn foo() { let $name:int = 3; }
diff --git a/src/test/run-pass-fulldeps/plugin-args-1.rs b/src/test/run-pass-fulldeps/plugin-args-1.rs
new file mode 100644 (file)
index 0000000..5a91f60
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// aux-build:plugin_args.rs
+// ignore-stage1
+
+#![feature(plugin)]
+
+#[no_link]
+#[plugin]
+extern crate plugin_args;
+
+fn main() {
+    assert_eq!(plugin_args!(), "#[plugin]");
+}
diff --git a/src/test/run-pass-fulldeps/plugin-args-2.rs b/src/test/run-pass-fulldeps/plugin-args-2.rs
new file mode 100644 (file)
index 0000000..d0ac22a
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// aux-build:plugin_args.rs
+// ignore-stage1
+
+#![feature(plugin)]
+
+#[no_link]
+#[plugin()]
+extern crate plugin_args;
+
+fn main() {
+    assert_eq!(plugin_args!(), "#[plugin()]");
+}
diff --git a/src/test/run-pass-fulldeps/plugin-args-3.rs b/src/test/run-pass-fulldeps/plugin-args-3.rs
new file mode 100644 (file)
index 0000000..7cac8ac
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// aux-build:plugin_args.rs
+// ignore-stage1
+
+#![feature(plugin)]
+
+#[no_link]
+#[plugin(hello(there), how(are="you"))]
+extern crate plugin_args;
+
+fn main() {
+    assert_eq!(plugin_args!(), "#[plugin(hello(there), how(are = \"you\"))]");
+}
diff --git a/src/test/run-pass-fulldeps/plugin-args-4.rs b/src/test/run-pass-fulldeps/plugin-args-4.rs
new file mode 100644 (file)
index 0000000..8563c8c
--- /dev/null
@@ -0,0 +1,22 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// aux-build:plugin_args.rs
+// ignore-stage1
+
+#![feature(plugin)]
+
+#[no_link]
+#[plugin="foobar"]
+extern crate plugin_args;
+
+fn main() {
+    assert_eq!(plugin_args!(), "#[plugin = \"foobar\"]");
+}
index 388a2d734473153f9b4c602bd59d99efa6cc51df..d9d11c95adbdcf9789d2f676fa9939e6882560d8 100644 (file)
@@ -19,7 +19,7 @@
 #![feature(lang_items, unboxed_closures)]
 #![no_implicit_prelude]
 
-use std::kinds::Sized;
+use std::marker::Sized;
 use std::option::Option::{None, Some, self};
 
 trait Iterator {
index abbe250b6279a17051edf12a87281d7a6d367eb0..4152321cab8139a1c26651f8309e4ab05666d23a 100644 (file)
@@ -19,7 +19,7 @@
 #![feature(lang_items, unboxed_closures)]
 #![no_implicit_prelude]
 
-use std::kinds::Sized;
+use std::marker::Sized;
 use std::option::Option::{None, Some, self};
 
 trait Iterator {
index 24df95ffd3cb6ffa810ebef96959d9ef759b5b68..9b030de998373be9b62b6b9542d8de7fbb5c4a11 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 dac8945b6e828f850352afb4f5eda3c00f9f266e..c586ff2c93ab3215bd9d20bdd87ebe3c9eceb252 100644 (file)
@@ -32,9 +32,9 @@ pub fn main() {
     add_int(&mut *ints, 44);
 
     iter_ints(&*ints, |i| {
-        println!("int = {}", *i);
+        println!("int = {:?}", *i);
         true
     });
 
-    println!("ints={}", ints);
+    println!("ints={:?}", ints);
 }
index 86d7b72f4ffd0c28c60d902df379ea62c21eccd0..9c7913dc0b0b1d69f58fbd9ab07a4f78cabb75a1 100644 (file)
@@ -51,7 +51,7 @@ fn cat(in_x : uint, in_y : int, in_name: String) -> cat {
     }
 }
 
-impl fmt::Show for cat {
+impl fmt::String for cat {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         write!(f, "{}", self.name)
     }
index 440b7afa984f796ca2d7aab32420dd6f27b1ceb8..526819940d00322f28cd68124b15969348b92276 100644 (file)
@@ -45,5 +45,5 @@ pub fn fails() {
 }
 
 pub fn main() {
-    Thread::spawn(fails).join();
+    Thread::scoped(fails).join();
 }
index e3bdbeb169295e7a8d9236af7726f6da72b95af1..b5a5f57d07abda322171f642cf19c29b7a9eec5f 100644 (file)
@@ -16,5 +16,5 @@
 
 pub fn main() {
     // only panics if println! evaluates its argument.
-    debug!("{}", { if true { panic!() } });
+    debug!("{:?}", { if true { panic!() } });
 }
index 0591828bb132b1dde473de1112095ca701eb7cf6..b335e20f91d932df7a127b37a6eca2e56c4b73f8 100644 (file)
@@ -13,7 +13,7 @@
 pub fn main() {
     // exits early if println! evaluates its arguments, otherwise it
     // will hit the panic.
-    println!("{}", { if true { return; } });
+    println!("{:?}", { if true { return; } });
 
     panic!();
 }
index 35783ea5899d55897a1a1e245b902f5439d9a430..84acd3c4ecd7ebe77d0f74d821c2e0be454d6228 100644 (file)
@@ -11,7 +11,7 @@
 #![allow(dead_code)]
 #![allow(unused_unsafe)]
 
-use std::kinds::Sync;
+use std::marker::Sync;
 
 struct Foo {
     a: uint,
index 25c1464adfaf436e6ef9a0de8c5a95cf8a916586..28b346c9ed4d0532e240902677419fa09dbd8375 100644 (file)
@@ -29,7 +29,7 @@ fn odd(x: uint) -> bool { x % 2 == 1 }
 fn dummy_rng() -> DummyRng { DummyRng::new_unseeded() }
 
 macro_rules! tests {
-    ($($expr:expr: $ty:ty /($($test:expr),*);)+) => (pub fn main() {$({
+    ($($expr:expr, $ty:ty, ($($test:expr),*);)+) => (pub fn main() {$({
         const C: $ty = $expr;
         static S: $ty = $expr;
         assert!(eq(C($($test),*), $expr($($test),*)));
@@ -40,45 +40,44 @@ macro_rules! tests {
 
 tests! {
     // Free function.
-    id: fn(int) -> int /(5);
-    id::<int>: fn(int) -> int /(5);
+    id, fn(int) -> int, (5);
+    id::<int>, fn(int) -> int, (5);
 
     // Enum variant constructor.
-    Some: fn(int) -> Option<int> /(5);
-    Some::<int>: fn(int) -> Option<int> /(5);
+    Some, fn(int) -> Option<int>, (5);
+    Some::<int>, fn(int) -> Option<int>, (5);
 
     // Tuple struct constructor.
-    Newt: fn(int) -> Newt<int> /(5);
-    Newt::<int>: fn(int) -> Newt<int> /(5);
+    Newt, fn(int) -> Newt<int>, (5);
+    Newt::<int>, fn(int) -> Newt<int>, (5);
 
     // Inherent static methods.
-    Vec::new: fn() -> Vec<()> /();
-    Vec::<()>::new: fn() -> Vec<()> /();
-    Vec::with_capacity: fn(uint) -> Vec<()> /(5);
-    Vec::<()>::with_capacity: fn(uint) -> Vec<()> /(5);
-    Bitv::from_fn: fn(uint, fn(uint) -> bool) -> Bitv /(5, odd);
-    Bitv::from_fn::<fn(uint) -> bool>: fn(uint, fn(uint) -> bool) -> Bitv /(5, odd);
+    Vec::new, fn() -> Vec<()>, ();
+    Vec::<()>::new, fn() -> Vec<()>, ();
+    Vec::with_capacity, fn(uint) -> Vec<()>, (5);
+    Vec::<()>::with_capacity, fn(uint) -> Vec<()>, (5);
+    Bitv::from_fn, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
+    Bitv::from_fn::<fn(uint) -> bool>, fn(uint, fn(uint) -> bool) -> Bitv, (5, odd);
 
     // Inherent non-static method.
-    Vec::map_in_place: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-        /(vec![b'f', b'o', b'o'], u8_as_i8);
-    Vec::map_in_place::<i8, fn(u8) -> i8>: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-        /(vec![b'f', b'o', b'o'], u8_as_i8);
+    Vec::map_in_place, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>, (vec![b'f', b'o', b'o'], u8_as_i8);
+    Vec::map_in_place::<i8, fn(u8) -> i8>, fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>,
+        (vec![b'f', b'o', b'o'], u8_as_i8);
     // FIXME these break with "type parameter might not appear here pointing at `<u8>`.
     // Vec::<u8>::map_in_place: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-    //     /(vec![b'f', b'o', b'o'], u8_as_i8);
+    //    (vec![b'f', b'o', b'o'], u8_as_i8);
     // Vec::<u8>::map_in_place::<i8, fn(u8) -> i8>: fn(Vec<u8>, fn(u8) -> i8) -> Vec<i8>
-    //     /(vec![b'f', b'o', b'o'], u8_as_i8);
+    //    (vec![b'f', b'o', b'o'], u8_as_i8);
 
     // Trait static methods.
     // FIXME qualified path expressions aka UFCS i.e. <T as Trait>::method.
-    Default::default: fn() -> int /();
-    Rand::rand: fn(&mut DummyRng) -> int /(&mut dummy_rng());
-    Rand::rand::<DummyRng>: fn(&mut DummyRng) -> int /(&mut dummy_rng());
+    Default::default, fn() -> int, ();
+    Rand::rand, fn(&mut DummyRng) -> int, (&mut dummy_rng());
+    Rand::rand::<DummyRng>, fn(&mut DummyRng) -> int, (&mut dummy_rng());
 
     // Trait non-static methods.
-    Clone::clone: fn(&int) -> int /(&5);
-    FromIterator::from_iter: fn(OptionIter<int>) -> Vec<int> /(Some(5).into_iter());
-    FromIterator::from_iter::<OptionIter<int>>: fn(OptionIter<int>) -> Vec<int>
-        /(Some(5).into_iter());
+    Clone::clone, fn(&int) -> int, (&5);
+    FromIterator::from_iter, fn(OptionIter<int>) -> Vec<int>, (Some(5).into_iter());
+    FromIterator::from_iter::<OptionIter<int>>, fn(OptionIter<int>) -> Vec<int>
+       (Some(5).into_iter());
 }
index 3298976de6ce34d8bd6f13fe8af4d629b951f1fe..eeb044e560422ba07b0c5c0df67f76ec3517e81a 100644 (file)
@@ -90,7 +90,7 @@ pub fn test_destroy_actually_kills(force: bool) {
             _ = rx2.recv() => unsafe { libc::exit(1) },
             _ = rx1.recv() => {}
         }
-    }).detach();
+    });
     match p.wait().unwrap() {
         ExitStatus(..) => panic!("expected a signal"),
         ExitSignal(..) => tx.send(()).unwrap(),
index 2466d0adf7bc305fc2ac2e0d9fdc3e9539a6c2f7..01814e8eab7909cd948c87b8935472f67d1fff35 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 d191bad10ea66a1a3db248ee22ecaa7e7cb29af1..cd79f84b7cbc31f99353b08b166c556cfea8716d 100644 (file)
@@ -15,5 +15,5 @@ struct Foo {
     }
 
     let f = Foo { foo: 10 };
-    format!("{}", f);
+    format!("{:?}", f);
 }
index 58faab7bfbe529c0b65dbd17de581387ffe7669c..8465f521e43992de43cf5845a2db206b44c10f33 100644 (file)
@@ -38,16 +38,25 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
     }
 }
 
+trait ToShow {
+    fn to_show(&self) -> String;
+}
+
+impl<T: fmt::Show> ToShow for T {
+    fn to_show(&self) -> String {
+        format!("{:?}", self)
+    }
+}
+
 pub fn main() {
-    assert_eq!(B::B1.to_string(), "B1".to_string());
-    assert_eq!(B::B2.to_string(), "B2".to_string());
-    assert_eq!(C::C1(3).to_string(), "C1(3)".to_string());
-    assert_eq!(C::C2(B::B2).to_string(), "C2(B2)".to_string());
-    assert_eq!(D::D1{ a: 2 }.to_string(), "D1 { a: 2 }".to_string());
-    assert_eq!(E.to_string(), "E".to_string());
-    assert_eq!(F(3).to_string(), "F(3)".to_string());
-    assert_eq!(G(3, 4).to_string(), "G(3, 4)".to_string());
-    assert_eq!(G(3, 4).to_string(), "G(3, 4)".to_string());
-    assert_eq!(I{ a: 2, b: 4 }.to_string(), "I { a: 2, b: 4 }".to_string());
-    assert_eq!(J(Custom).to_string(), "J(yay)".to_string());
+    assert_eq!(B::B1.to_show(), "B1".to_string());
+    assert_eq!(B::B2.to_show(), "B2".to_string());
+    assert_eq!(C::C1(3).to_show(), "C1(3i)".to_string());
+    assert_eq!(C::C2(B::B2).to_show(), "C2(B2)".to_string());
+    assert_eq!(D::D1{ a: 2 }.to_show(), "D1 { a: 2i }".to_string());
+    assert_eq!(E.to_show(), "E".to_string());
+    assert_eq!(F(3).to_show(), "F(3i)".to_string());
+    assert_eq!(G(3, 4).to_show(), "G(3i, 4i)".to_string());
+    assert_eq!(I{ a: 2, b: 4 }.to_show(), "I { a: 2i, b: 4i }".to_string());
+    assert_eq!(J(Custom).to_show(), "J(yay)".to_string());
 }
index e8086b8b7c6b20c2a988de3cd5976fa32160c03c..99c73dd94a6b6a06f71e1c969b2264812448d2ed 100644 (file)
@@ -26,15 +26,15 @@ enum Enum {
 
 macro_rules! t {
     ($x:expr, $expected:expr) => {
-        assert_eq!(format!("{}", $x), $expected.to_string())
+        assert_eq!(format!("{:?}", $x), $expected.to_string())
     }
 }
 
 pub fn main() {
     t!(Unit, "Unit");
-    t!(Tuple(1, 2), "Tuple(1, 2)");
-    t!(Struct { x: 1, y: 2 }, "Struct { x: 1, y: 2 }");
+    t!(Tuple(1, 2), "Tuple(1i, 2u)");
+    t!(Struct { x: 1, y: 2 }, "Struct { x: 1i, y: 2u }");
     t!(Enum::Nullary, "Nullary");
-    t!(Enum::Variant(1, 2), "Variant(1, 2)");
-    t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1, y: 2 }");
+    t!(Enum::Variant(1, 2), "Variant(1i, 2u)");
+    t!(Enum::StructVariant { x: 1, y: 2 }, "StructVariant { x: 1i, y: 2u }");
 }
index d1823359af1351c438d6fd425c7752aafdf13316..dfb28fc9344d9f9c09cd203efa0329ed8a40c88f 100644 (file)
@@ -30,12 +30,13 @@ impl Index<uint> for T {
     type Output = Show + 'static;
 
     fn index<'a>(&'a self, idx: &uint) -> &'a (Show + 'static) {
-        static x: uint = 42;
-        &x
+        static X: uint = 42;
+        &X as &(Show + 'static)
     }
 }
 
 fn main() {
     assert_eq!(&S[0], "hello");
-    assert_eq!(format!("{}", &T[0]).as_slice(), "42");
+    &T[0];
+    // let x = &x as &Show;
 }
index 07941eca2243ec4cb8107bdf177b8489c1c2fc5c..73559af79de0a7bd1c819e3b69ed333b9238a22e 100644 (file)
@@ -23,8 +23,8 @@ pub fn check() {
                 assert_eq!(size_of::<E>(), size_of::<$t>());
                 assert_eq!(E::V as $t, $v as $t);
                 assert_eq!(C as $t, $v as $t);
-                assert_eq!(format!("{}", E::V), "V".to_string());
-                assert_eq!(format!("{}", C), "V".to_string());
+                assert_eq!(format!("{:?}", E::V), "V".to_string());
+                assert_eq!(format!("{:?}", C), "V".to_string());
             }
         }
         $m::check();
index ce3e447350d40cb57877b5c936e647a53411ce33..c1df9d53ad440516228977777aa40b5a6a1ce1a8 100644 (file)
@@ -21,7 +21,7 @@ fn rust_dbg_call(cb: extern "C" fn(libc::uintptr_t),
 
 pub fn main() {
     unsafe {
-        Thread::spawn(move|| {
+        Thread::scoped(move|| {
             let i = &100i;
             rust_dbg_call(callback, mem::transmute(i));
         }).join();
index 14843b30e1c41a3b5a0a7ad46fa9e927e472f42c..a08cd33362f4732cf59d66ee3aea4b12e041cfae 100644 (file)
@@ -11,7 +11,7 @@
 // Issue 4691: Ensure that functional-struct-updates operates
 // correctly and moves rather than copy when appropriate.
 
-use std::kinds::marker::NoCopy as NP;
+use std::marker::NoCopy as NP;
 
 struct ncint { np: NP, v: int }
 fn ncint(v: int) -> ncint { ncint { np: NP, v: v } }
index e2297661d65c1b5907034f63502e412fe7579289..5f2ebc6cbed3e1a11300b107b74708955bcda0cf 100644 (file)
@@ -17,5 +17,5 @@ struct Foo {
 pub fn main() {
     let a = Foo { x: 1, y: 2 };
     let c = Foo { x: 4, .. a};
-    println!("{}", c);
+    println!("{:?}", c);
 }
index 3bcce5388715d6e34df5117549980565e4d765ef..f83698edc90526d1cd236410d9ed1f726f3b9a30 100644 (file)
@@ -1,4 +1,3 @@
-
 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
 // file at the top-level directory of this distribution and at
 // http://rust-lang.org/COPYRIGHT.
@@ -37,7 +36,7 @@ fn start_mappers(ctrl: Sender<ctrl_proto>, inputs: Vec<String>) {
         for i in inputs.iter() {
             let ctrl = ctrl.clone();
             let i = i.clone();
-            Thread::spawn(move|| map_task(ctrl.clone(), i.clone()) ).detach();
+            Thread::spawn(move|| map_task(ctrl.clone(), i.clone()) );
         }
     }
 
index 0616a7b21b546d94af2217a355fc896d593b2fb7..8eaf8427bfdec9bbc680ccd0d187c60928d3dab3 100644 (file)
@@ -18,7 +18,7 @@
 
 #![allow(dead_code)]
 
-use std::kinds::marker;
+use std::marker;
 
 #[derive(Copy)]
 struct Foo<T> { x: T }
index fbaeb1753f41de6436f2c376b6b401c9672e38b0..23970af957655f88019c3e924409535f93c936eb 100644 (file)
@@ -10,6 +10,7 @@
 
 // A test of the macro system. Can we do HTML literals?
 
+// ignore-test FIXME #20673
 
 /*
 
index d38b0ea27476569f1f8ac0df6e1cb7776c03e3cb..8b0d7c18fb119b6359ee2210fe2747f293985ef3 100644 (file)
@@ -30,7 +30,7 @@ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.write_str("adios")
     }
 }
-impl fmt::Show for C {
+impl fmt::String for C {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         f.pad_integral(true, "☃", "123")
     }
@@ -58,9 +58,12 @@ pub fn main() {
     t!(format!("{}", true), "true");
     t!(format!("{}", '☃'), "☃");
     t!(format!("{}", 10i), "10");
-    t!(format!("{}", 10i), "10");
     t!(format!("{}", 10u), "10");
-    t!(format!("{:?}", true), "true");
+    t!(format!("{:?}", '☃'), "'\\u{2603}'");
+    t!(format!("{:?}", 10i), "10i");
+    t!(format!("{:?}", 10u), "10u");
+    t!(format!("{:?}", "true"), "\"true\"");
+    t!(format!("{:?}", "foo\nbar"), "\"foo\\nbar\"");
     t!(format!("{:o}", 10u), "12");
     t!(format!("{:x}", 10u), "a");
     t!(format!("{:X}", 10u), "A");
@@ -79,8 +82,10 @@ pub fn main() {
     t!(format!("{}", 5i + 5i), "10");
     t!(format!("{:#4}", C), "☃123");
 
-    let a: &fmt::Show = &1i;
-    t!(format!("{}", a), "1");
+    // FIXME(#20676)
+    // let a: &fmt::Show = &1i;
+    // t!(format!("{:?}", a), "1i");
+
 
     // Formatting strings and their arguments
     t!(format!("{}", "a"), "a");
index ea311e6e32c65ede88046e07e1a20c33984aedc4..308783f0d4b596f634df56349788f03c2ac7e883 100644 (file)
@@ -15,7 +15,7 @@ enum Foo<'s> {
 
 fn f(arr: &[&Foo]) {
     for &f in arr.iter() {
-        println!("{}", f);
+        println!("{:?}", f);
     }
 }
 
index 8a6e300bd15b6b2c9c0102f991790c4ecdccc463..b06799444f4c797ed6fe603d09774d22c922fa48 100644 (file)
@@ -30,5 +30,5 @@ pub fn main () {
 
     let mut p = process::Command::new(args[0].as_slice());
     p.arg("child").stdout(process::Ignored).stderr(process::Ignored);
-    println!("{}", p.spawn().unwrap().wait());
+    println!("{:?}", p.spawn().unwrap().wait());
 }
index f08805fe49c2c9c7ae74e3e3db39f7de49cccb68..6fb2c532e0c0b1f48300f3d3740138c80e6092da 100644 (file)
@@ -20,7 +20,7 @@ fn next(&mut self) -> Option<int> { None }
 }
 
 fn do_something_with(a : &mut T<int>) {
-    println!("{}", a.next())
+    println!("{:?}", a.next())
 }
 
 pub fn main() {
index 856fbbd00b20b2ef6112a7bf30f0c9fd8fd2337d..a6a4d21e8f2c04aefe297e38c100ed31e987ef9a 100644 (file)
@@ -12,7 +12,7 @@
 use std::thread::Thread;
 
 fn main() {
-    Thread::spawn(move|| customtask()).join().ok().unwrap();
+    Thread::scoped(move|| customtask()).join().ok().unwrap();
 }
 
 fn customtask() {
index 1182cf5b29f85da0be6b7ab369145833d7e3b206..a91dbd2b716b66da21ed7593a8c593a7e0d2ddb7 100644 (file)
@@ -10,5 +10,5 @@
 
 fn main() {
     fn test() -> Box<std::any::Any + 'static> { box 1i }
-    println!("{}", test())
+    println!("{:?}", test())
 }
index e5fd17e2dfed0017791c9b0c81276c79fbd2c4c1..35e487539fab98a050cbdf72d3cfefffd72bddee 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 b9339c1cc0d03ad030a746487036669e53b173bb..bef0ff5fc2cd2551c94124bc44696c44e61d7140 100644 (file)
@@ -22,7 +22,7 @@ fn helper(rx: Receiver<Sender<()>>) {
 
 fn main() {
     let (tx, rx) = channel();
-    let _t = Thread::spawn(move|| { helper(rx) }).detach();
+    let _t = Thread::spawn(move|| { helper(rx) });
     let (snd, rcv) = channel::<int>();
     for _ in range(1i, 100000i) {
         snd.send(1i).unwrap();
index a1a5922e15003bad5bf69793fe076a28956ab7e4..4e1aa454a881db717a5dfcd9101ebd95de8564aa 100644 (file)
@@ -12,5 +12,5 @@
 
 fn main() {
     let mut array = [1, 2, 3];
-    let pie_slice = array[1..2];
+    let pie_slice = &array[1..2];
 }
index b2b819a110305ec5265ebd396afab5ee8014b5f2..6b03a499f15773728e54d603a344f929bfa4d8d5 100644 (file)
@@ -20,7 +20,7 @@ fn main() {
     // Check that both closures are capturing by value
     assert_eq!(1, mem::size_of_val(&closure));
 
-    Thread::spawn(move|| {
+    Thread::scoped(move|| {
         let ok = closure;
     }).join().ok().unwrap();
 }
index 99758f9f777d6511e8b837a533b8478d60243642..e25b3e8e89c6c16175ce85e79f0d1807f1d3c6fb 100644 (file)
@@ -24,5 +24,5 @@ pub fn main() {
     let mut stdin = std::io::stdin();
     Thread::spawn(move|| {
         let _ = stdin.read_to_end();
-    }).detach();
+    });
 }
index e69738d4caab979fea1ba4954cd0c0b7f92b2243..40e112d6fbf7637ab56636048881c872456cb5de 100644 (file)
@@ -15,5 +15,5 @@
 pub fn main() {
     let mut m = HashMap::new();
     m.insert(b"foo".to_vec(), b"bar".to_vec());
-    println!("{}", m);
+    println!("{:?}", m);
 }
index 986879e8e461d1af4bb9d81e2033eff1e928d2b8..8acda1750069257f80cb09360568b269d451f7c2 100644 (file)
@@ -15,7 +15,7 @@ fn main() {
     let ss: &&[int] = &s;
     let sss: &&&[int] = &ss;
 
-    println!("{}", s[..3]);
-    println!("{}", ss[3..]);
-    println!("{}", sss[2..4]);
+    println!("{}", &s[0..3]);
+    println!("{}", &ss[3..]);
+    println!("{}", &sss[2..4]);
 }
index 0851f0e367bf85ce977ae5685d593e6d217a17da..cdd03244df14567d8e4b12db36f191c59b366686 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-use std::kinds::marker;
+use std::marker;
 use std::cell::UnsafeCell;
 
 struct MyUnsafePack<T>(UnsafeCell<T>);
index b9d0a9a2988f4b50790de346992e959e26523281..c90880ff120bbcaef7558d7633359cba19774c1c 100644 (file)
@@ -14,7 +14,7 @@
 struct LifetimeStruct<'a>;
 
 fn main() {
-    takes_hrtb_closure(|&mut: lts| println!("{}", lts));
+    takes_hrtb_closure(|&mut: lts| println!("{:?}", lts));
 }
 
 fn takes_hrtb_closure<F: for<'a>FnMut(LifetimeStruct<'a>)>(mut f: F) {
index 86687fccd61fce377458c7979b75c71ba1108bf5..360934821750dd8a83044d3193334dfac15658d3 100644 (file)
@@ -25,5 +25,5 @@ impl Trait for int {}
 fn main() {
     let a = Foo { foo: 12i };
     let b = Bar { bar: 12i };
-    println!("{} {}", a, b);
+    println!("{:?} {:?}", a, b);
 }
diff --git a/src/test/run-pass/issue-20644.rs b/src/test/run-pass/issue-20644.rs
new file mode 100644 (file)
index 0000000..4a57ed5
--- /dev/null
@@ -0,0 +1,35 @@
+// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <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.
+
+// A reduced version of the rustbook ice. The problem this encountered
+// had to do with trans ignoring binders.
+
+#![feature(slicing_syntax)]
+#![feature(associated_types)]
+#![feature(macro_rules)]
+
+use std::iter;
+use std::os;
+use std::io::File;
+
+#[allow(unused)]
+pub fn parse_summary<R: Reader>(_: R, _: &Path) {
+     let path_from_root = Path::new("");
+     Path::new(iter::repeat("../")
+               .take(path_from_root.components().count() - 1)
+               .collect::<String>());
+ }
+
+fn main() {
+    let cwd = os::getcwd().unwrap();
+    let src = cwd.clone();
+    let summary = File::open(&src.join("SUMMARY.md"));
+    let _ = parse_summary(summary, &src);
+}
index 4bbbe978192b13f2e85ab112f2a69e9129acb40e..810bf385d7e0b0946d1c05921155a6fbc53d922d 100644 (file)
@@ -14,7 +14,7 @@
 static generations: uint = 1024+256+128+49;
 
 fn spawn(f: Thunk) {
-    Builder::new().stack_size(32 * 1024).spawn(move|| f.invoke(())).detach()
+    Builder::new().stack_size(32 * 1024).spawn(move|| f.invoke(()));
 }
 
 fn child_no(x: uint) -> Thunk {
index f414606340924b82c3b87b0ae8efefce2711230a..3ca3e0592e7896e64b0ebcd2c6a829e958e0bd28 100644 (file)
@@ -23,7 +23,7 @@ pub mod pipes {
     use std::mem::{replace, swap};
     use std::mem;
     use std::thread::Thread;
-    use std::kinds::Send;
+    use std::marker::Send;
 
     pub struct Stuff<T> {
         state: state,
index 86913c0e8d4fd4b3938bf8f54d8ec7f52530dbe9..dc22ebce804e643d6fea7c1482c61dadb5acb820 100644 (file)
@@ -9,5 +9,5 @@
 // except according to those terms.
 
 pub fn main() {
-    println!("{}", ("hi there!", "you"));
+    println!("{:?}", ("hi there!", "you"));
 }
index e004c24da136886aad88a57c9b9af760db6b1aa4..3448273e14424709c730969cdda7d38857757276 100644 (file)
@@ -43,6 +43,6 @@ pub fn main()
                     "foo".to_string(),
                     "foo".to_string(), "foo".to_string(), "foo".to_string(),
                     "foo".to_string());
-    let v = format!("{}", u);    // this is the line that causes the seg fault
+    let v = format!("{:?}", u);    // this is the line that causes the seg fault
     assert!(v.len() > 0);
 }
index 2568d94fcbf9e4f14d62ae0b00bdcb228e0040e2..633832f424c858757cbb93c5eadbe0123fd263fd 100644 (file)
@@ -24,6 +24,6 @@ pub fn main() {
     let mut table = HashMap::new();
     table.insert("one".to_string(), 1i);
     table.insert("two".to_string(), 2i);
-    assert!(check_strs(table.to_string().as_slice(), "{one: 1, two: 2}") ||
-            check_strs(table.to_string().as_slice(), "{two: 2, one: 1}"));
+    assert!(check_strs(format!("{:?}", table).as_slice(), "HashMap {\"one\": 1i, \"two\": 2i}") ||
+            check_strs(format!("{:?}", table).as_slice(), "HashMap {\"two\": 2i, \"one\": 1i}"));
 }
index a3903128b65397b871e649341aeb8387e0080d24..3fe6e02dcefba1f39750156f9bf1045b25029164 100644 (file)
@@ -104,7 +104,7 @@ fn add_pt(&mut self, x: int, y: int) {
 
 // Allows AsciiArt to be converted to a string using the libcore ToString trait.
 // Note that the %s fmt! specifier will not call this automatically.
-impl fmt::Show for AsciiArt {
+impl fmt::String for AsciiArt {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
         // Convert each line into a string.
         let lines = self.lines.iter()
index 43852fb33240090ddadb1314559108aa80ad0d64..382ea0c575887cc9ddc72ebcd47072eec8210159 100644 (file)
@@ -30,17 +30,23 @@ fn vmul(self, other: f64) -> Vec2 {
 }
 
 // Right-hand-side operator visitor pattern
-trait RhsOfVec2Mul<Result> { fn mul_vec2_by(&self, lhs: &Vec2) -> Result; }
+trait RhsOfVec2Mul {
+    type Result;
+
+    fn mul_vec2_by(&self, lhs: &Vec2) -> Self::Result;
+}
 
 // Vec2's implementation of Mul "from the other side" using the above trait
-impl<Res, Rhs: RhsOfVec2Mul<Res>> Mul<Rhs> for Vec2 {
+impl<Res, Rhs: RhsOfVec2Mul<Result=Res>> Mul<Rhs> for Vec2 {
     type Output = Res;
 
     fn mul(self, rhs: Rhs) -> Res { rhs.mul_vec2_by(&self) }
 }
 
 // Implementation of 'f64 as right-hand-side of Vec2::Mul'
-impl RhsOfVec2Mul<Vec2> for f64 {
+impl RhsOfVec2Mul for f64 {
+    type Result = Vec2;
+
     fn mul_vec2_by(&self, lhs: &Vec2) -> Vec2 { lhs.vmul(*self) }
 }
 
index 4508bc5771cbdcf91764e5147a28abe7467555dd..926b53cf92c0d1bc2ded84dc93d61c9b1c544874 100644 (file)
@@ -19,7 +19,7 @@ struct S {
 
 impl T for S {
     fn print(&self) {
-        println!("{}", self);
+        println!("{:?}", self);
     }
 }
 
index 10add853ee7f3bc2fcf8513dab64415dd05da36f..5ed9729c1425861cf9ed4a4530ef5932c1e59fe7 100644 (file)
@@ -11,7 +11,7 @@
 #![feature(slicing_syntax)]
 
 fn vec_peek<'r, T>(v: &'r [T]) -> &'r [T] {
-    v[1..5]
+    &v[1..5]
 }
 
 pub fn main() {}
index 6ed35e6bc232f2611d8a5a8e91a4e8c1cc3e65d4..3606aff05ff5e0805747f77dfdb7d61fcd40c2ba 100644 (file)
@@ -13,7 +13,7 @@
 trait X {
     fn call<T: std::fmt::Show>(&self, x: &T);
     fn default_method<T: std::fmt::Show>(&self, x: &T) {
-        println!("X::default_method {}", x);
+        println!("X::default_method {:?}", x);
     }
 }
 
@@ -27,7 +27,7 @@ struct Z<T> {
 
 impl X for Y {
     fn call<T: std::fmt::Show>(&self, x: &T) {
-        println!("X::call {} {}", self, x);
+        println!("X::call {:?} {:?}", self, x);
     }
 }
 
index 30e1a14ecff8fc776f44862abb78e940be73911c..9c00348ad6a5155814859b31da8af2208a3383bc 100644 (file)
@@ -17,7 +17,7 @@ pub fn main() {
 
     tx.send("hello, world").unwrap();
 
-    Thread::spawn(move|| {
+    Thread::scoped(move|| {
         println(rx.recv().unwrap());
     }).join().ok().unwrap();
 }
index 7e53722726f2cef8d53b748ccd69ee0fb0085c60..a19bfca721a7c2318dc705a183551300c2e808dc 100644 (file)
@@ -14,7 +14,7 @@
 pub fn main() {
     let (tx, rx) = channel::<&'static str>();
 
-    let t = Thread::spawn(move|| {
+    let t = Thread::scoped(move|| {
         assert_eq!(rx.recv().unwrap(), "hello, world");
     });
 
index f2c1a715b514b959ed238dea4c5d4519165a064d..2581069d29b05c0b399b53530d579b987aeab2f3 100644 (file)
@@ -10,6 +10,6 @@
 
 #![feature(slicing_syntax)]
 
-fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { v[i..j] }
+fn broken(v: &[u8], i: uint, j: uint) -> &[u8] { &v[i..j] }
 
 pub fn main() {}
index 4d217fbf3351e976086f9531e5fb4c73b270d82c..734d131ffdff002b223262c7c14b6da42a85b977 100644 (file)
@@ -31,6 +31,6 @@ pub fn main() {
     let sa = A { a: 100 };
     let sb = B { b: 200, pa: &sa };
 
-    println!("sa is {}", sa);
-    println!("sb is {}", sb);
+    println!("sa is {:?}", sa);
+    println!("sb is {:?}", sb);
 }
index 3d5e32972e7247ef548c3b2e90e350faec1a7336..3ea6d5d4f2fcbeefb2ed53e6a985460fe778ddb0 100644 (file)
 use std::thread::Thread;
 
 fn main() {
-    assert!(Thread::spawn(move|| int::MIN / -1).join().is_err());
-    assert!(Thread::spawn(move|| i8::MIN / -1).join().is_err());
-    assert!(Thread::spawn(move|| i16::MIN / -1).join().is_err());
-    assert!(Thread::spawn(move|| i32::MIN / -1).join().is_err());
-    assert!(Thread::spawn(move|| i64::MIN / -1).join().is_err());
-    assert!(Thread::spawn(move|| 1i / 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i8 / 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i16 / 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i32 / 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i64 / 0).join().is_err());
-    assert!(Thread::spawn(move|| int::MIN % -1).join().is_err());
-    assert!(Thread::spawn(move|| i8::MIN % -1).join().is_err());
-    assert!(Thread::spawn(move|| i16::MIN % -1).join().is_err());
-    assert!(Thread::spawn(move|| i32::MIN % -1).join().is_err());
-    assert!(Thread::spawn(move|| i64::MIN % -1).join().is_err());
-    assert!(Thread::spawn(move|| 1i % 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i8 % 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i16 % 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i32 % 0).join().is_err());
-    assert!(Thread::spawn(move|| 1i64 % 0).join().is_err());
+    assert!(Thread::scoped(move|| int::MIN / -1).join().is_err());
+    assert!(Thread::scoped(move|| i8::MIN / -1).join().is_err());
+    assert!(Thread::scoped(move|| i16::MIN / -1).join().is_err());
+    assert!(Thread::scoped(move|| i32::MIN / -1).join().is_err());
+    assert!(Thread::scoped(move|| i64::MIN / -1).join().is_err());
+    assert!(Thread::scoped(move|| 1i / 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i8 / 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i16 / 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i32 / 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i64 / 0).join().is_err());
+    assert!(Thread::scoped(move|| int::MIN % -1).join().is_err());
+    assert!(Thread::scoped(move|| i8::MIN % -1).join().is_err());
+    assert!(Thread::scoped(move|| i16::MIN % -1).join().is_err());
+    assert!(Thread::scoped(move|| i32::MIN % -1).join().is_err());
+    assert!(Thread::scoped(move|| i64::MIN % -1).join().is_err());
+    assert!(Thread::scoped(move|| 1i % 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i8 % 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i16 % 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i32 % 0).join().is_err());
+    assert!(Thread::scoped(move|| 1i64 % 0).join().is_err());
 }
index 39695a8339f08aa0017ff4baa150b8df4380b68d..d8b7490124f7055a2b1f08d89599cf1bfa081c74 100644 (file)
@@ -26,7 +26,7 @@ fn periodical(n: int) -> Receiver<bool> {
                 Err(..) => break
             }
         }
-    }).detach();
+    });
     return port;
 }
 
@@ -41,7 +41,7 @@ fn integers() -> Receiver<int> {
             }
             i = i + 1;
         }
-    }).detach();
+    });
     return port;
 }
 
@@ -58,4 +58,3 @@ fn main() {
         }
     }
 }
-
index 305f984f98efbffac47982b6bbeb15052de1754d..0ca63d52bd849f224066ce63e163e4bc70b388e0 100644 (file)
 #![feature(slicing_syntax)]
 
 fn assert_repr_eq<T: std::fmt::Show>(obj : T, expected : String) {
-    assert_eq!(expected, format!("{}", obj));
+    assert_eq!(expected, format!("{:?}", obj));
 }
 
 pub fn main() {
     let abc = [1i, 2, 3];
     let tf = [true, false];
     let x  = [(), ()];
-    let slice = x[0..1];
+    let slice = &x[0..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[], "[1i, 2i, 3i]".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 bffa86a2c62e85914ab4e90bf82f83fff8a6d0b5..7fb2390b84b701df5bd5b713dba811a12610675c 100644 (file)
@@ -15,19 +15,19 @@ enum foo {
 }
 
 fn check_log<T: std::fmt::Show>(exp: String, v: T) {
-    assert_eq!(exp, format!("{}", v));
+    assert_eq!(exp, format!("{:?}", v));
 }
 
 pub fn main() {
     let mut x = Some(foo::a(22u));
-    let exp = "Some(a(22))".to_string();
-    let act = format!("{}", x);
+    let exp = "Some(a(22u))".to_string();
+    let act = format!("{:?}", x);
     assert_eq!(act, exp);
     check_log(exp, x);
 
     x = None;
     let exp = "None".to_string();
-    let act = format!("{}", x);
+    let act = format!("{:?}", x);
     assert_eq!(act, exp);
     check_log(exp, x);
 }
index e40723ab1b6316098a79ca377fa1da1e8d8ad5a8..45fd2098dc42e8b91b49709f5c25cb0241fbe667 100644 (file)
@@ -21,7 +21,7 @@ enum bar {
 }
 
 pub fn main() {
-    assert_eq!("a(22)".to_string(), format!("{}", foo::a(22u)));
-    assert_eq!("c".to_string(), format!("{}", foo::c));
-    assert_eq!("d".to_string(), format!("{}", bar::d));
+    assert_eq!("a(22u)".to_string(), format!("{:?}", foo::a(22u)));
+    assert_eq!("c".to_string(), format!("{:?}", foo::c));
+    assert_eq!("d".to_string(), format!("{:?}", bar::d));
 }
index 163efcb1a2ba6cc28a13715be790f57a56b1621b..a6a99d6fc92a73e247d99b2b0655ded4c3998a56 100644 (file)
@@ -14,8 +14,8 @@ enum Numbers {
 }
 
 pub fn main() {
-    println!("{}", 1i);
-    println!("{}", 2.0f64);
-    println!("{}", Numbers::Three);
-    println!("{}", vec!(4i));
+    println!("{:?}", 1i);
+    println!("{:?}", 2.0f64);
+    println!("{:?}", Numbers::Three);
+    println!("{:?}", vec!(4i));
 }
index 509afff3d133bb204744467e0c64cadcbbf08675..a72cfad2cb88ee27682d2506b93f848ddabd1174 100644 (file)
@@ -27,9 +27,9 @@ fn fmt(&self, _fmt: &mut fmt::Formatter) -> fmt::Result {
 }
 
 pub fn main() {
-    Thread::spawn(move|| {
+    Thread::scoped(move|| {
         let mut f = Foo(Cell::new(0));
-        println!("{}", f);
+        println!("{:?}", f);
         let Foo(ref mut f) = f;
         assert!(f.get() == 1);
     }).join().ok().unwrap();
index 93bb9557604c49cd9d4e61fa1373b74edd7485bf..cb52ba74bbd683088d2c1807cc72bb8c253766ac 100644 (file)
@@ -14,7 +14,7 @@ macro_rules! expr { ($e: expr) => { $e } }
 
 macro_rules! spawn {
     ($($code: tt)*) => {
-        expr!(Thread::spawn(move|| {$($code)*}).detach())
+        expr!(Thread::spawn(move|| {$($code)*}))
     }
 }
 
index e81244d4beabc20c1b9a1269db02b6c97b367180..338bd89ab5cb1e55e833fe478a790b04d849b382 100644 (file)
@@ -13,7 +13,7 @@
 // know not to stop at the blanket, we have to recursively evaluate
 // the `T:Foo` bound.
 
-use std::kinds::Sized;
+use std::marker::Sized;
 
 // Note: this must be generic for the problem to show up
 trait Foo<A> {
index 8532b5f51dc5e68ebe94cb66623b9b532647e52c..84d2083cedd71532fd7c19bb90ef51b5a012cb21 100644 (file)
@@ -17,7 +17,7 @@ struct Thingy {
 
 impl fmt::Show for Thingy {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{{ x: {}, y: {} }}", self.x, self.y)
+        write!(f, "{{ x: {:?}, y: {:?} }}", self.x, self.y)
     }
 }
 
@@ -27,11 +27,11 @@ struct PolymorphicThingy<T> {
 
 impl<T:fmt::Show> fmt::Show for PolymorphicThingy<T> {
     fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
-        write!(f, "{}", self.x)
+        write!(f, "{:?}", self.x)
     }
 }
 
 pub fn main() {
-    println!("{}", Thingy { x: 1, y: 2 }.to_string());
-    println!("{}", PolymorphicThingy { x: Thingy { x: 1, y: 2 } }.to_string());
+    println!("{:?}", Thingy { x: 1, y: 2 });
+    println!("{:?}", PolymorphicThingy { x: Thingy { x: 1, y: 2 } });
 }
index 6b1553cd9f600d924efa784fde15fb7ec8196f8d..64e78c3483bbae41d35503df04db32a339f9de5c 100644 (file)
@@ -23,7 +23,7 @@ fn drop(&mut self) {
 }
 
 fn main() {
-    Thread::spawn(move|| -> () {
+    Thread::scoped(move|| -> () {
         let _a = A;
         panic!();
     }).join().unwrap_err();
index 9b9a7f68995f7e90456ef1753fd93190d652a07d..0293c4e36ac59c09f89f47ba8c92d51e1e0a74e1 100644 (file)
@@ -35,10 +35,10 @@ fn get_ref(&self) -> (int, &T) {
 }
 
 macro_rules! check_option {
-    ($e:expr: $T:ty) => {{
-        check_option!($e: $T, |ptr| assert!(*ptr == $e));
+    ($e:expr, $T:ty) => {{
+        check_option!($e, $T, |ptr| assert!(*ptr == $e));
     }};
-    ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
+    ($e:expr, $T:ty, |$v:ident| $chk:expr) => {{
         assert!(option::Option::None::<$T>.is_none());
         let e = $e;
         let s_ = option::Option::Some::<$T>(e);
@@ -48,10 +48,10 @@ macro_rules! check_option {
 }
 
 macro_rules! check_fancy {
-    ($e:expr: $T:ty) => {{
-        check_fancy!($e: $T, |ptr| assert!(*ptr == $e));
+    ($e:expr, $T:ty) => {{
+        check_fancy!($e, $T, |ptr| assert!(*ptr == $e));
     }};
-    ($e:expr: $T:ty, |$v:ident| $chk:expr) => {{
+    ($e:expr, $T:ty, |$v:ident| $chk:expr) => {{
         assert!(E::Nothing::<$T>((), ((), ()), [23i8; 0]).is_none());
         let e = $e;
         let t_ = E::Thing::<$T>(23, e);
@@ -71,12 +71,12 @@ macro_rules! check_type {
 }
 
 pub fn main() {
-    check_type!(&17: &int);
-    check_type!(box 18: Box<int>);
-    check_type!("foo".to_string(): String);
-    check_type!(vec!(20, 22): Vec<int> );
+    check_type!(&17, &int);
+    check_type!(box 18, Box<int>);
+    check_type!("foo".to_string(), String);
+    check_type!(vec!(20, 22), Vec<int> );
     let mint: uint = unsafe { mem::transmute(main) };
-    check_type!(main: fn(), |pthing| {
+    check_type!(main, fn(), |pthing| {
         assert!(mint == unsafe { mem::transmute(*pthing) })
     });
 }
index 7aac2d705a854d293ec1ed4da203ea3df5bab79b..ce6604df49b4497fccd25020f92854e48574dca4 100644 (file)
@@ -37,11 +37,13 @@ fn main() {
     let args = os::args();
     let args = args.as_slice();
     if args.len() > 1 && args[1].as_slice() == "recurse" {
-        let _t = Thread::spawn(recurse);
+        let _t = Thread::scoped(recurse);
     } else {
         let recurse = Command::new(args[0].as_slice()).arg("recurse").output().unwrap();
         assert!(!recurse.status.success());
         let error = String::from_utf8_lossy(recurse.error.as_slice());
+        println!("wut");
+        println!("`{}`", error);
         assert!(error.as_slice().contains("has overflowed its stack"));
     }
 }
index aac0b5e06d004fde8c98838ea36752d4425d4155..2e044227eb135b90141acdd0b8fe405c1fd171ad 100644 (file)
@@ -37,7 +37,7 @@ fn index<'a>(&'a self, index: &K) -> &'a V {
                 return &pair.value
             }
         }
-        panic!("No value found for key: {}", index);
+        panic!("No value found for key: {:?}", index);
     }
 }
 
index 5c692bf8801815ba5d38c406becc663e77bb5df5..3cc01b967ce6af5d452cc6edad560502e25d7372 100644 (file)
@@ -33,10 +33,9 @@ fn drop(&mut self) {
 }
 
 pub fn main() {
-    let ret = Thread::spawn(move|| {
+    let ret = Thread::scoped(move|| {
         let _a = A { b: B { foo: 3 } };
     }).join();
     assert!(ret.is_err());
     unsafe { assert!(dropped); }
 }
-
diff --git a/src/test/run-pass/plugin-args-1.rs b/src/test/run-pass/plugin-args-1.rs
deleted file mode 100644 (file)
index 5a91f60..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// aux-build:plugin_args.rs
-// ignore-stage1
-
-#![feature(plugin)]
-
-#[no_link]
-#[plugin]
-extern crate plugin_args;
-
-fn main() {
-    assert_eq!(plugin_args!(), "#[plugin]");
-}
diff --git a/src/test/run-pass/plugin-args-2.rs b/src/test/run-pass/plugin-args-2.rs
deleted file mode 100644 (file)
index d0ac22a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// aux-build:plugin_args.rs
-// ignore-stage1
-
-#![feature(plugin)]
-
-#[no_link]
-#[plugin()]
-extern crate plugin_args;
-
-fn main() {
-    assert_eq!(plugin_args!(), "#[plugin()]");
-}
diff --git a/src/test/run-pass/plugin-args-3.rs b/src/test/run-pass/plugin-args-3.rs
deleted file mode 100644 (file)
index 7cac8ac..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// aux-build:plugin_args.rs
-// ignore-stage1
-
-#![feature(plugin)]
-
-#[no_link]
-#[plugin(hello(there), how(are="you"))]
-extern crate plugin_args;
-
-fn main() {
-    assert_eq!(plugin_args!(), "#[plugin(hello(there), how(are = \"you\"))]");
-}
diff --git a/src/test/run-pass/plugin-args-4.rs b/src/test/run-pass/plugin-args-4.rs
deleted file mode 100644 (file)
index 8563c8c..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-// aux-build:plugin_args.rs
-// ignore-stage1
-
-#![feature(plugin)]
-
-#[no_link]
-#[plugin="foobar"]
-extern crate plugin_args;
-
-fn main() {
-    assert_eq!(plugin_args!(), "#[plugin = \"foobar\"]");
-}
index e165b34f680ba70d42723ff292d957dc494b389b..5b91d5e930f9bef1b0afb4b7888476b8a386a36b 100644 (file)
@@ -53,11 +53,11 @@ pub fn main() {
         let x = Outer {c8: 22u8, t: Inner {c64: 44u32}};
 
         // Send it through the shape code
-        let y = format!("{}", x);
+        let y = format!("{:?}", x);
 
-        println!("align inner = {}", rusti::min_align_of::<Inner>());
-        println!("size outer = {}", mem::size_of::<Outer>());
-        println!("y = {}", y);
+        println!("align inner = {:?}", rusti::min_align_of::<Inner>());
+        println!("size outer = {:?}", mem::size_of::<Outer>());
+        println!("y = {:?}", y);
 
         // per clang/gcc the alignment of `inner` is 4 on x86.
         assert_eq!(rusti::min_align_of::<Inner>(), m::align());
@@ -66,6 +66,6 @@ pub fn main() {
         // because `inner`s alignment was 4.
         assert_eq!(mem::size_of::<Outer>(), m::size());
 
-        assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());
+        assert_eq!(y, "Outer { c8: 22u8, t: Inner { c64: 44u32 } }".to_string());
     }
 }
index c3cec77a646585372b792f3a1587df12ce02a491..27941542d000e532366c6d601b01b804fd68a651 100644 (file)
@@ -82,11 +82,11 @@ pub fn main() {
     unsafe {
         let x = Outer {c8: 22u8, t: Inner {c64: 44u64}};
 
-        let y = format!("{}", x);
+        let y = format!("{:?}", x);
 
-        println!("align inner = {}", rusti::min_align_of::<Inner>());
-        println!("size outer = {}", mem::size_of::<Outer>());
-        println!("y = {}", y);
+        println!("align inner = {:?}", rusti::min_align_of::<Inner>());
+        println!("size outer = {:?}", mem::size_of::<Outer>());
+        println!("y = {:?}", y);
 
         // per clang/gcc the alignment of `Inner` is 4 on x86.
         assert_eq!(rusti::min_align_of::<Inner>(), m::m::align());
@@ -95,6 +95,6 @@ pub fn main() {
         // because `Inner`s alignment was 4.
         assert_eq!(mem::size_of::<Outer>(), m::m::size());
 
-        assert_eq!(y, "Outer { c8: 22, t: Inner { c64: 44 } }".to_string());
+        assert_eq!(y, "Outer { c8: 22u8, t: Inner { c64: 44u64 } }".to_string());
     }
 }
index 8b9d6af1017b5ca4d122586ec03ba07cc2b5bc5d..a3288e2e1b90b1a80b2633cfa686095634720caf 100644 (file)
@@ -11,7 +11,7 @@
 // Test that a type whose lifetime parameters is never used is
 // inferred to be bivariant.
 
-use std::kinds::marker;
+use std::marker;
 
 struct Bivariant<'a>;
 
index 0781822cb748203ac502305255d04a561904d0cd..e854a7326329c8d6d0e977230224b3dc9285f578 100644 (file)
@@ -16,8 +16,8 @@ pub fn main() {
 
     print!("[");
     for xi in x.iter() {
-        print!("{}, ", (*xi)[]);
+        print!("{}, ", &xi[]);
     }
     println!("]");
-    println!("{}", y[]);
+    println!("{}", &y[]);
 }
index a67b24f8b1e3f8e827fafffd2496dfa563159909..57f72b23adfa3e74b3cf38c9283b1d096e7d4bce 100644 (file)
@@ -37,7 +37,7 @@ pub fn main() {
         let a = r(i);
         let b = (a, 10i);
         let (c, _d) = b;
-        println!("{}", c);
+        println!("{:?}", c);
     }
     assert_eq!(i.get(), 1);
 }
index 6f807fc34995eaae94270d5318b3abe647788454..d6c25672cdbbc720ca1a68ca9cb917ab0c915711 100644 (file)
@@ -57,7 +57,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.as_slice()));
+        println!("{:?}", str::from_utf8(output.error.as_slice()));
     }
 }
index 3ed835dc5bdf9d6907442b65ce701df61c0a448c..a6e4716c3b8a36e0294654b42b24e66c3a7386b6 100644 (file)
@@ -22,7 +22,7 @@ fn test05() {
         println!("{}", *three + n); // will copy x into the closure
         assert_eq!(*three, 3);
     };
-    Thread::spawn(move|| {
+    Thread::scoped(move|| {
         test05_start(fn_to_send);
     }).join().ok().unwrap();
 }
index 246957a4f46087d62f440207ed06869e9f787af2..b8bb3b4e7f8c39dd70eff3464308cf3b9d43b6db 100644 (file)
@@ -36,5 +36,5 @@ pub fn g() {
 }
 
 fn main() {
-    Thread::spawn(move|| { ::b::g() }).join().unwrap_err();
+    Thread::scoped(move|| { ::b::g() }).join().unwrap_err();
 }
index 2273c399c9a52f28487eca494455d22c84583958..e0d005a485bc0c15cdff2983fbf3b5146798b8cb 100644 (file)
@@ -12,5 +12,5 @@
 struct Foo(Box<[u8]>);
 
 pub fn main() {
-    println!("{}", Foo(box [0, 1, 2]));
+    println!("{:?}", Foo(box [0, 1, 2]));
 }
index f03b4609637a9998424060b9f9a8992bdc44bdcc..05f318b53c2e543404988c2c536e40751601d4ed 100644 (file)
 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);
+    assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
-    assert!(x[..3] == cmp);
+    assert!(&x[0..3] == cmp);
     let cmp: &[int] = &[2, 3, 4];
-    assert!(x[1..4] == cmp);
+    assert!(&x[1..4] == cmp);
 
     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);
+    assert!(&x[2..] == cmp);
     let cmp: &[int] = &[1, 2, 3];
-    assert!(x[..3] == cmp);
+    assert!(&x[0..3] == cmp);
     let cmp: &[int] = &[2, 3, 4];
-    assert!(x[1..4] == cmp);
+    assert!(&x[1..4] == cmp);
 
     let x: &mut [int] = &mut [1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(x[mut] == cmp);
+        assert!(&mut x[] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
-        assert!(x[mut 2..] == cmp);
+        assert!(&mut x[2..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [1, 2, 3];
-        assert!(x[mut ..3] == cmp);
+        assert!(&mut x[..3] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [2, 3, 4];
-        assert!(x[mut 1..4] == cmp);
+        assert!(&mut x[1..4] == cmp);
     }
 
     let mut x: Vec<int> = vec![1, 2, 3, 4, 5];
     {
         let cmp: &mut [int] = &mut [1, 2, 3, 4, 5];
-        assert!(x[mut] == cmp);
+        assert!(&mut x[] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [3, 4, 5];
-        assert!(x[mut 2..] == cmp);
+        assert!(&mut x[2..] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [1, 2, 3];
-        assert!(x[mut ..3] == cmp);
+        assert!(&mut x[..3] == cmp);
     }
     {
         let cmp: &mut [int] = &mut [2, 3, 4];
-        assert!(x[mut 1..4] == cmp);
+        assert!(&mut x[1..4] == cmp);
     }
 }
index 13f2971871ba89ae218b0ae0a25e71da9cf1beb7..8b9a3f10a60bc744a06fd3aced3b3374569dfe77 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Test that is a slicing expr[..] fails, the correct cleanups happen.
+// Test that if a slicing expr[..] fails, the correct cleanups happen.
 
 #![feature(slicing_syntax)]
 
@@ -24,10 +24,10 @@ impl Drop for Foo {
 
 fn foo() {
     let x: &[_] = &[Foo, Foo];
-    x[3..4];
+    &x[3..4];
 }
 
 fn main() {
-    let _ = Thread::spawn(move|| foo()).join();
+    let _ = Thread::scoped(move|| foo()).join();
     unsafe { assert!(DTOR_COUNT == 2); }
 }
index ccbb33d7768c4bff3a30df226d43f4ce87391cf3..94a0530bffb9437136f19a55c856cb8f33f1d6e8 100644 (file)
@@ -8,7 +8,7 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-// Test that is a slicing expr[..] fails, the correct cleanups happen.
+// Test that if a slicing expr[..] fails, the correct cleanups happen.
 
 #![feature(slicing_syntax)]
 
@@ -28,10 +28,10 @@ fn bar() -> uint {
 
 fn foo() {
     let x: &[_] = &[Foo, Foo];
-    x[3..bar()];
+    &x[3..bar()];
 }
 
 fn main() {
-    let _ = Thread::spawn(move|| foo()).join();
+    let _ = Thread::scoped(move|| foo()).join();
     unsafe { assert!(DTOR_COUNT == 2); }
 }
index f863c4d330fbfa54346d406a64285367fd344197..fca7daeb07d6f8c992508d8225ccfd91c08d942e 100644 (file)
 // Test slicing sugar.
 
 #![feature(slicing_syntax)]
+#![feature(associated_types)]
 
 extern crate core;
-use core::ops::{Slice,SliceMut};
+use core::ops::{Index, Range, RangeTo, RangeFrom, FullRange};
 
 static mut COUNT: uint = 0;
 
 struct Foo;
 
-impl Slice<Foo, Foo> for Foo {
-    fn as_slice_<'a>(&'a self) -> &'a Foo {
+impl Index<Range<Foo>> for Foo {
+    type Output = Foo;
+    fn index(&self, index: &Range<Foo>) -> &Foo {
         unsafe { COUNT += 1; }
         self
     }
-    fn slice_from_or_fail<'a>(&'a self, _from: &Foo) -> &'a Foo {
+}
+impl Index<RangeTo<Foo>> for Foo {
+    type Output = Foo;
+    fn index(&self, index: &RangeTo<Foo>) -> &Foo {
         unsafe { COUNT += 1; }
         self
     }
-    fn slice_to_or_fail<'a>(&'a self, _to: &Foo) -> &'a Foo {
+}
+impl Index<RangeFrom<Foo>> for Foo {
+    type Output = Foo;
+    fn index(&self, index: &RangeFrom<Foo>) -> &Foo {
         unsafe { COUNT += 1; }
         self
     }
-    fn slice_or_fail<'a>(&'a self, _from: &Foo, _to: &Foo) -> &'a Foo {
+}
+impl Index<FullRange> for Foo {
+    type Output = Foo;
+    fn index(&self, _index: &FullRange) -> &Foo {
         unsafe { COUNT += 1; }
         self
     }
 }
 
-impl SliceMut<Foo, Foo> for Foo {
-    fn as_mut_slice_<'a>(&'a mut self) -> &'a mut Foo {
+impl IndexMut<Range<Foo>> for Foo {
+    type Output = Foo;
+    fn index_mut(&mut self, index: &Range<Foo>) -> &mut Foo {
         unsafe { COUNT += 1; }
         self
     }
-    fn slice_from_or_fail_mut<'a>(&'a mut self, _from: &Foo) -> &'a mut Foo {
+}
+impl IndexMut<RangeTo<Foo>> for Foo {
+    type Output = Foo;
+    fn index_mut(&mut self, index: &RangeTo<Foo>) -> &mut Foo {
         unsafe { COUNT += 1; }
         self
     }
-    fn slice_to_or_fail_mut<'a>(&'a mut self, _to: &Foo) -> &'a mut Foo {
+}
+impl IndexMut<RangeFrom<Foo>> for Foo {
+    type Output = Foo;
+    fn index_mut(&mut self, index: &RangeFrom<Foo>) -> &mut Foo {
         unsafe { COUNT += 1; }
         self
     }
-    fn slice_or_fail_mut<'a>(&'a mut self, _from: &Foo, _to: &Foo) -> &'a mut Foo {
+}
+impl IndexMut<FullRange> for Foo {
+    type Output = Foo;
+    fn index_mut(&mut self, _index: &FullRange) -> &mut Foo {
         unsafe { COUNT += 1; }
         self
     }
 }
+
+
 fn main() {
     let mut x = Foo;
-    x[];
-    x[Foo..];
-    x[..Foo];
-    x[Foo..Foo];
-    x[mut];
-    x[mut Foo..];
-    x[mut ..Foo];
-    x[mut Foo..Foo];
+    &x[];
+    &x[Foo..];
+    &x[..Foo];
+    &x[Foo..Foo];
+    &mut x[];
+    &mut x[Foo..];
+    &mut x[..Foo];
+    &mut x[Foo..Foo];
     unsafe {
         assert!(COUNT == 8);
     }
index 46daa6594303c51b1c9a587a705ae08652ff6ccc..c793deaae2b29acaad8b27571d44463f1532ac65 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).as_slice(), $s);
+            assert_eq!(format!("{:?}", S).as_slice(), $s);
         });*
     }}
 }
@@ -29,14 +29,14 @@ macro_rules! check {
 pub fn main() {
     check!(Option<u8>, 2,
            None, "None",
-           Some(129u8), "Some(129)");
+           Some(129u8), "Some(129u8)");
     check!(Option<i16>, 4,
            None, "None",
-           Some(-20000i16), "Some(-20000)");
+           Some(-20000i16), "Some(-20000i16)");
     check!(Either<u8, i8>, 2,
-           Either::Left(132u8), "Left(132)",
-           Either::Right(-32i8), "Right(-32)");
+           Either::Left(132u8), "Left(132u8)",
+           Either::Right(-32i8), "Right(-32i8)");
     check!(Either<u8, i16>, 4,
-           Either::Left(132u8), "Left(132)",
-           Either::Right(-20000i16), "Right(-20000)");
+           Either::Left(132u8), "Left(132u8)",
+           Either::Right(-20000i16), "Right(-20000i16)");
 }
index bb9de7cecc98c4fb53b021efea3430ab06b1c33f..eaad2abe8f72e4909c7a541c82be4e155e9079e5 100644 (file)
@@ -25,6 +25,6 @@ fn iotask(_tx: &ctx, ip: String) {
 
 pub fn main() {
     let (tx, _rx) = channel::<int>();
-    let t = Thread::spawn(move|| iotask(&tx, "localhost".to_string()) );
+    let t = Thread::scoped(move|| iotask(&tx, "localhost".to_string()) );
     t.join().ok().unwrap();
 }
index 820dd49142ac695ac99588d578d66ba89033af63..8f937afa6b93241ebf5a01316fac9e44256ca702 100644 (file)
@@ -11,7 +11,7 @@
 use std::thread::Thread;
 
 pub fn main() {
-    Thread::spawn(move|| child(10)).join().ok().unwrap();
+    Thread::scoped(move|| child(10)).join().ok().unwrap();
 }
 
 fn child(i: int) { println!("{}", i); assert!((i == 10)); }
index 50c2d79132ef5dee706a58ee14b362e721e27f8a..75104a4ddef008ebf063383b9d36a94af4981c90 100644 (file)
@@ -11,7 +11,7 @@
 use std::thread::Thread;
 
 pub fn main() {
-    let t = Thread::spawn(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) );
+    let t = Thread::scoped(move|| child((10, 20, 30, 40, 50, 60, 70, 80, 90)) );
     t.join().ok().unwrap();
 }
 
index ea594977f905cf81b37912afc1bc8027a830ce3c..858b7a83c6274f475f484666c2f6e36bed5be558 100644 (file)
@@ -17,5 +17,5 @@
 
 pub fn main() {
     let mut t = Builder::new();
-    t.spawn(move|| ()).detach();
+    t.spawn(move|| ());
 }
index 2757439828dd97c3201d2421ea43eda9eb7055f2..7cba4533c7f59ce0a88b525a6248c990c2c026e3 100644 (file)
 
 pub fn main() {
   let f = 1u as *const libc::FILE;
-  println!("{}", f as int);
-  println!("{}", f as uint);
-  println!("{}", f as i8);
-  println!("{}", f as i16);
-  println!("{}", f as i32);
-  println!("{}", f as i64);
-  println!("{}", f as u8);
-  println!("{}", f as u16);
-  println!("{}", f as u32);
-  println!("{}", f as u64);
-
-  println!("{}", 1 as int);
-  println!("{}", 1 as uint);
-  println!("{}", 1 as *const libc::FILE);
-  println!("{}", 1 as i8);
-  println!("{}", 1 as i16);
-  println!("{}", 1 as i32);
-  println!("{}", 1 as i64);
-  println!("{}", 1 as u8);
-  println!("{}", 1 as u16);
-  println!("{}", 1 as u32);
-  println!("{}", 1 as u64);
-  println!("{}", 1i as f32);
-  println!("{}", 1i as f64);
-
-  println!("{}", 1u as int);
-  println!("{}", 1u as uint);
-  println!("{}", 1u as *const libc::FILE);
-  println!("{}", 1u as i8);
-  println!("{}", 1u as i16);
-  println!("{}", 1u as i32);
-  println!("{}", 1u as i64);
-  println!("{}", 1u as u8);
-  println!("{}", 1u as u16);
-  println!("{}", 1u as u32);
-  println!("{}", 1u as u64);
-  println!("{}", 1u as f32);
-  println!("{}", 1u as f64);
-
-  println!("{}", 1i8 as int);
-  println!("{}", 1i8 as uint);
-  println!("{}", 1i8 as *const libc::FILE);
-  println!("{}", 1i8 as i8);
-  println!("{}", 1i8 as i16);
-  println!("{}", 1i8 as i32);
-  println!("{}", 1i8 as i64);
-  println!("{}", 1i8 as u8);
-  println!("{}", 1i8 as u16);
-  println!("{}", 1i8 as u32);
-  println!("{}", 1i8 as u64);
-  println!("{}", 1i8 as f32);
-  println!("{}", 1i8 as f64);
-
-  println!("{}", 1u8 as int);
-  println!("{}", 1u8 as uint);
-  println!("{}", 1u8 as *const libc::FILE);
-  println!("{}", 1u8 as i8);
-  println!("{}", 1u8 as i16);
-  println!("{}", 1u8 as i32);
-  println!("{}", 1u8 as i64);
-  println!("{}", 1u8 as u8);
-  println!("{}", 1u8 as u16);
-  println!("{}", 1u8 as u32);
-  println!("{}", 1u8 as u64);
-  println!("{}", 1u8 as f32);
-  println!("{}", 1u8 as f64);
-
-  println!("{}", 1i16 as int);
-  println!("{}", 1i16 as uint);
-  println!("{}", 1i16 as *const libc::FILE);
-  println!("{}", 1i16 as i8);
-  println!("{}", 1i16 as i16);
-  println!("{}", 1i16 as i32);
-  println!("{}", 1i16 as i64);
-  println!("{}", 1i16 as u8);
-  println!("{}", 1i16 as u16);
-  println!("{}", 1i16 as u32);
-  println!("{}", 1i16 as u64);
-  println!("{}", 1i16 as f32);
-  println!("{}", 1i16 as f64);
-
-  println!("{}", 1u16 as int);
-  println!("{}", 1u16 as uint);
-  println!("{}", 1u16 as *const libc::FILE);
-  println!("{}", 1u16 as i8);
-  println!("{}", 1u16 as i16);
-  println!("{}", 1u16 as i32);
-  println!("{}", 1u16 as i64);
-  println!("{}", 1u16 as u8);
-  println!("{}", 1u16 as u16);
-  println!("{}", 1u16 as u32);
-  println!("{}", 1u16 as u64);
-  println!("{}", 1u16 as f32);
-  println!("{}", 1u16 as f64);
-
-  println!("{}", 1i32 as int);
-  println!("{}", 1i32 as uint);
-  println!("{}", 1i32 as *const libc::FILE);
-  println!("{}", 1i32 as i8);
-  println!("{}", 1i32 as i16);
-  println!("{}", 1i32 as i32);
-  println!("{}", 1i32 as i64);
-  println!("{}", 1i32 as u8);
-  println!("{}", 1i32 as u16);
-  println!("{}", 1i32 as u32);
-  println!("{}", 1i32 as u64);
-  println!("{}", 1i32 as f32);
-  println!("{}", 1i32 as f64);
-
-  println!("{}", 1u32 as int);
-  println!("{}", 1u32 as uint);
-  println!("{}", 1u32 as *const libc::FILE);
-  println!("{}", 1u32 as i8);
-  println!("{}", 1u32 as i16);
-  println!("{}", 1u32 as i32);
-  println!("{}", 1u32 as i64);
-  println!("{}", 1u32 as u8);
-  println!("{}", 1u32 as u16);
-  println!("{}", 1u32 as u32);
-  println!("{}", 1u32 as u64);
-  println!("{}", 1u32 as f32);
-  println!("{}", 1u32 as f64);
-
-  println!("{}", 1i64 as int);
-  println!("{}", 1i64 as uint);
-  println!("{}", 1i64 as *const libc::FILE);
-  println!("{}", 1i64 as i8);
-  println!("{}", 1i64 as i16);
-  println!("{}", 1i64 as i32);
-  println!("{}", 1i64 as i64);
-  println!("{}", 1i64 as u8);
-  println!("{}", 1i64 as u16);
-  println!("{}", 1i64 as u32);
-  println!("{}", 1i64 as u64);
-  println!("{}", 1i64 as f32);
-  println!("{}", 1i64 as f64);
-
-  println!("{}", 1u64 as int);
-  println!("{}", 1u64 as uint);
-  println!("{}", 1u64 as *const libc::FILE);
-  println!("{}", 1u64 as i8);
-  println!("{}", 1u64 as i16);
-  println!("{}", 1u64 as i32);
-  println!("{}", 1u64 as i64);
-  println!("{}", 1u64 as u8);
-  println!("{}", 1u64 as u16);
-  println!("{}", 1u64 as u32);
-  println!("{}", 1u64 as u64);
-  println!("{}", 1u64 as f32);
-  println!("{}", 1u64 as f64);
-
-  println!("{}", 1u64 as int);
-  println!("{}", 1u64 as uint);
-  println!("{}", 1u64 as *const libc::FILE);
-  println!("{}", 1u64 as i8);
-  println!("{}", 1u64 as i16);
-  println!("{}", 1u64 as i32);
-  println!("{}", 1u64 as i64);
-  println!("{}", 1u64 as u8);
-  println!("{}", 1u64 as u16);
-  println!("{}", 1u64 as u32);
-  println!("{}", 1u64 as u64);
-  println!("{}", 1u64 as f32);
-  println!("{}", 1u64 as f64);
-
-  println!("{}", true as int);
-  println!("{}", true as uint);
-  println!("{}", true as *const libc::FILE);
-  println!("{}", true as i8);
-  println!("{}", true as i16);
-  println!("{}", true as i32);
-  println!("{}", true as i64);
-  println!("{}", true as u8);
-  println!("{}", true as u16);
-  println!("{}", true as u32);
-  println!("{}", true as u64);
-  println!("{}", true as f32);
-  println!("{}", true as f64);
-
-  println!("{}", 1f32 as int);
-  println!("{}", 1f32 as uint);
-  println!("{}", 1f32 as i8);
-  println!("{}", 1f32 as i16);
-  println!("{}", 1f32 as i32);
-  println!("{}", 1f32 as i64);
-  println!("{}", 1f32 as u8);
-  println!("{}", 1f32 as u16);
-  println!("{}", 1f32 as u32);
-  println!("{}", 1f32 as u64);
-  println!("{}", 1f32 as f32);
-  println!("{}", 1f32 as f64);
-
-  println!("{}", 1f64 as int);
-  println!("{}", 1f64 as uint);
-  println!("{}", 1f64 as i8);
-  println!("{}", 1f64 as i16);
-  println!("{}", 1f64 as i32);
-  println!("{}", 1f64 as i64);
-  println!("{}", 1f64 as u8);
-  println!("{}", 1f64 as u16);
-  println!("{}", 1f64 as u32);
-  println!("{}", 1f64 as u64);
-  println!("{}", 1f64 as f32);
-  println!("{}", 1f64 as f64);
+  println!("{:?}", f as int);
+  println!("{:?}", f as uint);
+  println!("{:?}", f as i8);
+  println!("{:?}", f as i16);
+  println!("{:?}", f as i32);
+  println!("{:?}", f as i64);
+  println!("{:?}", f as u8);
+  println!("{:?}", f as u16);
+  println!("{:?}", f as u32);
+  println!("{:?}", f as u64);
+
+  println!("{:?}", 1 as int);
+  println!("{:?}", 1 as uint);
+  println!("{:?}", 1 as *const libc::FILE);
+  println!("{:?}", 1 as i8);
+  println!("{:?}", 1 as i16);
+  println!("{:?}", 1 as i32);
+  println!("{:?}", 1 as i64);
+  println!("{:?}", 1 as u8);
+  println!("{:?}", 1 as u16);
+  println!("{:?}", 1 as u32);
+  println!("{:?}", 1 as u64);
+  println!("{:?}", 1i as f32);
+  println!("{:?}", 1i as f64);
+
+  println!("{:?}", 1u as int);
+  println!("{:?}", 1u as uint);
+  println!("{:?}", 1u as *const libc::FILE);
+  println!("{:?}", 1u as i8);
+  println!("{:?}", 1u as i16);
+  println!("{:?}", 1u as i32);
+  println!("{:?}", 1u as i64);
+  println!("{:?}", 1u as u8);
+  println!("{:?}", 1u as u16);
+  println!("{:?}", 1u as u32);
+  println!("{:?}", 1u as u64);
+  println!("{:?}", 1u as f32);
+  println!("{:?}", 1u as f64);
+
+  println!("{:?}", 1i8 as int);
+  println!("{:?}", 1i8 as uint);
+  println!("{:?}", 1i8 as *const libc::FILE);
+  println!("{:?}", 1i8 as i8);
+  println!("{:?}", 1i8 as i16);
+  println!("{:?}", 1i8 as i32);
+  println!("{:?}", 1i8 as i64);
+  println!("{:?}", 1i8 as u8);
+  println!("{:?}", 1i8 as u16);
+  println!("{:?}", 1i8 as u32);
+  println!("{:?}", 1i8 as u64);
+  println!("{:?}", 1i8 as f32);
+  println!("{:?}", 1i8 as f64);
+
+  println!("{:?}", 1u8 as int);
+  println!("{:?}", 1u8 as uint);
+  println!("{:?}", 1u8 as *const libc::FILE);
+  println!("{:?}", 1u8 as i8);
+  println!("{:?}", 1u8 as i16);
+  println!("{:?}", 1u8 as i32);
+  println!("{:?}", 1u8 as i64);
+  println!("{:?}", 1u8 as u8);
+  println!("{:?}", 1u8 as u16);
+  println!("{:?}", 1u8 as u32);
+  println!("{:?}", 1u8 as u64);
+  println!("{:?}", 1u8 as f32);
+  println!("{:?}", 1u8 as f64);
+
+  println!("{:?}", 1i16 as int);
+  println!("{:?}", 1i16 as uint);
+  println!("{:?}", 1i16 as *const libc::FILE);
+  println!("{:?}", 1i16 as i8);
+  println!("{:?}", 1i16 as i16);
+  println!("{:?}", 1i16 as i32);
+  println!("{:?}", 1i16 as i64);
+  println!("{:?}", 1i16 as u8);
+  println!("{:?}", 1i16 as u16);
+  println!("{:?}", 1i16 as u32);
+  println!("{:?}", 1i16 as u64);
+  println!("{:?}", 1i16 as f32);
+  println!("{:?}", 1i16 as f64);
+
+  println!("{:?}", 1u16 as int);
+  println!("{:?}", 1u16 as uint);
+  println!("{:?}", 1u16 as *const libc::FILE);
+  println!("{:?}", 1u16 as i8);
+  println!("{:?}", 1u16 as i16);
+  println!("{:?}", 1u16 as i32);
+  println!("{:?}", 1u16 as i64);
+  println!("{:?}", 1u16 as u8);
+  println!("{:?}", 1u16 as u16);
+  println!("{:?}", 1u16 as u32);
+  println!("{:?}", 1u16 as u64);
+  println!("{:?}", 1u16 as f32);
+  println!("{:?}", 1u16 as f64);
+
+  println!("{:?}", 1i32 as int);
+  println!("{:?}", 1i32 as uint);
+  println!("{:?}", 1i32 as *const libc::FILE);
+  println!("{:?}", 1i32 as i8);
+  println!("{:?}", 1i32 as i16);
+  println!("{:?}", 1i32 as i32);
+  println!("{:?}", 1i32 as i64);
+  println!("{:?}", 1i32 as u8);
+  println!("{:?}", 1i32 as u16);
+  println!("{:?}", 1i32 as u32);
+  println!("{:?}", 1i32 as u64);
+  println!("{:?}", 1i32 as f32);
+  println!("{:?}", 1i32 as f64);
+
+  println!("{:?}", 1u32 as int);
+  println!("{:?}", 1u32 as uint);
+  println!("{:?}", 1u32 as *const libc::FILE);
+  println!("{:?}", 1u32 as i8);
+  println!("{:?}", 1u32 as i16);
+  println!("{:?}", 1u32 as i32);
+  println!("{:?}", 1u32 as i64);
+  println!("{:?}", 1u32 as u8);
+  println!("{:?}", 1u32 as u16);
+  println!("{:?}", 1u32 as u32);
+  println!("{:?}", 1u32 as u64);
+  println!("{:?}", 1u32 as f32);
+  println!("{:?}", 1u32 as f64);
+
+  println!("{:?}", 1i64 as int);
+  println!("{:?}", 1i64 as uint);
+  println!("{:?}", 1i64 as *const libc::FILE);
+  println!("{:?}", 1i64 as i8);
+  println!("{:?}", 1i64 as i16);
+  println!("{:?}", 1i64 as i32);
+  println!("{:?}", 1i64 as i64);
+  println!("{:?}", 1i64 as u8);
+  println!("{:?}", 1i64 as u16);
+  println!("{:?}", 1i64 as u32);
+  println!("{:?}", 1i64 as u64);
+  println!("{:?}", 1i64 as f32);
+  println!("{:?}", 1i64 as f64);
+
+  println!("{:?}", 1u64 as int);
+  println!("{:?}", 1u64 as uint);
+  println!("{:?}", 1u64 as *const libc::FILE);
+  println!("{:?}", 1u64 as i8);
+  println!("{:?}", 1u64 as i16);
+  println!("{:?}", 1u64 as i32);
+  println!("{:?}", 1u64 as i64);
+  println!("{:?}", 1u64 as u8);
+  println!("{:?}", 1u64 as u16);
+  println!("{:?}", 1u64 as u32);
+  println!("{:?}", 1u64 as u64);
+  println!("{:?}", 1u64 as f32);
+  println!("{:?}", 1u64 as f64);
+
+  println!("{:?}", 1u64 as int);
+  println!("{:?}", 1u64 as uint);
+  println!("{:?}", 1u64 as *const libc::FILE);
+  println!("{:?}", 1u64 as i8);
+  println!("{:?}", 1u64 as i16);
+  println!("{:?}", 1u64 as i32);
+  println!("{:?}", 1u64 as i64);
+  println!("{:?}", 1u64 as u8);
+  println!("{:?}", 1u64 as u16);
+  println!("{:?}", 1u64 as u32);
+  println!("{:?}", 1u64 as u64);
+  println!("{:?}", 1u64 as f32);
+  println!("{:?}", 1u64 as f64);
+
+  println!("{:?}", true as int);
+  println!("{:?}", true as uint);
+  println!("{:?}", true as *const libc::FILE);
+  println!("{:?}", true as i8);
+  println!("{:?}", true as i16);
+  println!("{:?}", true as i32);
+  println!("{:?}", true as i64);
+  println!("{:?}", true as u8);
+  println!("{:?}", true as u16);
+  println!("{:?}", true as u32);
+  println!("{:?}", true as u64);
+  println!("{:?}", true as f32);
+  println!("{:?}", true as f64);
+
+  println!("{:?}", 1f32 as int);
+  println!("{:?}", 1f32 as uint);
+  println!("{:?}", 1f32 as i8);
+  println!("{:?}", 1f32 as i16);
+  println!("{:?}", 1f32 as i32);
+  println!("{:?}", 1f32 as i64);
+  println!("{:?}", 1f32 as u8);
+  println!("{:?}", 1f32 as u16);
+  println!("{:?}", 1f32 as u32);
+  println!("{:?}", 1f32 as u64);
+  println!("{:?}", 1f32 as f32);
+  println!("{:?}", 1f32 as f64);
+
+  println!("{:?}", 1f64 as int);
+  println!("{:?}", 1f64 as uint);
+  println!("{:?}", 1f64 as i8);
+  println!("{:?}", 1f64 as i16);
+  println!("{:?}", 1f64 as i32);
+  println!("{:?}", 1f64 as i64);
+  println!("{:?}", 1f64 as u8);
+  println!("{:?}", 1f64 as u16);
+  println!("{:?}", 1f64 as u32);
+  println!("{:?}", 1f64 as u64);
+  println!("{:?}", 1f64 as f32);
+  println!("{:?}", 1f64 as f64);
 }
index 021cfedf06f96c337e73ee815d4e4474ee495e06..a91e5da15376800596c89ea4dfdbf9b3dbb67600 100644 (file)
@@ -10,7 +10,7 @@
 
 #![feature(optin_builtin_traits)]
 
-use std::kinds::Send;
+use std::marker::Send;
 
 struct TestType;
 
index 8438a5ff47f9afaa9b4908438d05dec81cd6e627..b88357252d8ed617e260e55a123850cdb9babc28 100644 (file)
@@ -21,7 +21,7 @@ struct t_rec {
 
 pub fn main() {
     let x = t_rec {c8: 22u8, t: a_tag::a_tag_var(44u64)};
-    let y = format!("{}", x);
-    println!("y = {}", y);
-    assert_eq!(y, "t_rec { c8: 22, t: a_tag_var(44) }".to_string());
+    let y = format!("{:?}", x);
+    println!("y = {:?}", y);
+    assert_eq!(y, "t_rec { c8: 22u8, t: a_tag_var(44u64) }".to_string());
 }
index 1155a619a607063e2286e028ba6cdfd5d8c80f17..049e4bb9a38ef084d3a7550e002131273bdd08da 100644 (file)
@@ -18,9 +18,9 @@ enum color {
 }
 
 pub fn main() {
-    let act = format!("{}", color::red);
+    let act = format!("{:?}", color::red);
     println!("{}", act);
     assert_eq!("red".to_string(), act);
-    assert_eq!("green".to_string(), format!("{}", color::green));
-    assert_eq!("white".to_string(), format!("{}", color::white));
+    assert_eq!("green".to_string(), format!("{:?}", color::green));
+    assert_eq!("white".to_string(), format!("{:?}", color::white));
 }
index 966bb6aa7358bce2e9f400c7dfe02955577c3d7d..180f6e09ba99bb12b0f341e85dfa5c215912e306 100644 (file)
@@ -15,6 +15,6 @@
 fn start() { println!("Started / Finished task."); }
 
 fn test00() {
-    let _ = Thread::spawn(move|| start() ).join();
+    let _ = Thread::scoped(move|| start() ).join();
     println!("Completing.");
 }
index 561c9e91553dd17fc5d9254f99cfc90d94610da7..da080408ad17c8a9be99fc09a2bfd520391db5cc 100644 (file)
@@ -16,7 +16,7 @@
 
 fn test00() {
     let i: int = 0;
-    let mut result = Thread::spawn(move|| {
+    let mut result = Thread::scoped(move|| {
         start(i)
     });
 
index 50667d375a13c0f53345331709f1dfc2efcd9c8b..429c6ce9fb3711531cf0f1765730d8839b29182c 100644 (file)
@@ -19,6 +19,6 @@ fn start(tx: &Sender<int>, start: int, number_of_messages: int) {
 pub fn main() {
     println!("Check that we don't deadlock.");
     let (tx, rx) = channel();
-    let _ = Thread::spawn(move|| { start(&tx, 0, 10) }).join();
+    let _ = Thread::scoped(move|| { start(&tx, 0, 10) }).join();
     println!("Joined task");
 }
index 82e4bd8f6d2a1688b30007e09e85b44c858acc2b..0735e3996eec10ec81986948a1157616b598d143 100644 (file)
@@ -19,7 +19,7 @@ pub fn main() {
     while (i > 0) {
         println!("{}", i);
         let tx = tx.clone();
-        Thread::spawn({let i = i; move|| { child(i, &tx) }}).detach();
+        Thread::spawn({let i = i; move|| { child(i, &tx) }});
         i = i - 1;
     }
 
index e9f7cdf96a83a4a37a379d61cbf80d2e221fca9b..9db5465f7e96e77e03d0dbaa66fdb1490644f28b 100644 (file)
@@ -18,5 +18,5 @@ fn f() {
 }
 
 pub fn main() {
-    let _t = Thread::spawn(move|| f() ).join();
+    let _t = Thread::scoped(move|| f() ).join();
 }
index a002a597481e42ee8a660694f223efa37716037c..306cc0ffcef7cb6127c7a84fe41f6b100713dd80 100644 (file)
@@ -40,7 +40,7 @@ fn test00() {
     let mut results = Vec::new();
     while i < number_of_tasks {
         let tx = tx.clone();
-        results.push(Thread::spawn({
+        results.push(Thread::scoped({
             let i = i;
             move|| {
                 test00_start(&tx, i, number_of_messages)
index d9faf6ee4e4b24a0a1dce1f2a43c41ae36b854ec..6d8de4a6a53d6c090b2cfa7fae564fe5b1739bec 100644 (file)
@@ -24,7 +24,7 @@ fn test00() {
     let (tx, rx) = channel();
     let number_of_messages: int = 10;
 
-    let result = Thread::spawn(move|| {
+    let result = Thread::scoped(move|| {
         test00_start(&tx, number_of_messages);
     });
 
index a7eabe0edb3845468dc07836eb5f4086c82e4c62..7ff5960375cb2d7d20d0f2ea93a9ee791e4222c4 100644 (file)
@@ -17,7 +17,7 @@ fn main() {
     let mut reader = ChanReader::new(rx);
     let stderr = ChanWriter::new(tx);
 
-    let res = thread::Builder::new().stderr(box stderr as Box<Writer + Send>).spawn(move|| -> () {
+    let res = thread::Builder::new().stderr(box stderr as Box<Writer + Send>).scoped(move|| -> () {
         panic!("Hello, world!")
     }).join();
     assert!(res.is_err());
index 3e6158ca82193e3c6c309e08b35d5d6f12ae0c05..cd3cb872fd3bc58fdca1791a001752162b808b30 100644 (file)
@@ -52,7 +52,7 @@ fn test() {
                 }
             }
             srv_tx.send(());
-        }).detach();
+        });
     }
 
     for _ in range(0, N) {
@@ -62,7 +62,7 @@ fn test() {
                 let _s = TcpStream::connect(addr).unwrap();
             }
             cli_tx.send(());
-        }).detach();
+        });
     }
     drop((cli_tx, srv_tx));
 
index 7d226aa9420320b95bd35e40c88735d9b6a83834..0109d64ad5347896f7c9129a27a54dca6cdd11c6 100644 (file)
@@ -29,7 +29,7 @@ fn main() {
         timer::sleep(Duration::milliseconds(30 * 1000));
         println!("timed out!");
         unsafe { libc::exit(1) }
-    }).detach();
+    });
 
     let (tx, rx) = channel();
     Thread::spawn(move || -> () {
@@ -47,7 +47,7 @@ fn main() {
             stream.read_byte();
             stream.write(&[2]);
         }
-    }).detach();
+    });
     let addr = rx.recv().unwrap();
 
     let (tx, rx) = channel();
@@ -64,7 +64,7 @@ fn main() {
                 Err(e) => debug!("{}", e)
             }
             tx.send(()).unwrap();
-        }).detach();
+        });
     }
 
     // Wait for all clients to exit, but don't wait for the server to exit. The
index bf108ecd6764a954e681940487786c1e78a21382..b931bd9609c6fde3fbfa64a369c9cf8d8bb23f1b 100644 (file)
@@ -42,7 +42,7 @@ fn test_rm_tempdir() {
         tx.send(tmp.path().clone()).unwrap();
         panic!("panic to unwind past `tmp`");
     };
-    let _ = Thread::spawn(f).join();
+    let _ = Thread::scoped(f).join();
     let path = rx.recv().unwrap();
     assert!(!path.exists());
 
@@ -52,7 +52,7 @@ fn test_rm_tempdir() {
         let _tmp = tmp;
         panic!("panic to unwind past `tmp`");
     };
-    let _ = Thread::spawn(f).join();
+    let _ = Thread::scoped(f).join();
     assert!(!path.exists());
 
     let path;
@@ -60,7 +60,7 @@ fn test_rm_tempdir() {
         let f = move|:| {
             TempDir::new("test_rm_tempdir").unwrap()
         };
-        let tmp = Thread::spawn(f).join().ok().expect("test_rm_tmdir");
+        let tmp = Thread::scoped(f).join().ok().expect("test_rm_tmdir");
         path = tmp.path().clone();
         assert!(path.exists());
     }
@@ -84,7 +84,7 @@ fn test_rm_tempdir_close() {
         tmp.close();
         panic!("panic when unwinding past `tmp`");
     };
-    let _ = Thread::spawn(f).join();
+    let _ = Thread::scoped(f).join();
     let path = rx.recv().unwrap();
     assert!(!path.exists());
 
@@ -95,7 +95,7 @@ fn test_rm_tempdir_close() {
         tmp.close();
         panic!("panic when unwinding past `tmp`");
     };
-    let _ = Thread::spawn(f).join();
+    let _ = Thread::scoped(f).join();
     assert!(!path.exists());
 
     let path;
@@ -103,7 +103,7 @@ fn test_rm_tempdir_close() {
         let f = move|:| {
             TempDir::new("test_rm_tempdir").unwrap()
         };
-        let tmp = Thread::spawn(f).join().ok().expect("test_rm_tmdir");
+        let tmp = Thread::scoped(f).join().ok().expect("test_rm_tmdir");
         path = tmp.path().clone();
         assert!(path.exists());
         tmp.close();
@@ -177,7 +177,7 @@ pub fn test_rmdir_recursive_ok() {
 }
 
 pub fn dont_double_panic() {
-    let r: Result<(), _> = Thread::spawn(move|| {
+    let r: Result<(), _> = Thread::scoped(move|| {
         let tmpdir = TempDir::new("test").unwrap();
         // Remove the temporary directory so that TempDir sees
         // an error on drop
index 4270ecc7450921713404b199c210dcccfdcc3da4..bfd1f5f4a74dd60ef6710a1a0df2615ee3206872 100644 (file)
 
 fn test_panic() {
     fn f() { let _x: Box<int> = panic!(); }
-    Thread::spawn(move|| f() ).join().err().unwrap();
+    Thread::scoped(move|| f() ).join().err().unwrap();
 }
 
 fn test_panic_indirect() {
     fn f() -> ! { panic!(); }
     fn g() { let _x: Box<int> = f(); }
-    Thread::spawn(move|| g() ).join().err().unwrap();
+    Thread::scoped(move|| g() ).join().err().unwrap();
 }
 
 pub fn main() {
index 02817a285ddf5bbd007d4105747ea72d74163dcf..c47ca0db2a15693d797a1de63f0ae549608f36a0 100644 (file)
@@ -13,7 +13,7 @@
 pub fn main() {
     let mut i = 10;
     while i > 0 {
-        Thread::spawn({let i = i; move|| child(i)}).detach();
+        Thread::spawn({let i = i; move|| child(i)});
         i = i - 1;
     }
     println!("main thread exiting");
index 6bece8265c0066252f3f68752a86181b49d8dd0a..df8efb42e30e5bdfcedf2dd13ccf167259491aab 100644 (file)
@@ -19,5 +19,5 @@ pub fn main() {
     let (tx, rx) = channel();
     tx.send(42i);
     let r = rx.recv();
-    println!("{}", r);
+    println!("{:?}", r);
 }
index 5bf152f2976b9d6704de1f144eff2df4adc0ef5a..d7a78dbc4119ba9ca29008a204457d2ca79b67d7 100644 (file)
@@ -13,5 +13,5 @@
 
 pub fn main() {
     let x = Foo(1, 2);
-    println!("{}", x);
+    println!("{:?}", x);
 }
index 4f473755cb6cff868fd36c406abd55d2fac49d4a..e3b148ac92db6fbe1e4a8e6c43027176454c1fc1 100644 (file)
@@ -17,7 +17,7 @@ struct Foo<T> {
 
 pub fn main() {
     unsafe {
-        assert_eq!((*get_tydesc::<int>()).name, "int");
-        assert_eq!((*get_tydesc::<Foo<uint>>()).name, "Foo<uint>");
+        assert_eq!((*get_tydesc::<int>()).name, "isize");
+        assert_eq!((*get_tydesc::<Foo<uint>>()).name, "Foo<usize>");
     }
 }
index bd4143348b8867660d7af9c27fb86eb0e3d4cbfa..bb3019ede4b5764dc86547851f447ad7b1d36485 100644 (file)
@@ -23,7 +23,7 @@ pub fn main() {
         let tx = tx.clone();
         Thread::spawn(move|| {
             child(&tx, i)
-        }).detach();
+        });
         expected += i;
     }
 
index 9aeb5b10cf5f8d40b9b4c88639d48524fde69e6f..4c8665032828e50fbb93496e57621f7607eb7a37 100644 (file)
@@ -22,7 +22,7 @@ fn drop(&mut self) {
 }
 
 pub fn main() {
-    let x = Thread::spawn(move|| {
+    let x = Thread::scoped(move|| {
         let _b = Foo;
     }).join();
 
index bdd62995e0a31c5dd2cb58a9fd2951ec17e51fa9..29bf82a81d65da7949368c4fd0156b7511530596 100644 (file)
@@ -77,7 +77,7 @@ pub fn main() {
 
                 let v = main.clone();
 
-                let _ = Thread::spawn(move|| {
+                let _ = Thread::scoped(move|| {
                     let mut v = v;
                     let mut panic_countdown = panic_countdown;
                     v.as_mut_slice().sort_by(|a, b| {
diff --git a/src/test/run-pass/where-clauses-not-parameter.rs b/src/test/run-pass/where-clauses-not-parameter.rs
deleted file mode 100644 (file)
index bc5fc38..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <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.
-
-fn equal<T>(_: &T, _: &T) -> bool where int : Eq {
-    true
-}
-
-fn main() {
-    equal(&0i, &0i);
-}
index 9a96b483f2c92d3b3dec452fba69bfc9cff085ea..9ad6dd9d2b14213302d6f7e109e776f90d0832f0 100644 (file)
@@ -11,7 +11,7 @@
 use std::thread::Thread;
 
 pub fn main() {
-    let mut result = Thread::spawn(child);
+    let mut result = Thread::scoped(child);
     println!("1");
     Thread::yield_now();
     println!("2");
index 13119e5d909cd26b5e05e8b633e3e403bd668a93..3d3a36021da1569d405b95fbb4271f28ea9a7ced 100644 (file)
@@ -11,7 +11,7 @@
 use std::thread::Thread;
 
 pub fn main() {
-    let mut result = Thread::spawn(child);
+    let mut result = Thread::scoped(child);
     println!("1");
     Thread::yield_now();
     result.join();