From afe376d57125a452fa6d3338cc5ae863146be69f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 14 Oct 2014 23:05:01 -0700 Subject: [PATCH] Remove a large amount of deprecated functionality Spring cleaning is here! In the Fall! This commit removes quite a large amount of deprecated functionality from the standard libraries. I tried to ensure that only old deprecated functionality was removed. This is removing lots and lots of deprecated features, so this is a breaking change. Please consult the deprecation messages of the deleted code to see how to migrate code forward if it still needs migration. [breaking-change] --- src/libcollections/dlist.rs | 15 +- src/libcollections/lib.rs | 34 -- src/libcollections/priority_queue.rs | 14 - src/libcollections/ringbuf.rs | 108 +++---- src/libcollections/slice.rs | 241 ++------------ src/libcollections/smallintmap.rs | 40 +-- src/libcollections/str.rs | 96 ------ src/libcollections/string.rs | 218 ------------- src/libcollections/treemap.rs | 42 --- src/libcollections/trie.rs | 18 -- src/libcollections/vec.rs | 200 +----------- src/libcore/any.rs | 19 -- src/libcore/cmp.rs | 14 - src/libcore/iter.rs | 21 -- src/libcore/kinds.rs | 3 - src/libcore/lib.rs | 7 - src/libcore/mem.rs | 146 --------- src/libcore/option.rs | 140 -------- src/libcore/ptr.rs | 64 ---- src/libcore/result.rs | 40 --- src/libcore/slice.rs | 286 +--------------- src/libcoretest/cmp.rs | 16 - src/libcoretest/option.rs | 53 +-- src/libcoretest/ptr.rs | 132 +------- src/libcoretest/result.rs | 35 +- src/libgraphviz/maybe_owned_vec.rs | 8 - src/libgreen/basic.rs | 4 +- src/libgreen/sched.rs | 26 +- src/libgreen/task.rs | 10 +- src/libnative/io/addrinfo.rs | 10 +- src/libnative/io/helper_thread.rs | 7 +- src/libnative/io/timer_unix.rs | 6 +- src/libnative/lib.rs | 2 +- src/libnative/task.rs | 100 +++--- src/librand/isaac.rs | 8 +- src/librand/lib.rs | 6 - src/librustc/back/link.rs | 53 +-- src/librustc/driver/config.rs | 4 +- src/librustc/driver/driver.rs | 15 +- src/librustc/driver/mod.rs | 14 +- src/librustc/driver/pretty.rs | 6 +- src/librustc/lib.rs | 1 - src/librustc/lint/builtin.rs | 6 +- src/librustc/lint/context.rs | 2 +- src/librustc/metadata/csearch.rs | 5 +- src/librustc/metadata/cstore.rs | 2 +- src/librustc/metadata/decoder.rs | 2 +- src/librustc/metadata/encoder.rs | 22 +- src/librustc/metadata/loader.rs | 6 +- src/librustc/metadata/tydecode.rs | 6 +- src/librustc/middle/astencode.rs | 2 +- .../borrowck/gather_loans/move_error.rs | 2 +- src/librustc/middle/borrowck/graphviz.rs | 9 +- src/librustc/middle/borrowck/mod.rs | 6 +- src/librustc/middle/borrowck/move_data.rs | 22 +- src/librustc/middle/cfg/construct.rs | 2 +- src/librustc/middle/cfg/graphviz.rs | 11 +- src/librustc/middle/check_match.rs | 26 +- src/librustc/middle/dataflow.rs | 8 +- src/librustc/middle/dead.rs | 6 +- src/librustc/middle/effect.rs | 2 +- src/librustc/middle/expr_use_visitor.rs | 2 +- src/librustc/middle/graph.rs | 18 +- src/librustc/middle/intrinsicck.rs | 2 +- src/librustc/middle/lang_items.rs | 14 +- src/librustc/middle/liveness.rs | 32 +- src/librustc/middle/mem_categorization.rs | 6 +- src/librustc/middle/privacy.rs | 12 +- src/librustc/middle/reachable.rs | 2 +- src/librustc/middle/region.rs | 6 +- src/librustc/middle/resolve.rs | 47 +-- src/librustc/middle/resolve_lifetime.rs | 4 +- src/librustc/middle/save/mod.rs | 45 ++- src/librustc/middle/save/recorder.rs | 24 +- src/librustc/middle/subst.rs | 4 +- src/librustc/middle/traits/select.rs | 23 +- src/librustc/middle/traits/util.rs | 5 +- src/librustc/middle/trans/_match.rs | 35 +- src/librustc/middle/trans/adt.rs | 43 +-- src/librustc/middle/trans/asm.rs | 11 +- src/librustc/middle/trans/base.rs | 31 +- src/librustc/middle/trans/builder.rs | 6 +- src/librustc/middle/trans/cabi_x86_64.rs | 2 +- src/librustc/middle/trans/callee.rs | 26 +- src/librustc/middle/trans/cleanup.rs | 2 +- src/librustc/middle/trans/closure.rs | 2 +- src/librustc/middle/trans/common.rs | 6 +- src/librustc/middle/trans/consts.rs | 2 +- src/librustc/middle/trans/controlflow.rs | 5 +- src/librustc/middle/trans/debuginfo.rs | 106 +++--- src/librustc/middle/trans/expr.rs | 13 +- src/librustc/middle/trans/foreign.rs | 15 +- src/librustc/middle/trans/glue.rs | 4 +- src/librustc/middle/trans/intrinsic.rs | 102 +++--- src/librustc/middle/trans/meth.rs | 6 +- src/librustc/middle/ty.rs | 13 +- src/librustc/middle/typeck/astconv.rs | 16 +- src/librustc/middle/typeck/check/_match.rs | 10 +- src/librustc/middle/typeck/check/method.rs | 26 +- src/librustc/middle/typeck/check/mod.rs | 20 +- src/librustc/middle/typeck/check/regionck.rs | 4 +- src/librustc/middle/typeck/coherence/mod.rs | 8 +- src/librustc/middle/typeck/collect.rs | 12 +- src/librustc/middle/typeck/infer/combine.rs | 21 +- .../middle/typeck/infer/error_reporting.rs | 8 +- .../typeck/infer/region_inference/mod.rs | 30 +- src/librustc/middle/typeck/variance.rs | 17 +- src/librustc/plugin/load.rs | 4 +- src/librustc/util/common.rs | 2 +- src/librustc/util/ppaux.rs | 30 +- src/librustc/util/snapshot_vec.rs | 4 +- src/librustdoc/html/format.rs | 8 +- src/librustdoc/html/render.rs | 46 +-- src/librustrt/args.rs | 4 +- src/librustrt/c_str.rs | 24 -- src/libserialize/json.rs | 8 - src/libstd/ascii.rs | 52 +-- src/libstd/collections/hashmap/map.rs | 306 +----------------- src/libstd/io/net/udp.rs | 19 -- src/libstd/lib.rs | 4 - src/libstd/num/f32.rs | 23 -- src/libstd/num/f64.rs | 23 -- src/libstd/num/i16.rs | 3 +- src/libstd/num/i32.rs | 3 +- src/libstd/num/i64.rs | 3 +- src/libstd/num/i8.rs | 3 +- src/libstd/num/int.rs | 3 +- src/libstd/num/int_macros.rs | 50 --- src/libstd/num/mod.rs | 7 - src/libstd/num/strconv.rs | 34 +- src/libstd/num/u16.rs | 3 +- src/libstd/num/u32.rs | 3 +- src/libstd/num/u64.rs | 3 +- src/libstd/num/u8.rs | 3 +- src/libstd/num/uint.rs | 3 +- src/libstd/num/uint_macros.rs | 33 -- src/libstd/sync/mod.rs | 3 - src/libstd/task.rs | 46 --- src/libsync/comm/duplex.rs | 78 ----- src/libsync/comm/mod.rs | 13 +- src/libsync/mpmc_bounded_queue.rs | 5 +- src/libsync/mpsc_queue.rs | 3 +- src/libsync/mutex.rs | 3 +- src/libsync/spsc_queue.rs | 4 +- src/libsyntax/ast_map/mod.rs | 6 +- src/libsyntax/ast_util.rs | 2 +- src/libsyntax/codemap.rs | 39 +-- src/libsyntax/crateid.rs | 216 ------------- src/libsyntax/diagnostic.rs | 18 +- src/libsyntax/ext/base.rs | 2 +- src/libsyntax/ext/build.rs | 2 +- src/libsyntax/ext/concat.rs | 2 +- src/libsyntax/ext/deriving/clone.rs | 2 +- src/libsyntax/ext/deriving/generic/mod.rs | 8 +- src/libsyntax/ext/deriving/show.rs | 2 +- src/libsyntax/ext/expand.rs | 38 +-- src/libsyntax/ext/format.rs | 18 +- src/libsyntax/ext/mtwt.rs | 18 +- src/libsyntax/ext/quote.rs | 10 +- src/libsyntax/ext/tt/macro_parser.rs | 8 +- src/libsyntax/ext/tt/macro_rules.rs | 4 +- src/libsyntax/ext/tt/transcribe.rs | 4 +- src/libsyntax/fold.rs | 16 +- src/libsyntax/lib.rs | 2 - src/libsyntax/owned_slice.rs | 2 +- src/libsyntax/parse/lexer/comments.rs | 16 +- src/libsyntax/parse/lexer/mod.rs | 6 +- src/libsyntax/parse/mod.rs | 10 +- src/libsyntax/parse/parser.rs | 60 ++-- src/libsyntax/print/pp.rs | 69 ++-- src/libsyntax/print/pprust.rs | 24 +- src/libsyntax/ptr.rs | 4 +- src/libsyntax/std_inject.rs | 4 +- src/libsyntax/util/interner.rs | 6 +- src/libsyntax/util/small_vector.rs | 2 +- .../anon-extern-mod-cross-crate-1.rs | 2 +- src/test/auxiliary/cci_impl_lib.rs | 2 +- src/test/auxiliary/cci_iter_lib.rs | 2 +- src/test/auxiliary/cci_no_inline_lib.rs | 4 +- src/test/auxiliary/changing-crates-a1.rs | 2 +- src/test/auxiliary/changing-crates-a2.rs | 2 +- src/test/auxiliary/changing-crates-b.rs | 2 +- .../crate-method-reexport-grrrrrrr2.rs | 2 +- src/test/auxiliary/crateresolve3-1.rs | 2 +- src/test/auxiliary/crateresolve3-2.rs | 2 +- src/test/auxiliary/crateresolve4a-1.rs | 2 +- src/test/auxiliary/crateresolve4a-2.rs | 2 +- src/test/auxiliary/crateresolve4b-1.rs | 2 +- src/test/auxiliary/crateresolve4b-2.rs | 2 +- src/test/auxiliary/crateresolve5-1.rs | 2 +- src/test/auxiliary/crateresolve5-2.rs | 2 +- src/test/auxiliary/crateresolve8-1.rs | 2 +- src/test/auxiliary/crateresolve_calories-1.rs | 2 +- src/test/auxiliary/crateresolve_calories-2.rs | 2 +- src/test/auxiliary/foreign_lib.rs | 2 +- src/test/auxiliary/inherited_stability.rs | 2 +- src/test/auxiliary/inline_dtor.rs | 2 +- src/test/auxiliary/iss.rs | 2 +- src/test/auxiliary/issue-2380.rs | 2 +- src/test/auxiliary/issue-2414-a.rs | 2 +- src/test/auxiliary/issue-2414-b.rs | 2 +- src/test/auxiliary/issue-2526.rs | 2 +- src/test/auxiliary/issue-2631-a.rs | 6 +- src/test/auxiliary/issue-3012-1.rs | 2 +- src/test/auxiliary/issue-4208-cc.rs | 2 +- src/test/auxiliary/issue_2242_a.rs | 2 +- src/test/auxiliary/issue_2242_c.rs | 2 +- src/test/auxiliary/issue_3979_traits.rs | 2 +- src/test/auxiliary/lint_output_format.rs | 2 +- src/test/auxiliary/lint_stability.rs | 2 +- src/test/auxiliary/macro_crate_test.rs | 2 +- .../auxiliary/static-function-pointer-aux.rs | 2 +- src/test/auxiliary/static-methods-crate.rs | 2 +- src/test/auxiliary/struct_variant_xc_aux.rs | 2 +- src/test/auxiliary/svh-a-base.rs | 2 +- src/test/auxiliary/svh-a-change-lit.rs | 2 +- .../auxiliary/svh-a-change-significant-cfg.rs | 2 +- .../auxiliary/svh-a-change-trait-bound.rs | 2 +- src/test/auxiliary/svh-a-change-type-arg.rs | 2 +- src/test/auxiliary/svh-a-change-type-ret.rs | 2 +- .../auxiliary/svh-a-change-type-static.rs | 2 +- src/test/auxiliary/svh-a-comment.rs | 2 +- src/test/auxiliary/svh-a-doc.rs | 2 +- src/test/auxiliary/svh-a-macro.rs | 2 +- src/test/auxiliary/svh-a-no-change.rs | 2 +- src/test/auxiliary/svh-a-redundant-cfg.rs | 2 +- src/test/auxiliary/svh-a-whitespace.rs | 2 +- src/test/auxiliary/svh-b.rs | 2 +- src/test/auxiliary/svh-uta-base.rs | 2 +- .../auxiliary/svh-uta-change-use-trait.rs | 2 +- src/test/auxiliary/svh-utb.rs | 2 +- .../auxiliary/trait_default_method_xc_aux.rs | 2 +- src/test/bench/core-std.rs | 16 +- src/test/bench/core-uint-to-str.rs | 2 +- src/test/bench/msgsend-ring-mutex-arcs.rs | 4 +- src/test/bench/msgsend-ring-rw-arcs.rs | 4 +- src/test/bench/shootout-ackermann.rs | 2 +- src/test/bench/shootout-fibo.rs | 2 +- src/test/bench/shootout-k-nucleotide-pipes.rs | 29 +- src/test/bench/shootout-nbody.rs | 20 +- src/test/bench/shootout-pfib.rs | 2 +- src/test/bench/std-smallintmap.rs | 6 +- src/test/bench/sudoku.rs | 36 +-- src/test/bench/task-perf-alloc-unwind.rs | 27 +- .../bench/task-perf-jargon-metal-smoke.rs | 2 +- src/test/bench/task-perf-spawnalot.rs | 2 +- .../syntax-extension-fourcc-bad-len.rs | 22 -- .../syntax-extension-fourcc-invalid-endian.rs | 21 -- .../syntax-extension-fourcc-non-ascii-str.rs | 21 -- .../syntax-extension-fourcc-non-literal.rs | 21 -- ...ax-extension-fourcc-unsupported-literal.rs | 21 -- .../syntax-extension-hexfloat-bad-lits.rs | 34 -- .../syntax-extension-hexfloat-bad-types.rs | 26 -- .../compile-fail/borrowck-assign-comp-idx.rs | 2 +- .../compile-fail/borrowck-loan-vec-content.rs | 4 +- .../borrowck-overloaded-index-2.rs | 2 +- src/test/compile-fail/deprecated-url.rs | 20 -- src/test/compile-fail/lub-if.rs | 8 +- .../moves-based-on-type-access-to-field.rs | 2 +- .../compile-fail/moves-based-on-type-exprs.rs | 6 +- src/test/compile-fail/no-capture-arc.rs | 4 +- src/test/compile-fail/no-reuse-move-arc.rs | 4 +- .../compile-fail/ufcs-explicit-self-bad.rs | 2 - .../unresolved-extern-mod-suggestion.rs | 4 +- .../compile-fail/writing-to-immutable-vec.rs | 2 +- .../bug-2470-bounds-check-overflow.rs | 2 +- src/test/run-fail/glob-use-std.rs | 2 - src/test/run-fail/issue-3029.rs | 2 +- src/test/run-fail/vec-overrun.rs | 4 +- .../bootstrap-from-c-with-native/lib.rs | 2 +- src/test/run-make/dep-info-custom/lib.rs | 2 +- .../run-make/libs-through-symlinks/foo.rs | 2 +- .../run-make/lto-syntax-extension/main.rs | 5 +- .../many-crates-but-no-match/crateA1.rs | 2 +- .../many-crates-but-no-match/crateA2.rs | 2 +- .../many-crates-but-no-match/crateA3.rs | 2 +- src/test/run-make/rustdoc-hidden-line/foo.rs | 2 +- src/test/run-make/rustdoc-json/foo.rs | 2 +- src/test/run-make/rustdoc-smoke/foo.rs | 2 +- .../run-make/unicode-input/multiple_files.rs | 4 +- .../run-make/unicode-input/span_length.rs | 4 +- .../syntax-extension-fourcc.rs | 43 --- .../syntax-extension-hexfloat.rs | 29 -- src/test/run-pass/assignability-trait.rs | 2 +- .../run-pass/bare-fn-implements-fn-mut.rs | 5 +- src/test/run-pass/borrowck-mut-uniq.rs | 2 +- .../call-closure-from-overloaded-op.rs | 2 +- .../run-pass/coerce-reborrow-imm-vec-rcvr.rs | 4 +- .../run-pass/drop-with-type-ascription-1.rs | 2 +- .../run-pass/drop-with-type-ascription-2.rs | 6 +- src/test/run-pass/expr-fn.rs | 2 +- src/test/run-pass/expr-match-fail.rs | 2 +- src/test/run-pass/foreach-nested.rs | 8 +- src/test/run-pass/hashmap-memory.rs | 2 +- src/test/run-pass/issue-13304.rs | 2 +- src/test/run-pass/issue-14021.rs | 2 +- src/test/run-pass/issue-14456.rs | 4 +- src/test/run-pass/issue-14940.rs | 2 +- src/test/run-pass/issue-15149.rs | 4 +- src/test/run-pass/issue-15189.rs | 2 +- src/test/run-pass/issue-17216.rs | 2 +- src/test/run-pass/issue-2383.rs | 2 +- src/test/run-pass/issue-2804-2.rs | 2 +- src/test/run-pass/issue-2804.rs | 6 +- src/test/run-pass/issue-2904.rs | 2 +- src/test/run-pass/issue-2989.rs | 4 +- src/test/run-pass/issue-3609.rs | 2 +- src/test/run-pass/issue-5521.rs | 2 +- src/test/run-pass/issue-7660.rs | 4 +- src/test/run-pass/issue-9259.rs | 2 +- src/test/run-pass/match-vec-rvalue.rs | 6 +- src/test/run-pass/monad.rs | 2 +- src/test/run-pass/move-arg-2-unique.rs | 2 +- src/test/run-pass/move-arg-2.rs | 2 +- src/test/run-pass/newtype-polymorphic.rs | 4 +- .../nullable-pointer-iotareduction.rs | 2 +- ...owned-object-borrowed-method-headerless.rs | 2 +- src/test/run-pass/overloaded-deref.rs | 6 +- .../process-spawn-with-unicode-params.rs | 6 +- src/test/run-pass/pure-sum.rs | 8 +- .../run-pass/regions-dependent-addr-of.rs | 4 +- .../regions-infer-borrow-scope-view.rs | 2 +- src/test/run-pass/running-with-no-runtime.rs | 2 +- src/test/run-pass/size-and-align.rs | 2 +- src/test/run-pass/static-impl.rs | 4 +- src/test/run-pass/swap-2.rs | 6 +- src/test/run-pass/task-comm-16.rs | 6 +- .../run-pass/trait-with-bounds-default.rs | 2 +- src/test/run-pass/type-use-i1-versus-i8.rs | 4 +- src/test/run-pass/ufcs-explicit-self.rs | 2 - src/test/run-pass/unique-autoderef-index.rs | 2 +- src/test/run-pass/unique-in-vec-copy.rs | 8 +- src/test/run-pass/unique-in-vec.rs | 2 +- src/test/run-pass/vec-concat.rs | 11 +- src/test/run-pass/vec-growth.rs | 10 +- src/test/run-pass/vec-late-init.rs | 2 +- src/test/run-pass/vec.rs | 12 +- 337 files changed, 1330 insertions(+), 4248 deletions(-) delete mode 100644 src/libsync/comm/duplex.rs delete mode 100644 src/libsyntax/crateid.rs delete mode 100644 src/test/compile-fail-fulldeps/syntax-extension-fourcc-bad-len.rs delete mode 100644 src/test/compile-fail-fulldeps/syntax-extension-fourcc-invalid-endian.rs delete mode 100644 src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-ascii-str.rs delete mode 100644 src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-literal.rs delete mode 100644 src/test/compile-fail-fulldeps/syntax-extension-fourcc-unsupported-literal.rs delete mode 100644 src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-lits.rs delete mode 100644 src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-types.rs delete mode 100644 src/test/compile-fail/deprecated-url.rs delete mode 100644 src/test/run-pass-fulldeps/syntax-extension-fourcc.rs delete mode 100644 src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs diff --git a/src/libcollections/dlist.rs b/src/libcollections/dlist.rs index 088784070e715..e751084addd77 100644 --- a/src/libcollections/dlist.rs +++ b/src/libcollections/dlist.rs @@ -475,12 +475,6 @@ impl DList { Items{nelem: self.len(), head: &self.list_head, tail: self.list_tail} } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> { - self.iter_mut() - } - /// Provides a forward iterator with mutable references. #[inline] pub fn iter_mut<'a>(&'a mut self) -> MutItems<'a, T> { @@ -496,12 +490,6 @@ impl DList { } } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> MoveItems { - self.into_iter() - } - /// Consumes the list into an iterator yielding elements by value. #[inline] pub fn into_iter(self) -> MoveItems { @@ -870,7 +858,8 @@ mod tests { let mut m = list_from(v.as_slice()); m.append(list_from(u.as_slice())); check_links(&m); - let sum = v.append(u.as_slice()); + let mut sum = v; + sum.push_all(u.as_slice()); assert_eq!(sum.len(), m.len()); for elt in sum.into_iter() { assert_eq!(m.pop_front(), Some(elt)) diff --git a/src/libcollections/lib.rs b/src/libcollections/lib.rs index 9f9894348203b..fa85d431b5485 100644 --- a/src/libcollections/lib.rs +++ b/src/libcollections/lib.rs @@ -502,40 +502,6 @@ pub trait Deque : MutableSeq { /// ``` fn push_front(&mut self, elt: T); - /// Inserts an element last in the sequence. - /// - /// # Example - /// - /// ```ignore - /// use std::collections::{DList, Deque}; - /// - /// let mut d = DList::new(); - /// d.push_back(1i); - /// d.push_back(2i); - /// assert_eq!(d.front(), Some(&1i)); - /// ``` - #[deprecated = "use the `push` method"] - fn push_back(&mut self, elt: T) { self.push(elt) } - - /// Removes the last element and returns it, or `None` if the sequence is - /// empty. - /// - /// # Example - /// - /// ```ignore - /// use std::collections::{RingBuf, Deque}; - /// - /// let mut d = RingBuf::new(); - /// d.push_back(1i); - /// d.push_back(2i); - /// - /// assert_eq!(d.pop_back(), Some(2i)); - /// assert_eq!(d.pop_back(), Some(1i)); - /// assert_eq!(d.pop_back(), None); - /// ``` - #[deprecated = "use the `pop` method"] - fn pop_back(&mut self) -> Option { self.pop() } - /// Removes the first element and returns it, or `None` if the sequence is /// empty. /// diff --git a/src/libcollections/priority_queue.rs b/src/libcollections/priority_queue.rs index 68e2086d042a3..16e04b93777f2 100644 --- a/src/libcollections/priority_queue.rs +++ b/src/libcollections/priority_queue.rs @@ -269,9 +269,6 @@ impl PriorityQueue { if self.is_empty() { None } else { Some(&self.data[0]) } } - #[deprecated="renamed to `top`"] - pub fn maybe_top<'a>(&'a self) -> Option<&'a T> { self.top() } - /// Returns the number of elements the queue can hold without reallocating. /// /// # Example @@ -341,9 +338,6 @@ impl PriorityQueue { } } - #[deprecated="renamed to `pop`"] - pub fn maybe_pop(&mut self) -> Option { self.pop() } - /// Pushes an item onto the queue. /// /// # Example @@ -417,14 +411,6 @@ impl PriorityQueue { } } - #[allow(dead_code)] - #[deprecated="renamed to `into_vec`"] - fn to_vec(self) -> Vec { self.into_vec() } - - #[allow(dead_code)] - #[deprecated="renamed to `into_sorted_vec`"] - fn to_sorted_vec(self) -> Vec { self.into_sorted_vec() } - /// Consumes the `PriorityQueue` and returns the underlying vector /// in arbitrary order. /// diff --git a/src/libcollections/ringbuf.rs b/src/libcollections/ringbuf.rs index 1ae63d11fbe8d..e32e8145d172e 100644 --- a/src/libcollections/ringbuf.rs +++ b/src/libcollections/ringbuf.rs @@ -19,6 +19,7 @@ use core::cmp; use core::default::Default; use core::fmt; use core::iter; +use core::slice; use std::hash::{Writer, Hash}; use {Deque, Mutable, MutableSeq}; @@ -132,32 +133,6 @@ impl RingBuf { elts: Vec::from_fn(cmp::max(MINIMUM_CAPACITY, n), |_| None)} } - /// Retrieve an element in the `RingBuf` by index. - /// - /// Fails if there is no element with the given index. - /// - /// # Example - /// - /// ```rust - /// #![allow(deprecated)] - /// - /// use std::collections::RingBuf; - /// - /// let mut buf = RingBuf::new(); - /// buf.push(3i); - /// buf.push(4); - /// buf.push(5); - /// assert_eq!(buf.get(1), &4); - /// ``` - #[deprecated = "prefer using indexing, e.g., ringbuf[0]"] - pub fn get<'a>(&'a self, i: uint) -> &'a T { - let idx = self.raw_index(i); - match self.elts[idx] { - None => fail!(), - Some(ref v) => v - } - } - /// Retrieves an element in the `RingBuf` by index. /// /// Fails if there is no element with the given index. @@ -250,12 +225,6 @@ impl RingBuf { Items{index: 0, rindex: self.nelts, lo: self.lo, elts: self.elts.as_slice()} } - /// Deprecated: use `iter_mut` - #[deprecated = "use iter_mut"] - pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a, T> { - self.iter_mut() - } - /// Returns a front-to-back iterator which returns mutable references. /// /// # Example @@ -285,16 +254,20 @@ impl RingBuf { // 0 to end_index let (temp, remaining1) = self.elts.split_at_mut(start_index); let (remaining2, _) = temp.split_at_mut(end_index); - MutItems { remaining1: remaining1, - remaining2: remaining2, - nelts: self.nelts } + MutItems { + remaining1: remaining1.iter_mut(), + remaining2: remaining2.iter_mut(), + nelts: self.nelts, + } } else { // Items to iterate goes from start_index to end_index: let (empty, elts) = self.elts.split_at_mut(0); let remaining1 = elts[mut start_index..end_index]; - MutItems { remaining1: remaining1, - remaining2: empty, - nelts: self.nelts } + MutItems { + remaining1: remaining1.iter_mut(), + remaining2: empty.iter_mut(), + nelts: self.nelts, + } } } } @@ -356,26 +329,26 @@ impl<'a, T> RandomAccessIterator<&'a T> for Items<'a, T> { /// `RingBuf` mutable iterator. pub struct MutItems<'a, T:'a> { - remaining1: &'a mut [Option], - remaining2: &'a mut [Option], + remaining1: slice::MutItems<'a, Option>, + remaining2: slice::MutItems<'a, Option>, nelts: uint, } impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> { #[inline] - #[allow(deprecated)] // mut_shift_ref fn next(&mut self) -> Option<&'a mut T> { if self.nelts == 0 { return None; } - let r = if self.remaining1.len() > 0 { - &mut self.remaining1 - } else { - assert!(self.remaining2.len() > 0); - &mut self.remaining2 - }; self.nelts -= 1; - Some(r.mut_shift_ref().unwrap().get_mut_ref()) + match self.remaining1.next() { + Some(ptr) => return Some(ptr.as_mut().unwrap()), + None => {} + } + match self.remaining2.next() { + Some(ptr) => return Some(ptr.as_mut().unwrap()), + None => unreachable!(), + } } #[inline] @@ -386,19 +359,19 @@ impl<'a, T> Iterator<&'a mut T> for MutItems<'a, T> { impl<'a, T> DoubleEndedIterator<&'a mut T> for MutItems<'a, T> { #[inline] - #[allow(deprecated)] // mut_shift_ref fn next_back(&mut self) -> Option<&'a mut T> { if self.nelts == 0 { return None; } - let r = if self.remaining2.len() > 0 { - &mut self.remaining2 - } else { - assert!(self.remaining1.len() > 0); - &mut self.remaining1 - }; self.nelts -= 1; - Some(r.mut_pop_ref().unwrap().get_mut_ref()) + match self.remaining2.next_back() { + Some(ptr) => return Some(ptr.as_mut().unwrap()), + None => {} + } + match self.remaining1.next_back() { + Some(ptr) => return Some(ptr.as_mut().unwrap()), + None => unreachable!(), + } } } @@ -484,9 +457,12 @@ impl> Hash for RingBuf { impl Index for RingBuf { #[inline] - #[allow(deprecated)] fn index<'a>(&'a self, i: &uint) -> &'a A { - self.get(*i) + let idx = self.raw_index(*i); + match self.elts[idx] { + None => fail!(), + Some(ref v) => v, + } } } @@ -576,14 +552,14 @@ mod tests { assert_eq!(d.len(), 3u); d.push_front(1); assert_eq!(d.len(), 4u); - debug!("{}", d.get(0)); - debug!("{}", d.get(1)); - debug!("{}", d.get(2)); - debug!("{}", d.get(3)); - assert_eq!(*d.get(0), 1); - assert_eq!(*d.get(1), 2); - assert_eq!(*d.get(2), 3); - assert_eq!(*d.get(3), 4); + debug!("{}", d[0]); + debug!("{}", d[1]); + debug!("{}", d[2]); + debug!("{}", d[3]); + assert_eq!(d[0], 1); + assert_eq!(d[1], 2); + assert_eq!(d[2], 3); + assert_eq!(d[3], 4); } #[cfg(test)] diff --git a/src/libcollections/slice.rs b/src/libcollections/slice.rs index 049bc231be39d..d061e60a42265 100644 --- a/src/libcollections/slice.rs +++ b/src/libcollections/slice.rs @@ -270,23 +270,6 @@ impl Iterator> for Permutations { pub trait CloneableVector { /// Copies `self` into a new `Vec`. fn to_vec(&self) -> Vec; - - /// Deprecated. Use `to_vec`. - #[deprecated = "Replaced by `to_vec`"] - fn to_owned(&self) -> Vec { - self.to_vec() - } - - /// Converts `self` into an owned vector, not making a copy if possible. - /// Deprecated. Use 'to_vec' - #[deprecated = "Replaced by `to_vec`"] - fn into_vec(self) -> Vec; - - /// Deprecated. Use `to_vec` - #[deprecated = "Replaced by `to_vec`"] - fn into_owned(self) -> Vec { - self.to_vec() - } } impl<'a, T: Clone> CloneableVector for &'a [T] { @@ -297,9 +280,6 @@ impl<'a, T: Clone> CloneableVector for &'a [T] { vector.push_all(*self); vector } - - #[inline(always)] - fn into_vec(self) -> Vec { self.to_vec() } } #[experimental] @@ -920,25 +900,6 @@ mod tests { a.as_mut_slice().tail_mut(); } - #[test] - #[allow(deprecated)] - fn test_tailn() { - let mut a = vec![11i, 12, 13]; - let b: &mut [int] = &mut [11, 12, 13]; - assert!(a.tailn(0) == b); - a = vec![11i, 12, 13]; - let b: &mut [int] = &mut [13]; - assert!(a.tailn(2) == b); - } - - #[test] - #[should_fail] - #[allow(deprecated)] - fn test_tailn_empty() { - let a: Vec = vec![]; - a.tailn(2); - } - #[test] fn test_init() { let mut a = vec![11i]; @@ -973,25 +934,6 @@ mod tests { a.as_mut_slice().init_mut(); } - #[test] - #[allow(deprecated)] - fn test_initn() { - let mut a = vec![11i, 12, 13]; - let b: &[int] = &[11, 12, 13]; - assert_eq!(a.as_slice().initn(0), b); - a = vec![11i, 12, 13]; - let b: &[int] = &[11]; - assert_eq!(a.as_slice().initn(2), b); - } - - #[test] - #[should_fail] - #[allow(deprecated)] - fn test_initn_empty() { - let a: Vec = vec![]; - a.as_slice().initn(2); - } - #[test] fn test_last() { let mut a = vec![]; @@ -1156,20 +1098,6 @@ mod tests { assert_eq!(v[2], 4u); } - #[test] - #[allow(deprecated)] - fn test_grow_set() { - let mut v = vec![1i, 2, 3]; - v.grow_set(4u, &4, 5); - let v = v.as_slice(); - assert_eq!(v.len(), 5u); - assert_eq!(v[0], 1); - assert_eq!(v[1], 2); - assert_eq!(v[2], 3); - assert_eq!(v[3], 4); - assert_eq!(v[4], 5); - } - #[test] fn test_truncate() { let mut v = vec![box 6i,box 5,box 4]; @@ -1385,49 +1313,48 @@ mod tests { } #[test] - #[allow(deprecated)] - fn test_bsearch_elem() { - assert_eq!([1i,2,3,4,5].bsearch_elem(&5), Some(4)); - assert_eq!([1i,2,3,4,5].bsearch_elem(&4), Some(3)); - assert_eq!([1i,2,3,4,5].bsearch_elem(&3), Some(2)); - assert_eq!([1i,2,3,4,5].bsearch_elem(&2), Some(1)); - assert_eq!([1i,2,3,4,5].bsearch_elem(&1), Some(0)); + fn test_binary_search_elem() { + assert_eq!([1i,2,3,4,5].binary_search_elem(&5).found(), Some(4)); + assert_eq!([1i,2,3,4,5].binary_search_elem(&4).found(), Some(3)); + assert_eq!([1i,2,3,4,5].binary_search_elem(&3).found(), Some(2)); + assert_eq!([1i,2,3,4,5].binary_search_elem(&2).found(), Some(1)); + assert_eq!([1i,2,3,4,5].binary_search_elem(&1).found(), Some(0)); - assert_eq!([2i,4,6,8,10].bsearch_elem(&1), None); - assert_eq!([2i,4,6,8,10].bsearch_elem(&5), None); - assert_eq!([2i,4,6,8,10].bsearch_elem(&4), Some(1)); - assert_eq!([2i,4,6,8,10].bsearch_elem(&10), Some(4)); + assert_eq!([2i,4,6,8,10].binary_search_elem(&1).found(), None); + assert_eq!([2i,4,6,8,10].binary_search_elem(&5).found(), None); + assert_eq!([2i,4,6,8,10].binary_search_elem(&4).found(), Some(1)); + assert_eq!([2i,4,6,8,10].binary_search_elem(&10).found(), Some(4)); - assert_eq!([2i,4,6,8].bsearch_elem(&1), None); - assert_eq!([2i,4,6,8].bsearch_elem(&5), None); - assert_eq!([2i,4,6,8].bsearch_elem(&4), Some(1)); - assert_eq!([2i,4,6,8].bsearch_elem(&8), Some(3)); + assert_eq!([2i,4,6,8].binary_search_elem(&1).found(), None); + assert_eq!([2i,4,6,8].binary_search_elem(&5).found(), None); + assert_eq!([2i,4,6,8].binary_search_elem(&4).found(), Some(1)); + assert_eq!([2i,4,6,8].binary_search_elem(&8).found(), Some(3)); - assert_eq!([2i,4,6].bsearch_elem(&1), None); - assert_eq!([2i,4,6].bsearch_elem(&5), None); - assert_eq!([2i,4,6].bsearch_elem(&4), Some(1)); - assert_eq!([2i,4,6].bsearch_elem(&6), Some(2)); + assert_eq!([2i,4,6].binary_search_elem(&1).found(), None); + assert_eq!([2i,4,6].binary_search_elem(&5).found(), None); + assert_eq!([2i,4,6].binary_search_elem(&4).found(), Some(1)); + assert_eq!([2i,4,6].binary_search_elem(&6).found(), Some(2)); - assert_eq!([2i,4].bsearch_elem(&1), None); - assert_eq!([2i,4].bsearch_elem(&5), None); - assert_eq!([2i,4].bsearch_elem(&2), Some(0)); - assert_eq!([2i,4].bsearch_elem(&4), Some(1)); + assert_eq!([2i,4].binary_search_elem(&1).found(), None); + assert_eq!([2i,4].binary_search_elem(&5).found(), None); + assert_eq!([2i,4].binary_search_elem(&2).found(), Some(0)); + assert_eq!([2i,4].binary_search_elem(&4).found(), Some(1)); - assert_eq!([2i].bsearch_elem(&1), None); - assert_eq!([2i].bsearch_elem(&5), None); - assert_eq!([2i].bsearch_elem(&2), Some(0)); + assert_eq!([2i].binary_search_elem(&1).found(), None); + assert_eq!([2i].binary_search_elem(&5).found(), None); + assert_eq!([2i].binary_search_elem(&2).found(), Some(0)); - assert_eq!([].bsearch_elem(&1i), None); - assert_eq!([].bsearch_elem(&5i), None); + assert_eq!([].binary_search_elem(&1i).found(), None); + assert_eq!([].binary_search_elem(&5i).found(), None); - assert!([1i,1,1,1,1].bsearch_elem(&1) != None); - assert!([1i,1,1,1,2].bsearch_elem(&1) != None); - assert!([1i,1,1,2,2].bsearch_elem(&1) != None); - assert!([1i,1,2,2,2].bsearch_elem(&1) != None); - assert_eq!([1i,2,2,2,2].bsearch_elem(&1), Some(0)); + assert!([1i,1,1,1,1].binary_search_elem(&1).found() != None); + assert!([1i,1,1,1,2].binary_search_elem(&1).found() != None); + assert!([1i,1,1,2,2].binary_search_elem(&1).found() != None); + assert!([1i,1,2,2,2].binary_search_elem(&1).found() != None); + assert_eq!([1i,2,2,2,2].binary_search_elem(&1).found(), Some(0)); - assert_eq!([1i,2,3,4,5].bsearch_elem(&6), None); - assert_eq!([1i,2,3,4,5].bsearch_elem(&0), None); + assert_eq!([1i,2,3,4,5].binary_search_elem(&6).found(), None); + assert_eq!([1i,2,3,4,5].binary_search_elem(&0).found(), None); } #[test] @@ -1544,26 +1471,6 @@ mod tests { assert_eq!(v.connect_vec(&0), vec![1, 0, 2, 0, 3]); } - #[test] - #[allow(deprecated)] - fn test_shift() { - let mut x = vec![1i, 2, 3]; - assert_eq!(x.shift(), Some(1)); - assert_eq!(&x, &vec![2i, 3]); - assert_eq!(x.shift(), Some(2)); - assert_eq!(x.shift(), Some(3)); - assert_eq!(x.shift(), None); - assert_eq!(x.len(), 0); - } - - #[test] - #[allow(deprecated)] - fn test_unshift() { - let mut x = vec![1i, 2, 3]; - x.unshift(0); - assert_eq!(x, vec![0, 1, 2, 3]); - } - #[test] fn test_insert() { let mut a = vec![1i, 2, 4]; @@ -1689,17 +1596,6 @@ mod tests { } } - #[test] - #[should_fail] - #[allow(deprecated)] - fn test_copy_memory_oob() { - unsafe { - let mut a = [1i, 2, 3, 4]; - let b = [1i, 2, 3, 4, 5]; - a.copy_memory(b); - } - } - #[test] fn test_total_ord() { let c: &[int] = &[1, 2, 3]; @@ -2005,19 +1901,6 @@ mod tests { assert!(a == [1i,2,6,7,5]); } - #[test] - #[allow(deprecated)] - fn test_copy_from() { - let mut a = [1i,2,3,4,5]; - let b = [6i,7,8]; - assert_eq!(a.copy_from(b), 3); - assert!(a == [6i,7,8,4,5]); - let mut c = [7i,2,8,1]; - let d = [3i,1,4,1,5,9]; - assert_eq!(c.copy_from(d), 4); - assert!(c == [3i,1,4,1]); - } - #[test] fn test_reverse_part() { let mut values = [1i,2,3,4,5]; @@ -2198,34 +2081,6 @@ mod tests { assert!(b"foobar".ends_with(empty)); } - #[test] - #[allow(deprecated)] - fn test_shift_ref() { - let mut x: &[int] = [1, 2, 3, 4, 5]; - let h = x.shift_ref(); - assert_eq!(*h.unwrap(), 1); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 2); - assert_eq!(x[3], 5); - - let mut y: &[int] = []; - assert_eq!(y.shift_ref(), None); - } - - #[test] - #[allow(deprecated)] - fn test_pop_ref() { - let mut x: &[int] = [1, 2, 3, 4, 5]; - let h = x.pop_ref(); - assert_eq!(*h.unwrap(), 5); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 1); - assert_eq!(x[3], 4); - - let mut y: &[int] = []; - assert!(y.pop_ref().is_none()); - } - #[test] fn test_mut_splitator() { let mut xs = [0i,1,0,2,3,0,0,4,5,0]; @@ -2292,34 +2147,6 @@ mod tests { let _it = v.chunks_mut(0); } - #[test] - #[allow(deprecated)] - fn test_mut_shift_ref() { - let mut x: &mut [int] = [1, 2, 3, 4, 5]; - let h = x.mut_shift_ref(); - assert_eq!(*h.unwrap(), 1); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 2); - assert_eq!(x[3], 5); - - let mut y: &mut [int] = []; - assert!(y.mut_shift_ref().is_none()); - } - - #[test] - #[allow(deprecated)] - fn test_mut_pop_ref() { - let mut x: &mut [int] = [1, 2, 3, 4, 5]; - let h = x.mut_pop_ref(); - assert_eq!(*h.unwrap(), 5); - assert_eq!(x.len(), 4); - assert_eq!(x[0], 1); - assert_eq!(x[3], 4); - - let mut y: &mut [int] = []; - assert!(y.mut_pop_ref().is_none()); - } - #[test] fn test_mut_last() { let mut x = [1i, 2, 3, 4, 5]; diff --git a/src/libcollections/smallintmap.rs b/src/libcollections/smallintmap.rs index 94dbf84a4b4b9..498f86a8bf1e4 100644 --- a/src/libcollections/smallintmap.rs +++ b/src/libcollections/smallintmap.rs @@ -199,29 +199,6 @@ impl SmallIntMap { SmallIntMap { v: Vec::with_capacity(capacity) } } - /// Retrieves a value for the given key. - /// See [`find`](../trait.Map.html#tymethod.find) for a non-failing alternative. - /// - /// # Failure - /// - /// Fails if the key is not present. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// - /// use std::collections::SmallIntMap; - /// - /// let mut map = SmallIntMap::new(); - /// map.insert(1, "a"); - /// assert_eq!(map.get(&1), &"a"); - /// ``` - #[deprecated = "prefer using indexing, e.g., map[0]"] - pub fn get<'a>(&'a self, key: &uint) -> &'a V { - self.find(key).expect("key not present") - } - /// Returns an iterator visiting all keys in ascending order by the keys. /// The iterator's element type is `uint`. pub fn keys<'r>(&'r self) -> Keys<'r, V> { @@ -260,12 +237,6 @@ impl SmallIntMap { } } - /// Deprecated: use `iter_mut` - #[deprecated = "use iter_mut"] - pub fn mut_iter<'r>(&'r mut self) -> MutEntries<'r, V> { - self.iter_mut() - } - /// Returns an iterator visiting all key-value pairs in ascending order by the keys, /// with mutable references to the values. /// The iterator's element type is `(uint, &'r mut V)`. @@ -296,14 +267,6 @@ impl SmallIntMap { } } - /// Deprecated: use `into_iter` instead. - #[deprecated = "use into_iter"] - pub fn move_iter(&mut self) - -> FilterMap<(uint, Option), (uint, V), - Enumerate>>> { - self.into_iter() - } - /// Returns an iterator visiting all key-value pairs in ascending order by /// the keys, emptying (but not consuming) the original `SmallIntMap`. /// The iterator's element type is `(uint, &'r V)`. @@ -437,9 +400,8 @@ impl Extendable<(uint, V)> for SmallIntMap { impl Index for SmallIntMap { #[inline] - #[allow(deprecated)] fn index<'a>(&'a self, i: &uint) -> &'a V { - self.get(i) + self.find(i).expect("key not present") } } diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index f49371b8e8862..901f8add73c1a 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -58,7 +58,6 @@ use core::default::Default; use core::fmt; use core::cmp; use core::iter::AdditiveIterator; -use core::mem; use core::prelude::{Char, Clone, Collection, Eq, Equiv, ImmutableSlice}; use core::prelude::{Iterator, MutableSlice, None, Option, Ord, Ordering}; use core::prelude::{PartialEq, PartialOrd, Result, AsSlice, Some, Tuple2}; @@ -67,7 +66,6 @@ use core::prelude::{range}; use {Deque, MutableSeq}; use hash; use ringbuf::RingBuf; -use slice::CloneableVector; use string::String; use unicode; use vec::Vec; @@ -85,31 +83,6 @@ pub use unicode::str::{UnicodeStrSlice, Words, Graphemes, GraphemeIndices}; Section: Creating a string */ -/// Deprecated. Replaced by `String::from_utf8`. -#[deprecated = "Replaced by `String::from_utf8`"] -pub fn from_utf8_owned(vv: Vec) -> Result> { - String::from_utf8(vv) -} - -/// Deprecated. Replaced by `String::from_byte`. -#[deprecated = "Replaced by String::from_byte"] -pub fn from_byte(b: u8) -> String { - assert!(b < 128u8); - String::from_char(1, b as char) -} - -/// Deprecated. Use `String::from_char` or `char::to_string()` instead. -#[deprecated = "use String::from_char or char.to_string()"] -pub fn from_char(ch: char) -> String { - String::from_char(1, ch) -} - -/// Deprecated. Replaced by `String::from_chars`. -#[deprecated = "use String::from_chars instead"] -pub fn from_chars(chs: &[char]) -> String { - chs.iter().map(|c| *c).collect() -} - /// Methods for vectors of strings. pub trait StrVector { /// Concatenates a vector of strings. @@ -427,18 +400,6 @@ pub fn replace(s: &str, from: &str, to: &str) -> String { Section: Misc */ -/// Deprecated. Use `String::from_utf16`. -#[deprecated = "Replaced by String::from_utf16"] -pub fn from_utf16(v: &[u16]) -> Option { - String::from_utf16(v) -} - -/// Deprecated. Use `String::from_utf16_lossy`. -#[deprecated = "Replaced by String::from_utf16_lossy"] -pub fn from_utf16_lossy(v: &[u16]) -> String { - String::from_utf16_lossy(v) -} - // Return the initial codepoint accumulator for the first byte. // The first byte is special, only want bottom 5 bits for width 2, 4 bits // for width 3, and 3 bits for width 4 @@ -451,12 +412,6 @@ macro_rules! utf8_acc_cont_byte( ($ch:expr, $byte:expr) => (($ch << 6) | ($byte & 63u8) as u32) ) -/// Deprecated. Use `String::from_utf8_lossy`. -#[deprecated = "Replaced by String::from_utf8_lossy"] -pub fn from_utf8_lossy<'a>(v: &'a [u8]) -> MaybeOwned<'a> { - String::from_utf8_lossy(v) -} - /* Section: MaybeOwned */ @@ -644,38 +599,8 @@ impl<'a> fmt::Show for MaybeOwned<'a> { /// Unsafe string operations. pub mod raw { - use string; - use string::String; - use vec::Vec; - - use MutableSeq; - pub use core::str::raw::{from_utf8, c_str_to_static_slice, slice_bytes}; pub use core::str::raw::{slice_unchecked}; - - /// Deprecated. Replaced by `string::raw::from_buf_len` - #[deprecated = "Use string::raw::from_buf_len"] - pub unsafe fn from_buf_len(buf: *const u8, len: uint) -> String { - string::raw::from_buf_len(buf, len) - } - - /// Deprecated. Use `string::raw::from_buf` - #[deprecated = "Use string::raw::from_buf"] - pub unsafe fn from_c_str(c_string: *const i8) -> String { - string::raw::from_buf(c_string as *const u8) - } - - /// Deprecated. Replaced by `string::raw::from_utf8` - #[deprecated = "Use string::raw::from_utf8"] - pub unsafe fn from_utf8_owned(v: Vec) -> String { - string::raw::from_utf8(v) - } - - /// Deprecated. Use `string::raw::from_utf8` - #[deprecated = "Use string::raw::from_utf8"] - pub unsafe fn from_byte(u: u8) -> String { - string::raw::from_utf8(vec![u]) - } } /* @@ -687,12 +612,6 @@ pub trait StrAllocating: Str { /// Converts `self` into a `String`, not making a copy if possible. fn into_string(self) -> String; - #[allow(missing_doc)] - #[deprecated = "replaced by .into_string()"] - fn into_owned(self) -> String { - self.into_string() - } - /// Escapes each char in `s` with `char::escape_default`. fn escape_default(&self) -> String { let me = self.as_slice(); @@ -750,21 +669,6 @@ pub trait StrAllocating: Str { result } - #[allow(missing_doc)] - #[deprecated = "obsolete, use `to_string`"] - #[inline] - fn to_owned(&self) -> String { - unsafe { - mem::transmute(self.as_slice().as_bytes().to_vec()) - } - } - - /// Converts to a vector of `u16` encoded as UTF-16. - #[deprecated = "use `utf16_units` instead"] - fn to_utf16(&self) -> Vec { - self.as_slice().utf16_units().collect::>() - } - /// Given a string, makes a new string with repeated copies of it. fn repeat(&self, nn: uint) -> String { let me = self.as_slice(); diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index 061064ff803d5..fa45dee7cdea7 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -84,20 +84,6 @@ impl String { String { vec: string.as_bytes().to_vec() } } - /// Deprecated. Replaced by `string::raw::from_parts` - #[inline] - #[deprecated = "Replaced by string::raw::from_parts"] - pub unsafe fn from_raw_parts(length: uint, capacity: uint, ptr: *mut u8) -> String { - raw::from_parts(ptr, length, capacity) - } - - /// Deprecated. - #[deprecated = "obsoleted by the removal of ~str"] - #[inline] - pub fn from_owned_str(string: String) -> String { - string - } - /// Returns the vector as a string buffer, if possible, taking care not to /// copy it. /// @@ -327,26 +313,6 @@ impl String { self.vec } - /// Pushes the given `String` onto this buffer then returns `self` so that it can be - /// used again. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let s = String::from_str("hello"); - /// let big = s.append(" ").append("world").append("!"); - /// // s has now been moved and cannot be used - /// - /// assert_eq!(big.as_slice(), "hello world!"); - /// ``` - #[inline] - #[deprecated = "use .push_str() instead"] - pub fn append(mut self, second: &str) -> String { - self.push_str(second); - self - } - /// Creates a string buffer by repeating a character `length` times. /// /// # Example @@ -373,25 +339,6 @@ impl String { buf } - /// Converts a byte to a UTF-8 string. - /// - /// # Failure - /// - /// Fails with invalid UTF-8 (i.e., the byte is greater than 127). - /// - /// # Example - /// - /// ```rust - /// # #![allow(deprecated)] - /// let s = String::from_byte(104); - /// assert_eq!(s.as_slice(), "h"); - /// ``` - #[deprecated = "use str::from_utf8 with a slice of one byte instead"] - pub fn from_byte(b: u8) -> String { - assert!(b < 128u8); - String::from_char(1, b as char) - } - /// Pushes the given string onto this string buffer. /// /// # Example @@ -424,21 +371,6 @@ impl String { } } - /// Returns the number of bytes that this string buffer can hold without reallocating. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let s = String::with_capacity(10); - /// assert!(s.byte_capacity() >= 10); - /// ``` - #[inline] - #[deprecated = "renamed to .capacity()"] - pub fn byte_capacity(&self) -> uint { - self.vec.capacity() - } - /// Returns the number of bytes that this string buffer can hold without reallocating. /// /// # Example @@ -512,13 +444,6 @@ impl String { self.vec.shrink_to_fit() } - /// Deprecated, use .push() instead. - #[inline] - #[deprecated = "renamed to .push()"] - pub fn push_char(&mut self, ch: char) { - self.push(ch) - } - /// Adds the given character to the end of the string. /// /// # Example @@ -549,26 +474,6 @@ impl String { } } - /// Pushes the given bytes onto this string buffer. - /// This is unsafe because it does not check - /// to ensure that the resulting string will be valid UTF-8. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let mut s = String::new(); - /// unsafe { - /// s.push_bytes([104, 101, 108, 108, 111]); - /// } - /// assert_eq!(s.as_slice(), "hello"); - /// ``` - #[inline] - #[deprecated = "call .as_mut_vec() and push onto that"] - pub unsafe fn push_bytes(&mut self, bytes: &[u8]) { - self.vec.push_all(bytes) - } - /// Works with the underlying buffer as a byte slice. /// /// # Example @@ -584,31 +489,6 @@ impl String { self.vec.as_slice() } - /// Works with the underlying buffer as a mutable byte slice. - /// - /// This is unsafe because it does not check - /// to ensure that the resulting string will be valid UTF-8. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let mut s = String::from_str("hello"); - /// unsafe { - /// let bytes = s.as_mut_bytes(); - /// bytes[1] = 51; - /// bytes[4] = 48; - /// } - /// let b: &[_] = &[104, 51, 108, 108, 48]; - /// assert_eq!(s.as_bytes(), b); - /// assert_eq!(s.as_slice(), "h3ll0") - /// ``` - #[inline] - #[deprecated = "call .as_mut_vec().as_mut_slice() instead"] - pub unsafe fn as_mut_bytes<'a>(&'a mut self) -> &'a mut [u8] { - self.vec.as_mut_slice() - } - /// Shortens a string to the specified length. /// /// # Failure @@ -630,63 +510,6 @@ impl String { self.vec.truncate(new_len) } - /// Appends a byte to this string buffer. - /// - /// This is unsafe because it does not check - /// to ensure that the resulting string will be valid UTF-8. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let mut s = String::from_str("hell"); - /// unsafe { - /// s.push_byte(111); - /// } - /// assert_eq!(s.as_slice(), "hello"); - /// ``` - #[inline] - #[deprecated = "call .as_mut_vec().push() instead"] - pub unsafe fn push_byte(&mut self, byte: u8) { - self.vec.push(byte) - } - - /// Removes the last byte from the string buffer and returns it. - /// Returns `None` if this string buffer is empty. - /// - /// This is unsafe because it does not check - /// to ensure that the resulting string will be valid UTF-8. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let mut s = String::from_str("foo"); - /// unsafe { - /// assert_eq!(s.pop_byte(), Some(111)); - /// assert_eq!(s.pop_byte(), Some(111)); - /// assert_eq!(s.pop_byte(), Some(102)); - /// assert_eq!(s.pop_byte(), None); - /// } - /// ``` - #[inline] - #[deprecated = "call .as_mut_vec().pop() instead"] - pub unsafe fn pop_byte(&mut self) -> Option { - let len = self.len(); - if len == 0 { - return None - } - - let byte = self.as_bytes()[len - 1]; - self.vec.set_len(len - 1); - Some(byte) - } - - /// Deprecated. Renamed to `pop`. - #[inline] - #[deprecated = "renamed to .pop()"] - pub fn pop_char(&mut self) -> Option { self.pop() } - /// Removes the last character from the string buffer and returns it. /// Returns `None` if this string buffer is empty. /// @@ -714,35 +537,6 @@ impl String { Some(ch) } - /// Removes the first byte from the string buffer and returns it. - /// Returns `None` if this string buffer is empty. - /// - /// This is unsafe because it does not check - /// to ensure that the resulting string will be valid UTF-8. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let mut s = String::from_str("foo"); - /// unsafe { - /// assert_eq!(s.shift_byte(), Some(102)); - /// assert_eq!(s.shift_byte(), Some(111)); - /// assert_eq!(s.shift_byte(), Some(111)); - /// assert_eq!(s.shift_byte(), None); - /// } - /// ``` - #[deprecated = "call .as_mut_vec().remove(0)"] - pub unsafe fn shift_byte(&mut self) -> Option { - self.vec.remove(0) - } - - /// Deprecated, call `remove(0)` instead - #[deprecated = "call .remove(0) instead"] - pub fn shift_char(&mut self) -> Option { - self.remove(0) - } - /// Removes the character from the string buffer at byte position `idx` and /// returns it. Returns `None` if `idx` is out of bounds. /// @@ -1251,18 +1045,6 @@ mod tests { assert_eq!(data.as_slice(), "ประเทศไทย中"); } - #[test] - #[allow(deprecated)] // use remove(0) instead - fn test_shift_char() { - let mut data = String::from_str("𤭢€¢b华ประเทศไทย中"); - assert_eq!(data.shift_char().unwrap(), '𤭢'); // 4 bytes - assert_eq!(data.shift_char().unwrap(), '€'); // 3 bytes - assert_eq!(data.shift_char().unwrap(), '¢'); // 2 bytes - assert_eq!(data.shift_char().unwrap(), 'b'); // 1 bytes - assert_eq!(data.shift_char().unwrap(), '华'); - assert_eq!(data.as_slice(), "ประเทศไทย中"); - } - #[test] fn test_str_truncate() { let mut s = String::from_str("12345"); diff --git a/src/libcollections/treemap.rs b/src/libcollections/treemap.rs index a86e7386eddd8..39362bf1fdc00 100644 --- a/src/libcollections/treemap.rs +++ b/src/libcollections/treemap.rs @@ -361,12 +361,6 @@ impl TreeMap { RevEntries{iter: self.iter()} } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter<'a>(&'a mut self) -> MutEntries<'a, K, V> { - self.iter_mut() - } - /// Gets a lazy forward iterator over the key-value pairs in the /// map, with the values being mutable. /// @@ -398,12 +392,6 @@ impl TreeMap { } } - /// Deprecated: use `rev_iter_mut`. - #[deprecated = "use rev_iter_mut"] - pub fn mut_rev_iter<'a>(&'a mut self) -> RevMutEntries<'a, K, V> { - self.rev_iter_mut() - } - /// Gets a lazy reverse iterator over the key-value pairs in the /// map, with the values being mutable. /// @@ -430,12 +418,6 @@ impl TreeMap { RevMutEntries{iter: self.iter_mut()} } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> MoveEntries { - self.into_iter() - } - /// Gets a lazy iterator that consumes the treemap. /// /// # Example @@ -494,12 +476,6 @@ impl TreeMap { tree_find_with(&self.root, f) } - /// Deprecated: use `find_with_mut`. - #[deprecated = "use find_with_mut"] - pub fn find_mut_with<'a>(&'a mut self, f:|&K| -> Ordering) -> Option<&'a mut V> { - self.find_with_mut(f) - } - /// Returns the value for which `f(key)` returns `Equal`. `f` is invoked /// with current key and guides tree navigation. That means `f` should /// be aware of natural ordering of the tree. @@ -626,12 +602,6 @@ impl TreeMap { } } - /// Deprecated: use `lower_bound_mut`. - #[deprecated = "use lower_bound_mut"] - pub fn mut_lower_bound<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { - self.lower_bound_mut(k) - } - /// Returns a lazy value iterator to the first key-value pair (with /// the value being mutable) whose key is not less than `k`. /// @@ -666,12 +636,6 @@ impl TreeMap { bound_setup!(self.iter_mut_for_traversal(), k, true) } - /// Deprecated: use `upper_bound_mut`. - #[deprecated = "use upper_bound_mut"] - pub fn mut_upper_bound<'a>(&'a mut self, k: &K) -> MutEntries<'a, K, V> { - self.upper_bound_mut(k) - } - /// Returns a lazy iterator to the first key-value pair (with the /// value being mutable) whose key is greater than `k`. /// @@ -1204,12 +1168,6 @@ impl TreeSet { RevSetItems{iter: self.map.rev_iter()} } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> MoveSetItems { - self.into_iter() - } - /// Creates a consuming iterator, that is, one that moves each value out of the /// set in ascending order. The set cannot be used after calling this. /// diff --git a/src/libcollections/trie.rs b/src/libcollections/trie.rs index 2e388a92a59f4..1b5c5dbc0a20b 100644 --- a/src/libcollections/trie.rs +++ b/src/libcollections/trie.rs @@ -268,12 +268,6 @@ impl TrieMap { iter } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter<'a>(&'a mut self) -> MutEntries<'a, T> { - self.iter_mut() - } - /// Gets an iterator over the key-value pairs in the map, with the /// ability to mutate the values. /// @@ -439,12 +433,6 @@ impl TrieMap { mutability = mut) } - /// Deprecated: use `lower_bound_mut`. - #[deprecated = "use lower_bound_mut"] - pub fn mut_lower_bound<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { - self.lower_bound_mut(key) - } - /// Gets an iterator pointing to the first key-value pair whose key is not less than `key`. /// If all keys in the map are less than `key` an empty iterator is returned. /// @@ -470,12 +458,6 @@ impl TrieMap { self.bound_mut(key, false) } - /// Deprecated: use `upper_bound_mut`. - #[deprecated = "use upper_bound_mut"] - pub fn mut_upper_bound<'a>(&'a mut self, key: uint) -> MutEntries<'a, T> { - self.upper_bound_mut(key) - } - /// Gets an iterator pointing to the first key-value pair whose key is greater than `key`. /// If all keys in the map are not greater than `key` an empty iterator is returned. /// diff --git a/src/libcollections/vec.rs b/src/libcollections/vec.rs index 0bfdcee7f76f4..e608a7d22dcf5 100644 --- a/src/libcollections/vec.rs +++ b/src/libcollections/vec.rs @@ -275,19 +275,6 @@ impl Vec { } impl Vec { - /// Deprecated, call `extend` instead. - #[inline] - #[deprecated = "this function has been deprecated in favor of extend()"] - pub fn append(mut self, second: &[T]) -> Vec { - self.push_all(second); - self - } - - /// Deprecated, call `to_vec()` instead - #[inline] - #[deprecated = "this function has been deprecated in favor of to_vec()"] - pub fn from_slice(values: &[T]) -> Vec { values.to_vec() } - /// Constructs a `Vec` with copies of a value. /// /// Creates a `Vec` with `length` copies of `value`. @@ -366,31 +353,6 @@ impl Vec { } } - /// Sets the value of a vector element at a given index, growing the vector - /// as needed. - /// - /// Sets the element at position `index` to `value`. If `index` is past the - /// end of the vector, expands the vector by replicating `initval` to fill - /// the intervening space. - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let mut vec = vec!["a", "b", "c"]; - /// vec.grow_set(1, &("fill"), "d"); - /// vec.grow_set(4, &("fill"), "e"); - /// assert_eq!(vec, vec!["a", "d", "c", "fill", "e"]); - /// ``` - #[deprecated = "call .grow() and .push() manually instead"] - pub fn grow_set(&mut self, index: uint, initval: &T, value: T) { - let l = self.len(); - if index >= l { - self.grow(index - l + 1u, initval.clone()); - } - *self.get_mut(index) = value; - } - /// Partitions a vector based on a predicate. /// /// Clones the elements of the vector, partitioning them into two `Vec`s @@ -447,9 +409,8 @@ impl Clone for Vec { #[experimental = "waiting on Index stability"] impl Index for Vec { #[inline] - #[allow(deprecated)] // allow use of get fn index<'a>(&'a self, index: &uint) -> &'a T { - self.get(*index) + &self.as_slice()[*index] } } @@ -721,14 +682,6 @@ impl Vec { } } - /// Deprecated, call `push` instead - #[inline] - #[deprecated = "call .push() instead"] - pub fn append_one(mut self, x: T) -> Vec { - self.push(x); - self - } - /// Shorten a vector, dropping excess elements. /// /// If `len` is greater than the vector's current length, this has no @@ -754,6 +707,14 @@ impl Vec { } } + /// Deprecated, use `.extend(other.into_iter())` + #[inline] + #[deprecated = "use .extend(other.into_iter())"] + #[cfg(stage0)] + pub fn push_all_move(&mut self, other: Vec) { + self.extend(other.into_iter()); + } + /// Returns a mutable slice of the elements of `self`. /// /// # Example @@ -775,12 +736,6 @@ impl Vec { } } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> MoveItems { - self.into_iter() - } - /// Creates a consuming iterator, that is, one that moves each /// value out of the vector (from start to end). The vector cannot /// be used after calling this. @@ -830,26 +785,6 @@ impl Vec { self.len = len; } - /// Returns a reference to the value at index `index`. - /// - /// # Failure - /// - /// Fails if `index` is out of bounds - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// - /// let vec = vec![1i, 2, 3]; - /// assert!(vec.get(1) == &2); - /// ``` - #[deprecated="prefer using indexing, e.g., vec[0]"] - #[inline] - pub fn get<'a>(&'a self, index: uint) -> &'a T { - &self.as_slice()[index] - } - /// Returns a mutable reference to the value at index `index`. /// /// # Failure @@ -885,12 +820,6 @@ impl Vec { self.as_slice().iter() } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter<'a>(&'a mut self) -> MutItems<'a,T> { - self.iter_mut() - } - /// Returns an iterator over mutable references to the elements of the /// vector in order. /// @@ -963,25 +892,6 @@ impl Vec { self[].tail() } - /// Returns all but the first `n' elements of a vector. - /// - /// # Failure - /// - /// Fails when there are fewer than `n` elements in the vector. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// let vec = vec![1i, 2, 3, 4]; - /// assert!(vec.tailn(2) == [3, 4]); - /// ``` - #[inline] - #[deprecated = "use slice_from"] - pub fn tailn<'a>(&'a self, n: uint) -> &'a [T] { - self[n..] - } - /// Returns a reference to the last element of a vector, or `None` if it is /// empty. /// @@ -996,12 +906,6 @@ impl Vec { self[].last() } - /// Deprecated: use `last_mut`. - #[deprecated = "use last_mut"] - pub fn mut_last<'a>(&'a mut self) -> Option<&'a mut T> { - self.last_mut() - } - /// Returns a mutable reference to the last element of a vector, or `None` /// if it is empty. /// @@ -1047,48 +951,6 @@ impl Vec { self.pop() } - /// Prepends an element to the vector. - /// - /// # Warning - /// - /// This is an O(n) operation as it requires copying every element in the - /// vector. - /// - /// # Example - /// - /// ```ignore - /// let mut vec = vec![1i, 2, 3]; - /// vec.unshift(4); - /// assert_eq!(vec, vec![4, 1, 2, 3]); - /// ``` - #[inline] - #[deprecated = "use insert(0, ...)"] - pub fn unshift(&mut self, element: T) { - self.insert(0, element) - } - - /// Removes the first element from a vector and returns it, or `None` if - /// the vector is empty. - /// - /// # Warning - /// - /// This is an O(n) operation as it requires copying every element in the - /// vector. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// let mut vec = vec![1i, 2, 3]; - /// assert!(vec.shift() == Some(1)); - /// assert_eq!(vec, vec![2, 3]); - /// ``` - #[inline] - #[deprecated = "use remove(0)"] - pub fn shift(&mut self) -> Option { - self.remove(0) - } - /// Inserts an element at position `index` within the vector, shifting all /// elements after position `i` one position to the right. /// @@ -1167,32 +1029,6 @@ impl Vec { } } - /// Takes ownership of the vector `other`, moving all elements into - /// the current vector. This does not copy any elements, and it is - /// illegal to use the `other` vector after calling this method - /// (because it is moved here). - /// - /// # Example - /// - /// ``` - /// # #![allow(deprecated)] - /// let mut vec = vec![box 1i]; - /// vec.push_all_move(vec![box 2, box 3, box 4]); - /// assert_eq!(vec, vec![box 1, box 2, box 3, box 4]); - /// ``` - #[inline] - #[deprecated = "use .extend(other.into_iter())"] - pub fn push_all_move(&mut self, other: Vec) { - self.extend(other.into_iter()); - } - - /// Deprecated: use `slice_mut`. - #[deprecated = "use slice_mut"] - pub fn mut_slice<'a>(&'a mut self, start: uint, end: uint) - -> &'a mut [T] { - self[mut start..end] - } - /// Returns a mutable slice of `self` between `start` and `end`. /// /// # Failure @@ -1212,12 +1048,6 @@ impl Vec { self[mut start..end] } - /// Deprecated: use "slice_from_mut". - #[deprecated = "use slice_from_mut"] - pub fn mut_slice_from<'a>(&'a mut self, start: uint) -> &'a mut [T] { - self[mut start..] - } - /// Returns a mutable slice of `self` from `start` to the end of the `Vec`. /// /// # Failure @@ -1235,12 +1065,6 @@ impl Vec { self[mut start..] } - /// Deprecated: use `slice_to_mut`. - #[deprecated = "use slice_to_mut"] - pub fn mut_slice_to<'a>(&'a mut self, end: uint) -> &'a mut [T] { - self[mut ..end] - } - /// Returns a mutable slice of `self` from the start of the `Vec` to `end`. /// /// # Failure @@ -1258,12 +1082,6 @@ impl Vec { self[mut ..end] } - /// Deprecated: use `split_at_mut`. - #[deprecated = "use split_at_mut"] - pub fn mut_split_at<'a>(&'a mut self, mid: uint) -> (&'a mut [T], &'a mut [T]) { - self.split_at_mut(mid) - } - /// Returns a pair of mutable slices that divides the `Vec` at an index. /// /// The first will contain all indices from `[0, mid)` (excluding diff --git a/src/libcore/any.rs b/src/libcore/any.rs index c4b07d42e693a..021f575b0acea 100644 --- a/src/libcore/any.rs +++ b/src/libcore/any.rs @@ -76,11 +76,6 @@ use option::{Option, Some, None}; use raw::TraitObject; use intrinsics::TypeId; -/// A type with no inhabitants -#[deprecated = "this type is being removed, define a type locally if \ - necessary"] -pub enum Void { } - /////////////////////////////////////////////////////////////////////////////// // Any trait /////////////////////////////////////////////////////////////////////////////// @@ -117,13 +112,6 @@ pub trait AnyRefExt<'a> { /// `None` if it isn't. #[unstable = "naming conventions around acquiring references may change"] fn downcast_ref(self) -> Option<&'a T>; - - /// Returns some reference to the boxed value if it is of type `T`, or - /// `None` if it isn't. - #[deprecated = "this function has been renamed to `downcast_ref`"] - fn as_ref(self) -> Option<&'a T> { - self.downcast_ref::() - } } #[stable] @@ -166,13 +154,6 @@ pub trait AnyMutRefExt<'a> { /// `None` if it isn't. #[unstable = "naming conventions around acquiring references may change"] fn downcast_mut(self) -> Option<&'a mut T>; - - /// Returns some mutable reference to the boxed value if it is of type `T`, or - /// `None` if it isn't. - #[deprecated = "this function has been renamed to `downcast_mut`"] - fn as_mut(self) -> Option<&'a mut T> { - self.downcast_mut::() - } } #[stable] diff --git a/src/libcore/cmp.rs b/src/libcore/cmp.rs index a567eaa57d57f..4665e2d823ef7 100644 --- a/src/libcore/cmp.rs +++ b/src/libcore/cmp.rs @@ -178,20 +178,6 @@ impl PartialOrd for Ordering { } } -/// Combine orderings, lexically. -/// -/// For example for a type `(int, int)`, two comparisons could be done. -/// If the first ordering is different, the first ordering is all that must be returned. -/// If the first ordering is equal, then second ordering is returned. -#[inline] -#[deprecated = "Just call .cmp() on a tuple"] -pub fn lexical_ordering(o1: Ordering, o2: Ordering) -> Ordering { - match o1 { - Equal => o2, - _ => o1 - } -} - /// Trait for values that can be compared for a sort-order. /// /// PartialOrd only requires implementation of the `partial_cmp` method, diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index 4b970dc3d25f6..e2a4fdfe79bf1 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -428,27 +428,6 @@ pub trait Iterator { ByRef{iter: self} } - /// Apply a function to each element, or stop iterating if the - /// function returns `false`. - /// - /// # Example - /// - /// ```rust,ignore - /// range(0u, 5).advance(|x| {print!("{} ", x); true}); - /// ``` - #[deprecated = "use the `all` method instead"] - #[inline] - fn advance(&mut self, f: |A| -> bool) -> bool { - loop { - match self.next() { - Some(x) => { - if !f(x) { return false; } - } - None => { return true; } - } - } - } - /// Loops through the entire iterator, collecting all of the elements into /// a container implementing `FromIterator`. /// diff --git a/src/libcore/kinds.rs b/src/libcore/kinds.rs index b0206e73e4799..677bc91d9dd3b 100644 --- a/src/libcore/kinds.rs +++ b/src/libcore/kinds.rs @@ -20,9 +20,6 @@ by the compiler automatically for the types to which they apply. */ -#[deprecated = "This has been renamed to Sync"] -pub use self::Sync as Share; - /// Types able to be transferred across task boundaries. #[lang="send"] pub trait Send for Sized? { diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 8134f5210243a..62a4fbd2e08cd 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -104,13 +104,6 @@ pub mod clone; pub mod default; pub mod collections; -#[deprecated = "all functionality now lives in `std::cell`"] -/// Deprecated module in favor of `std::cell` -pub mod ty { - #[deprecated = "this type has been renamed to `UnsafeCell`"] - pub use cell::UnsafeCell as Unsafe; -} - /* Core types and methods on primitives */ pub mod any; diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 947fa2ec92e5e..97b3554b1e1ba 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -14,7 +14,6 @@ //! types, initializing and manipulating memory. use intrinsics; -use num::Int; use ptr; pub use intrinsics::transmute; @@ -43,26 +42,6 @@ pub fn size_of_val(_val: &T) -> uint { size_of::() } -/// Deprecated, this function will be removed soon -#[inline] -#[deprecated = "this function will be removed soon"] -pub fn nonzero_size_of() -> uint { - match size_of::() { - 0 => 1, - n => n, - } -} - -/// Deprecated, this function will be removed soon -#[inline] -#[deprecated = "this function will be removed soon"] -pub fn nonzero_size_of_val(val: &T) -> uint { - match size_of_val::(val) { - 0 => 1, - n => n, - } -} - /// Returns the ABI-required minimum alignment of a type /// /// This is the alignment used for struct fields. It may be smaller @@ -107,16 +86,6 @@ pub fn align_of_val(_val: &T) -> uint { align_of::() } -/// Deprecated, this function has been renamed to align_of -#[inline] -#[deprecated = "use mem::align_of instead"] -pub fn pref_align_of() -> uint { align_of::() } - -/// Deprecated, this function has been renamed to align_of_val -#[inline] -#[deprecated = "use mem::align_of_val instead"] -pub fn pref_align_of_val(val: &T) -> uint { align_of_val(val) } - /// Create a value initialized to zero. /// /// This function is similar to allocating space for a a local variable and @@ -134,11 +103,6 @@ pub unsafe fn zeroed() -> T { intrinsics::init() } -/// Deprecated, use zeroed() instead -#[inline] -#[deprecated = "this function has been renamed to zeroed()"] -pub unsafe fn init() -> T { zeroed() } - /// Create an uninitialized value. /// /// Care must be taken when using this function, if the type `T` has a @@ -153,116 +117,6 @@ pub unsafe fn uninitialized() -> T { intrinsics::uninit() } -/// Deprecated, use `uninitialized` instead. -#[inline] -#[deprecated = "this function has been renamed to `uninitialized`"] -pub unsafe fn uninit() -> T { - intrinsics::uninit() -} - -/// Unsafely overwrite a memory location with the given value without destroying -/// the old value. -/// -/// This operation is unsafe because it does not destroy the previous value -/// contained at the location `dst`. This could leak allocations or resources, -/// so care must be taken to previously deallocate the value at `dst`. -#[inline] -#[deprecated = "use ptr::write"] -pub unsafe fn overwrite(dst: *mut T, src: T) { - intrinsics::move_val_init(&mut *dst, src) -} - -/// Deprecated, use `overwrite` instead -#[inline] -#[deprecated = "this function has been renamed to overwrite()"] -pub unsafe fn move_val_init(dst: &mut T, src: T) { - ptr::write(dst, src) -} - -/// Convert an u16 to little endian from the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_le` instead"] -pub fn to_le16(x: u16) -> u16 { x.to_le() } - -/// Convert an u32 to little endian from the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_le` instead"] -pub fn to_le32(x: u32) -> u32 { x.to_le() } - -/// Convert an u64 to little endian from the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_le` instead"] -pub fn to_le64(x: u64) -> u64 { x.to_le() } - -/// Convert an u16 to big endian from the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_be` instead"] -pub fn to_be16(x: u16) -> u16 { x.to_be() } - -/// Convert an u32 to big endian from the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_be` instead"] -pub fn to_be32(x: u32) -> u32 { x.to_be() } - -/// Convert an u64 to big endian from the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::to_be` instead"] -pub fn to_be64(x: u64) -> u64 { x.to_be() } - -/// Convert an u16 from little endian to the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_le` instead"] -pub fn from_le16(x: u16) -> u16 { Int::from_le(x) } - -/// Convert an u32 from little endian to the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_le` instead"] -pub fn from_le32(x: u32) -> u32 { Int::from_le(x) } - -/// Convert an u64 from little endian to the target's endianness. -/// -/// On little endian, this is a no-op. On big endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_le` instead"] -pub fn from_le64(x: u64) -> u64 { Int::from_le(x) } - -/// Convert an u16 from big endian to the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_be` instead"] -pub fn from_be16(x: u16) -> u16 { Int::from_be(x) } - -/// Convert an u32 from big endian to the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_be` instead"] -pub fn from_be32(x: u32) -> u32 { Int::from_be(x) } - -/// Convert an u64 from big endian to the target's endianness. -/// -/// On big endian, this is a no-op. On little endian, the bytes are swapped. -#[inline] -#[deprecated = "use `Int::from_be` instead"] -pub fn from_be64(x: u64) -> u64 { Int::from_be(x) } - /// Swap the values at two mutable locations of the same type, without /// deinitialising or copying either one. #[inline] diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 9b66f900d9c89..5b34cab611a56 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -482,33 +482,6 @@ impl Option { } } - /// Deprecated. - /// - /// Applies a function to the contained value or does nothing. - /// Returns true if the contained value was mutated. - #[deprecated = "removed due to lack of use"] - pub fn mutate(&mut self, f: |T| -> T) -> bool { - if self.is_some() { - *self = Some(f(self.take().unwrap())); - true - } else { false } - } - - /// Deprecated. - /// - /// Applies a function to the contained value or sets it to a default. - /// Returns true if the contained value was mutated, or false if set to the default. - #[deprecated = "removed due to lack of use"] - pub fn mutate_or_set(&mut self, def: T, f: |T| -> T) -> bool { - if self.is_some() { - *self = Some(f(self.take().unwrap())); - true - } else { - *self = Some(def); - false - } - } - ///////////////////////////////////////////////////////////////////////// // Iterator constructors ///////////////////////////////////////////////////////////////////////// @@ -530,12 +503,6 @@ impl Option { Item{opt: self.as_ref()} } - /// Deprecated: use `iter_mut` - #[deprecated = "use iter_mut"] - pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { - self.iter_mut() - } - /// Returns a mutable iterator over the possibly contained value. /// /// # Example @@ -557,12 +524,6 @@ impl Option { Item{opt: self.as_mut()} } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> Item { - self.into_iter() - } - /// Returns a consuming iterator over the possibly contained value. /// /// # Example @@ -713,100 +674,6 @@ impl Option { pub fn take(&mut self) -> Option { mem::replace(self, None) } - - /// Deprecated. - /// - /// Filters an optional value using a given function. - #[inline(always)] - #[deprecated = "removed due to lack of use"] - pub fn filtered(self, f: |t: &T| -> bool) -> Option { - match self { - Some(x) => if f(&x) { Some(x) } else { None }, - None => None - } - } - - /// Deprecated. - /// - /// Applies a function zero or more times until the result is `None`. - #[inline] - #[deprecated = "removed due to lack of use"] - pub fn while_some(self, f: |v: T| -> Option) { - let mut opt = self; - loop { - match opt { - Some(x) => opt = f(x), - None => break - } - } - } - - ///////////////////////////////////////////////////////////////////////// - // Common special cases - ///////////////////////////////////////////////////////////////////////// - - /// Deprecated: use `take().unwrap()` instead. - /// - /// The option dance. Moves a value out of an option type and returns it, - /// replacing the original with `None`. - /// - /// # Failure - /// - /// Fails if the value equals `None`. - #[inline] - #[deprecated = "use take().unwrap() instead"] - pub fn take_unwrap(&mut self) -> T { - match self.take() { - Some(x) => x, - None => fail!("called `Option::take_unwrap()` on a `None` value") - } - } - - /// Deprecated: use `as_ref().unwrap()` instead. - /// - /// Gets an immutable reference to the value inside an option. - /// - /// # Failure - /// - /// Fails if the value equals `None` - /// - /// # Safety note - /// - /// In general, because this function may fail, its use is discouraged - /// (calling `get` on `None` is akin to dereferencing a null pointer). - /// Instead, prefer to use pattern matching and handle the `None` - /// case explicitly. - #[inline] - #[deprecated = "use .as_ref().unwrap() instead"] - pub fn get_ref<'a>(&'a self) -> &'a T { - match *self { - Some(ref x) => x, - None => fail!("called `Option::get_ref()` on a `None` value"), - } - } - - /// Deprecated: use `as_mut().unwrap()` instead. - /// - /// Gets a mutable reference to the value inside an option. - /// - /// # Failure - /// - /// Fails if the value equals `None` - /// - /// # Safety note - /// - /// In general, because this function may fail, its use is discouraged - /// (calling `get` on `None` is akin to dereferencing a null pointer). - /// Instead, prefer to use pattern matching and handle the `None` - /// case explicitly. - #[inline] - #[deprecated = "use .as_mut().unwrap() instead"] - pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut T { - match *self { - Some(ref mut x) => x, - None => fail!("called `Option::get_mut_ref()` on a `None` value"), - } - } } impl Option { @@ -908,13 +775,6 @@ impl ExactSize for Item {} // Free functions ///////////////////////////////////////////////////////////////////////////// -/// Deprecated: use `Iterator::collect` instead. -#[inline] -#[deprecated = "use Iterator::collect instead"] -pub fn collect>, V: FromIterator>(mut iter: Iter) -> Option { - iter.collect() -} - impl> FromIterator> for Option { /// Takes each element in the `Iterator`: if it is `None`, no further /// elements are taken, and the `None` is returned. Should no `None` occur, a diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index b76c92140fda6..f0cd8402b1424 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -90,7 +90,6 @@ use mem; use clone::Clone; use intrinsics; -use iter::range; use option::{Some, None, Option}; use cmp::{PartialEq, Eq, PartialOrd, Equiv, Ordering, Less, Equal, Greater}; @@ -113,10 +112,6 @@ pub use intrinsics::set_memory; #[unstable = "may need a different name after pending changes to pointer types"] pub fn null() -> *const T { 0 as *const T } -/// Deprecated: use `null_mut`. -#[deprecated = "use null_mut"] -pub fn mut_null() -> *mut T { null_mut() } - /// Create an unsafe mutable null pointer. /// /// # Example @@ -203,59 +198,6 @@ pub unsafe fn write(dst: *mut T, src: T) { intrinsics::move_val_init(&mut *dst, src) } -/// Given a *const *const T (pointer to an array of pointers), -/// iterate through each *const T, up to the provided `len`, -/// passing to the provided callback function -#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -pub unsafe fn array_each_with_len(arr: *const *const T, len: uint, - cb: |*const T|) { - if arr.is_null() { - fail!("ptr::array_each_with_len failure: arr input is null pointer"); - } - //let start_ptr = *arr; - for e in range(0, len) { - let n = arr.offset(e as int); - cb(*n); - } -} - -/// Given a null-pointer-terminated *const *const T (pointer to -/// an array of pointers), iterate through each *const T, -/// passing to the provided callback function -/// -/// # Safety Note -/// -/// This will only work with a null-terminated -/// pointer array. -#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -#[allow(deprecated)] -pub unsafe fn array_each(arr: *const *const T, cb: |*const T|) { - if arr.is_null() { - fail!("ptr::array_each_with_len failure: arr input is null pointer"); - } - let len = buf_len(arr); - array_each_with_len(arr, len, cb); -} - -/// Return the offset of the first null pointer in `buf`. -#[inline] -#[deprecated = "use a loop and RawPtr::offset"] -#[allow(deprecated)] -pub unsafe fn buf_len(buf: *const *const T) -> uint { - position(buf, |i| *i == null()) -} - -/// Return the first offset `i` such that `f(buf[i]) == true`. -#[inline] -#[deprecated = "old-style iteration. use a loop and RawPtr::offset"] -pub unsafe fn position(buf: *const T, f: |&T| -> bool) -> uint { - let mut i = 0; - loop { - if f(&(*buf.offset(i as int))) { return i; } - else { i += 1; } - } -} - /// Methods on raw pointers pub trait RawPtr { /// Returns the null pointer. @@ -280,12 +222,6 @@ pub trait RawPtr { /// the returned value could be pointing to invalid memory. unsafe fn as_ref<'a>(&self) -> Option<&'a T>; - /// A synonym for `as_ref`, except with incorrect lifetime semantics - #[deprecated="Use `as_ref` instead"] - unsafe fn to_option<'a>(&'a self) -> Option<&'a T> { - mem::transmute(self.as_ref()) - } - /// Calculates the offset from a pointer. The offset *must* be in-bounds of /// the object, or one-byte-past-the-end. `count` is in units of T; e.g. a /// `count` of 3 represents a pointer offset of `3 * sizeof::()` bytes. diff --git a/src/libcore/result.rs b/src/libcore/result.rs index caede952e2ffe..27bb649d1d99b 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -566,12 +566,6 @@ impl Result { Item{opt: self.as_ref().ok()} } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter<'r>(&'r mut self) -> Item<&'r mut T> { - self.iter_mut() - } - /// Returns a mutable iterator over the possibly contained value. /// /// # Example @@ -593,12 +587,6 @@ impl Result { Item{opt: self.as_mut().ok()} } - /// Deprecated: `use into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> Item { - self.into_iter() - } - /// Returns a consuming iterator over the possibly contained value. /// /// # Example @@ -771,13 +759,6 @@ impl Result { Err(e) => op(e) } } - - /// Deprecated name for `unwrap_or_else()`. - #[deprecated = "replaced by .unwrap_or_else()"] - #[inline] - pub fn unwrap_or_handle(self, op: |E| -> T) -> T { - self.unwrap_or_else(op) - } } impl Result { @@ -902,14 +883,6 @@ impl ExactSize for Item {} // Free functions ///////////////////////////////////////////////////////////////////////////// -/// Deprecated: use `Iterator::collect`. -#[inline] -#[deprecated = "use Iterator::collect instead"] -pub fn collect>, V: FromIterator>(mut iter: Iter) - -> Result { - iter.collect() -} - impl> FromIterator> for Result { /// Takes each element in the `Iterator`: if it is an `Err`, no further /// elements are taken, and the `Err` is returned. Should no `Err` occur, a @@ -984,16 +957,3 @@ pub fn fold>>(iterator: Iter) -> Result<(),E> { - fold(iterator, (), |_, _| ()) -} diff --git a/src/libcore/slice.rs b/src/libcore/slice.rs index 5847a6177d729..df828f628eeb7 100644 --- a/src/libcore/slice.rs +++ b/src/libcore/slice.rs @@ -176,27 +176,14 @@ pub trait ImmutableSlice<'a, T> { #[unstable = "name may change"] fn tail(&self) -> &'a [T]; - /// Returns all but the first `n' elements of a slice. - #[deprecated = "use slice_from"] - fn tailn(&self, n: uint) -> &'a [T]; - /// Returns all but the last element of a slice. #[unstable = "name may change"] fn init(&self) -> &'a [T]; - /// Returns all but the last `n' elements of a slice. - #[deprecated = "use slice_to but note the arguments are different"] - fn initn(&self, n: uint) -> &'a [T]; - /// Returns the last element of a slice, or `None` if it is empty. #[unstable = "name may change"] fn last(&self) -> Option<&'a T>; - /// Returns a pointer to the element at the given index, without doing - /// bounds checking. - #[deprecated = "renamed to `unsafe_get`"] - unsafe fn unsafe_ref(self, index: uint) -> &'a T; - /// Returns a pointer to the element at the given index, without doing /// bounds checking. #[unstable] @@ -212,10 +199,6 @@ pub trait ImmutableSlice<'a, T> { #[unstable] fn as_ptr(&self) -> *const T; - /// Deprecated: use `binary_search`. - #[deprecated = "use binary_search"] - fn bsearch(&self, f: |&T| -> Ordering) -> Option; - /// Binary search a sorted slice with a comparator function. /// /// The comparator function should implement an order consistent @@ -251,44 +234,6 @@ pub trait ImmutableSlice<'a, T> { /// ``` #[unstable = "waiting on unboxed closures"] fn binary_search(&self, f: |&T| -> Ordering) -> BinarySearchResult; - - /** - * Returns an immutable reference to the first element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None } - * let head = &self[0]; - * *self = self[1..]; - * Some(head) - * ``` - * - * Returns `None` if vector is empty - */ - #[deprecated = "find some other way. sorry"] - fn shift_ref(&mut self) -> Option<&'a T>; - - /** - * Returns an immutable reference to the last element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None; } - * let tail = &self[self.len() - 1]; - * *self = self[..self.len() - 1]; - * Some(tail) - * ``` - * - * Returns `None` if slice is empty. - */ - #[deprecated = "find some other way. sorry"] - fn pop_ref(&mut self) -> Option<&'a T>; } #[unstable] @@ -388,32 +333,16 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { #[inline] fn tail(&self) -> &'a [T] { (*self)[1..] } - #[inline] - #[deprecated = "use slice_from"] - fn tailn(&self, n: uint) -> &'a [T] { (*self)[n..] } - #[inline] fn init(&self) -> &'a [T] { (*self)[..self.len() - 1] } - #[inline] - #[deprecated = "use slice_to but note the arguments are different"] - fn initn(&self, n: uint) -> &'a [T] { - (*self)[..self.len() - n] - } - #[inline] fn last(&self) -> Option<&'a T> { if self.len() == 0 { None } else { Some(&self[self.len() - 1]) } } - #[inline] - #[deprecated = "renamed to `unsafe_get`"] - unsafe fn unsafe_ref(self, index: uint) -> &'a T { - transmute(self.repr().data.offset(index as int)) - } - #[inline] unsafe fn unsafe_get(self, index: uint) -> &'a T { transmute(self.repr().data.offset(index as int)) @@ -424,27 +353,6 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { self.repr().data } - - #[deprecated = "use binary_search"] - fn bsearch(&self, f: |&T| -> Ordering) -> Option { - let mut base : uint = 0; - let mut lim : uint = self.len(); - - while lim != 0 { - let ix = base + (lim >> 1); - match f(&self[ix]) { - Equal => return Some(ix), - Less => { - base = ix + 1; - lim -= 1; - } - Greater => () - } - lim >>= 1; - } - return None; - } - #[unstable] fn binary_search(&self, f: |&T| -> Ordering) -> BinarySearchResult { let mut base : uint = 0; @@ -464,26 +372,6 @@ impl<'a,T> ImmutableSlice<'a, T> for &'a [T] { } return NotFound(base); } - - fn shift_ref(&mut self) -> Option<&'a T> { - unsafe { - let s: &mut RawSlice = transmute(self); - match raw::shift_ptr(s) { - Some(p) => Some(&*p), - None => None - } - } - } - - fn pop_ref(&mut self) -> Option<&'a T> { - unsafe { - let s: &mut RawSlice = transmute(self); - match raw::pop_ptr(s) { - Some(p) => Some(&*p), - None => None - } - } - } } @@ -557,12 +445,6 @@ pub trait MutableSlice<'a, T> { /// Primarily intended for getting a &mut [T] from a [T, ..N]. fn as_mut_slice(self) -> &'a mut [T]; - /// Deprecated: use `slice_mut`. - #[deprecated = "use slice_mut"] - fn mut_slice(self, start: uint, end: uint) -> &'a mut [T] { - self.slice_mut(start, end) - } - /// Returns a mutable subslice spanning the interval [`start`, `end`). /// /// Fails when the end of the new slice lies beyond the end of the @@ -572,12 +454,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn slice_mut(self, start: uint, end: uint) -> &'a mut [T]; - /// Deprecated: use `slice_from_mut`. - #[deprecated = "use slice_from_mut"] - fn mut_slice_from(self, start: uint) -> &'a mut [T] { - self.slice_from_mut(start) - } - /// Returns a mutable subslice from `start` to the end of the slice. /// /// Fails when `start` is strictly greater than the length of the original slice. @@ -586,12 +462,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn slice_from_mut(self, start: uint) -> &'a mut [T]; - /// Deprecated: use `slice_to_mut`. - #[deprecated = "use slice_to_mut"] - fn mut_slice_to(self, end: uint) -> &'a mut [T] { - self.slice_to_mut(end) - } - /// Returns a mutable subslice from the start of the slice to `end`. /// /// Fails when `end` is strictly greater than the length of the original slice. @@ -600,12 +470,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn slice_to_mut(self, end: uint) -> &'a mut [T]; - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - fn mut_iter(self) -> MutItems<'a, T> { - self.iter_mut() - } - /// Returns an iterator that allows modifying each value #[unstable = "waiting on iterator type name conventions"] fn iter_mut(self) -> MutItems<'a, T>; @@ -622,22 +486,10 @@ pub trait MutableSlice<'a, T> { #[unstable = "name may change"] fn init_mut(self) -> &'a mut [T]; - /// Deprecated: use `last_mut`. - #[deprecated = "use last_mut"] - fn mut_last(self) -> Option<&'a mut T> { - self.last_mut() - } - /// Returns a mutable pointer to the last item in the slice. #[unstable = "name may change"] fn last_mut(self) -> Option<&'a mut T>; - /// Deprecated: use `split_mut`. - #[deprecated = "use split_mut"] - fn mut_split(self, pred: |&T|: 'a -> bool) -> MutSplits<'a, T> { - self.split_mut(pred) - } - /// Returns an iterator over mutable subslices separated by elements that /// match `pred`. The matched element is not contained in the subslices. #[unstable = "waiting on unboxed closures, iterator type name conventions"] @@ -656,12 +508,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on unboxed closures, iterator type name conventions"] fn rsplitn_mut(self, n: uint, pred: |&T|: 'a -> bool) -> SplitsN>; - /// Deprecated: use `chunks_mut`. - #[deprecated = "use chunks_mut"] - fn mut_chunks(self, chunk_size: uint) -> MutChunks<'a, T> { - self.chunks_mut(chunk_size) - } - /// Returns an iterator over `chunk_size` elements of the slice at a time. /// The chunks are mutable and do not overlap. If `chunk_size` does /// not divide the length of the slice, then the last chunk will not @@ -673,44 +519,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on iterator type name conventions"] fn chunks_mut(self, chunk_size: uint) -> MutChunks<'a, T>; - /** - * Returns a mutable reference to the first element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None; } - * let head = &mut self[0]; - * *self = self[mut 1..]; - * Some(head) - * ``` - * - * Returns `None` if slice is empty - */ - #[deprecated = "use iter_mut"] - fn mut_shift_ref(&mut self) -> Option<&'a mut T>; - - /** - * Returns a mutable reference to the last element in this slice - * and adjusts the slice in place so that it no longer contains - * that element. O(1). - * - * Equivalent to: - * - * ```ignore - * if self.len() == 0 { return None; } - * let tail = &mut self[self.len() - 1]; - * *self = self[mut ..self.len() - 1]; - * Some(tail) - * ``` - * - * Returns `None` if slice is empty. - */ - #[deprecated = "use iter_mut"] - fn mut_pop_ref(&mut self) -> Option<&'a mut T>; - /// Swaps two elements in a slice. /// /// Fails if `a` or `b` are out of bounds. @@ -730,12 +538,6 @@ pub trait MutableSlice<'a, T> { #[unstable = "waiting on final error conventions"] fn swap(self, a: uint, b: uint); - /// Deprecated: use `split_at_mut`. - #[deprecated = "use split_at_mut"] - fn mut_split_at(self, mid: uint) -> (&'a mut [T], &'a mut [T]) { - self.split_at_mut(mid) - } - /// Divides one `&mut` into two at an index. /// /// The first will contain all indices from `[0, mid)` (excluding @@ -783,12 +585,6 @@ pub trait MutableSlice<'a, T> { #[experimental = "may be moved to iterators instead"] fn reverse(self); - /// Deprecated: use `unsafe_mut`. - #[deprecated = "use unsafe_mut"] - unsafe fn unsafe_mut_ref(self, index: uint) -> &'a mut T { - self.unsafe_mut(index) - } - /// Returns an unsafe mutable pointer to the element in index #[experimental = "waiting on unsafe conventions"] unsafe fn unsafe_mut(self, index: uint) -> &'a mut T; @@ -803,18 +599,6 @@ pub trait MutableSlice<'a, T> { #[inline] #[unstable] fn as_mut_ptr(self) -> *mut T; - - /// Deprecated: use `*foo.as_mut_ptr().offset(index) = val` instead. - #[deprecated = "use `*foo.as_mut_ptr().offset(index) = val`"] - unsafe fn unsafe_set(self, index: uint, val: T); - - /// Deprecated: use `ptr::write(foo.as_mut_ptr().offset(i), val)` instead. - #[deprecated = "use `ptr::write(foo.as_mut_ptr().offset(i), val)`"] - unsafe fn init_elem(self, i: uint, val: T); - - /// Deprecated: use `as_mut_ptr` and `ptr::copy_memory` instead. - #[deprecated = "use as_mut_ptr and ptr::copy_memory"] - unsafe fn copy_memory(self, src: &[T]); } #[experimental = "trait is experimental"] @@ -920,30 +704,6 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { MutChunks { v: self, chunk_size: chunk_size } } - fn mut_shift_ref(&mut self) -> Option<&'a mut T> { - unsafe { - let s: &mut RawSlice = transmute(self); - match raw::shift_ptr(s) { - // FIXME #13933: this `&` -> `&mut` cast is a little - // dubious - Some(p) => Some(&mut *(p as *mut _)), - None => None, - } - } - } - - fn mut_pop_ref(&mut self) -> Option<&'a mut T> { - unsafe { - let s: &mut RawSlice = transmute(self); - match raw::pop_ptr(s) { - // FIXME #13933: this `&` -> `&mut` cast is a little - // dubious - Some(p) => Some(&mut *(p as *mut _)), - None => None, - } - } - } - fn swap(self, a: uint, b: uint) { unsafe { // Can't take two mutable loans from one vector, so instead just cast @@ -977,23 +737,6 @@ impl<'a,T> MutableSlice<'a, T> for &'a mut [T] { fn as_mut_ptr(self) -> *mut T { self.repr().data as *mut T } - - #[inline] - unsafe fn unsafe_set(self, index: uint, val: T) { - *self.unsafe_mut(index) = val; - } - - #[inline] - unsafe fn init_elem(self, i: uint, val: T) { - ptr::write(&mut (*self.as_mut_ptr().offset(i as int)), val); - } - - #[inline] - unsafe fn copy_memory(self, src: &[T]) { - let len_src = src.len(); - assert!(self.len() >= len_src); - ptr::copy_nonoverlapping_memory(self.as_mut_ptr(), src.as_ptr(), len_src) - } } /// Extension methods for slices containing `PartialEq` elements. @@ -1048,10 +791,6 @@ impl<'a,T:PartialEq> ImmutablePartialEqSlice for &'a [T] { /// Extension methods for slices containing `Ord` elements. #[unstable = "may merge with other traits"] pub trait ImmutableOrdSlice { - /// Deprecated: use `binary_search_elem`. - #[deprecated = "use binary_search_elem"] - fn bsearch_elem(&self, x: &T) -> Option; - /// Binary search a sorted slice for a given element. /// /// If the value is found then `Found` is returned, containing the @@ -1082,12 +821,6 @@ pub trait ImmutableOrdSlice { #[unstable = "trait is unstable"] impl<'a, T: Ord> ImmutableOrdSlice for &'a [T] { - #[deprecated = "use binary_search_elem"] - #[allow(deprecated)] - fn bsearch_elem(&self, x: &T) -> Option { - self.bsearch(|p| p.cmp(x)) - } - #[unstable] fn binary_search_elem(&self, x: &T) -> BinarySearchResult { self.binary_search(|p| p.cmp(x)) @@ -1097,12 +830,6 @@ impl<'a, T: Ord> ImmutableOrdSlice for &'a [T] { /// Trait for &[T] where T is Cloneable #[unstable = "may merge with other traits"] pub trait MutableCloneableSlice { - /// Copies as many elements from `src` as it can into `self` (the - /// shorter of `self.len()` and `src.len()`). Returns the number - /// of elements copied. - #[deprecated = "renamed to clone_from_slice"] - fn copy_from(self, s: &[T]) -> uint { self.clone_from_slice(s) } - /// Copies as many elements from `src` as it can into `self` (the /// shorter of `self.len()` and `src.len()`). Returns the number /// of elements copied. @@ -1779,8 +1506,9 @@ pub mod raw { #[experimental = "needs review"] pub mod bytes { use collections::Collection; + use cmp; use ptr; - use slice::MutableSlice; + use slice::{ImmutableSlice, MutableSlice}; /// A trait for operations on mutable `[u8]`s. pub trait MutableByteVector { @@ -1801,10 +1529,14 @@ pub mod bytes { /// `src` and `dst` must not overlap. Fails if the length of `dst` /// is less than the length of `src`. #[inline] - #[allow(deprecated)] pub fn copy_memory(dst: &mut [u8], src: &[u8]) { - // Bound checks are done at .copy_memory. - unsafe { dst.copy_memory(src) } + let len_src = src.len(); + assert!(dst.len() >= len_src); + unsafe { + ptr::copy_nonoverlapping_memory(dst.as_mut_ptr(), + src.as_ptr(), + len_src); + } } } diff --git a/src/libcoretest/cmp.rs b/src/libcoretest/cmp.rs index 4ac3f7e931049..59ce73fe40da5 100644 --- a/src/libcoretest/cmp.rs +++ b/src/libcoretest/cmp.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::cmp::lexical_ordering; use core::cmp::{ partial_min, partial_max }; #[test] @@ -42,21 +41,6 @@ fn test_ordering_order() { assert_eq!(Greater.cmp(&Less), Greater); } -#[test] -#[allow(deprecated)] -fn test_lexical_ordering() { - fn t(o1: Ordering, o2: Ordering, e: Ordering) { - assert_eq!(lexical_ordering(o1, o2), e); - } - - let xs = [Less, Equal, Greater]; - for &o in xs.iter() { - t(Less, o, Less); - t(Equal, o, o); - t(Greater, o, Greater); - } -} - #[test] fn test_partial_min() { use core::f64::NAN; diff --git a/src/libcoretest/option.rs b/src/libcoretest/option.rs index 3f150b3d13695..71e9270fe4b0c 100644 --- a/src/libcoretest/option.rs +++ b/src/libcoretest/option.rs @@ -130,21 +130,6 @@ fn test_or_else() { assert_eq!(x.or_else(|| None), None); } -#[test] -#[allow(deprecated)] -fn test_option_while_some() { - let mut i = 0i; - Some(10i).while_some(|j| { - i += 1; - if j > 0 { - Some(j-1) - } else { - None - } - }); - assert_eq!(i, 11); -} - #[test] fn test_unwrap() { assert_eq!(Some(1i).unwrap(), 1); @@ -184,15 +169,6 @@ fn test_unwrap_or_else() { assert_eq!(x.unwrap_or_else(|| 2), 2); } -#[test] -#[allow(deprecated)] -fn test_filtered() { - let some_stuff = Some(42i); - let modified_stuff = some_stuff.filtered(|&x| {x < 10}); - assert_eq!(some_stuff.unwrap(), 42); - assert!(modified_stuff.is_none()); -} - #[test] fn test_iter() { let val = 5i; @@ -244,39 +220,22 @@ fn test_ord() { } #[test] -#[allow(deprecated)] -fn test_mutate() { - let mut x = Some(3i); - assert!(x.mutate(|i| i+1)); - assert_eq!(x, Some(4i)); - assert!(x.mutate_or_set(0, |i| i+1)); - assert_eq!(x, Some(5i)); - x = None; - assert!(!x.mutate(|i| i+1)); - assert_eq!(x, None); - assert!(!x.mutate_or_set(0i, |i| i+1)); - assert_eq!(x, Some(0i)); -} - -#[test] -#[allow(deprecated)] fn test_collect() { - let v: Option> = collect(range(0i, 0) - .map(|_| Some(0i))); + let v: Option> = range(0i, 0).map(|_| Some(0i)).collect(); assert!(v == Some(vec![])); - let v: Option> = collect(range(0i, 3) - .map(|x| Some(x))); + let v: Option> = range(0i, 3).map(|x| Some(x)).collect(); assert!(v == Some(vec![0, 1, 2])); - let v: Option> = collect(range(0i, 3) - .map(|x| if x > 1 { None } else { Some(x) })); + let v: Option> = range(0i, 3).map(|x| { + if x > 1 { None } else { Some(x) } + }).collect(); assert!(v == None); // test that it does not take more elements than it needs let mut functions = [|| Some(()), || None, || fail!()]; - let v: Option> = collect(functions.iter_mut().map(|f| (*f)())); + let v: Option> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == None); } diff --git a/src/libcoretest/ptr.rs b/src/libcoretest/ptr.rs index 754391a284ddf..db3580e5d0c42 100644 --- a/src/libcoretest/ptr.rs +++ b/src/libcoretest/ptr.rs @@ -7,12 +7,9 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![allow(deprecated)] + use core::ptr::*; -use libc::c_char; use core::mem; -use libc; -use std::c_str::CString; #[test] fn test() { @@ -39,49 +36,22 @@ fn test() { copy_memory(v1.as_mut_ptr().offset(1), v0.as_ptr().offset(1), 1); - assert!((*v1.get(0) == 0u16 && - *v1.get(1) == 32001u16 && - *v1.get(2) == 0u16)); + assert!((v1[0] == 0u16 && + v1[1] == 32001u16 && + v1[2] == 0u16)); copy_memory(v1.as_mut_ptr(), v0.as_ptr().offset(2), 1); - assert!((*v1.get(0) == 32002u16 && - *v1.get(1) == 32001u16 && - *v1.get(2) == 0u16)); + assert!((v1[0] == 32002u16 && + v1[1] == 32001u16 && + v1[2] == 0u16)); copy_memory(v1.as_mut_ptr().offset(2), v0.as_ptr(), 1u); - assert!((*v1.get(0) == 32002u16 && - *v1.get(1) == 32001u16 && - *v1.get(2) == 32000u16)); + assert!((v1[0] == 32002u16 && + v1[1] == 32001u16 && + v1[2] == 32000u16)); } } -#[test] -fn test_position() { - use libc::c_char; - - "hello".with_c_str(|p| { - unsafe { - assert!(2u == position(p, |c| *c == 'l' as c_char)); - assert!(4u == position(p, |c| *c == 'o' as c_char)); - assert!(5u == position(p, |c| *c == 0 as c_char)); - } - }) -} - -#[test] -fn test_buf_len() { - "hello".with_c_str(|p0| { - "there".with_c_str(|p1| { - "thing".with_c_str(|p2| { - let v = vec![p0, p1, p2, null()]; - unsafe { - assert_eq!(buf_len(v.as_ptr()), 3u); - } - }) - }) - }) -} - #[test] fn test_is_null() { let p: *const int = null(); @@ -92,7 +62,7 @@ fn test_is_null() { assert!(!q.is_null()); assert!(q.is_not_null()); - let mp: *mut int = mut_null(); + let mp: *mut int = null_mut(); assert!(mp.is_null()); assert!(!mp.is_not_null()); @@ -110,7 +80,7 @@ fn test_as_ref() { let q: *const int = &2; assert_eq!(q.as_ref().unwrap(), &2); - let p: *mut int = mut_null(); + let p: *mut int = null_mut(); assert_eq!(p.as_ref(), None); let q: *mut int = &mut 2; @@ -128,7 +98,7 @@ fn test_as_ref() { #[test] fn test_as_mut() { unsafe { - let p: *mut int = mut_null(); + let p: *mut int = null_mut(); assert!(p.as_mut() == None); let q: *mut int = &mut 2; @@ -193,82 +163,6 @@ fn test_ptr_subtraction() { } } -#[test] -fn test_ptr_array_each_with_len() { - unsafe { - let one = "oneOne".to_c_str(); - let two = "twoTwo".to_c_str(); - let three = "threeThree".to_c_str(); - let arr = vec![ - one.as_ptr(), - two.as_ptr(), - three.as_ptr() - ]; - let expected_arr = [ - one, two, three - ]; - - let mut ctr = 0; - let mut iteration_count = 0; - array_each_with_len(arr.as_ptr(), arr.len(), |e| { - let actual = CString::new(e, false); - assert_eq!(actual.as_str(), expected_arr[ctr].as_str()); - ctr += 1; - iteration_count += 1; - }); - assert_eq!(iteration_count, 3u); - } -} - -#[test] -fn test_ptr_array_each() { - unsafe { - let one = "oneOne".to_c_str(); - let two = "twoTwo".to_c_str(); - let three = "threeThree".to_c_str(); - let arr = vec![ - one.as_ptr(), - two.as_ptr(), - three.as_ptr(), - // fake a null terminator - null() - ]; - let expected_arr = [ - one, two, three - ]; - - let arr_ptr = arr.as_ptr(); - let mut ctr = 0u; - let mut iteration_count = 0u; - array_each(arr_ptr, |e| { - let actual = CString::new(e, false); - assert_eq!(actual.as_str(), expected_arr[ctr].as_str()); - ctr += 1; - iteration_count += 1; - }); - assert_eq!(iteration_count, 3); - } -} - -#[test] -#[should_fail] -fn test_ptr_array_each_with_len_null_ptr() { - unsafe { - array_each_with_len(0 as *const *const libc::c_char, 1, |e| { - CString::new(e, false).as_str().unwrap(); - }); - } -} -#[test] -#[should_fail] -fn test_ptr_array_each_null_ptr() { - unsafe { - array_each(0 as *const *const libc::c_char, |e| { - CString::new(e, false).as_str().unwrap(); - }); - } -} - #[test] fn test_set_memory() { let mut xs = [0u8, ..20]; diff --git a/src/libcoretest/result.rs b/src/libcoretest/result.rs index b023833f39474..1cb72bd9eac78 100644 --- a/src/libcoretest/result.rs +++ b/src/libcoretest/result.rs @@ -8,7 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use core::result::{collect, fold, fold_}; use core::iter::range; pub fn op1() -> Result { Ok(666) } @@ -69,47 +68,25 @@ pub fn test_impl_map_err() { } #[test] -#[allow(deprecated)] fn test_collect() { - let v: Result, ()> = collect(range(0i, 0).map(|_| Ok::(0))); + let v: Result, ()> = range(0i, 0).map(|_| Ok::(0)).collect(); assert!(v == Ok(vec![])); - let v: Result, ()> = collect(range(0i, 3).map(|x| Ok::(x))); + let v: Result, ()> = range(0i, 3).map(|x| Ok::(x)).collect(); assert!(v == Ok(vec![0, 1, 2])); - let v: Result, int> = collect(range(0i, 3) - .map(|x| if x > 1 { Err(x) } else { Ok(x) })); + let v: Result, int> = range(0i, 3).map(|x| { + if x > 1 { Err(x) } else { Ok(x) } + }).collect(); assert!(v == Err(2)); // test that it does not take more elements than it needs let mut functions = [|| Ok(()), || Err(1i), || fail!()]; - let v: Result, int> = collect(functions.iter_mut().map(|f| (*f)())); + let v: Result, int> = functions.iter_mut().map(|f| (*f)()).collect(); assert!(v == Err(1)); } -#[test] -#[allow(deprecated)] // we know fold_ is deprecated -fn test_fold() { - assert_eq!(fold_(range(0i, 0) - .map(|_| Ok::<(), ()>(()))), - Ok(())); - assert_eq!(fold(range(0i, 3) - .map(|x| Ok::(x)), - 0, |a, b| a + b), - Ok(3)); - assert_eq!(fold_(range(0i, 3) - .map(|x| if x > 1 { Err(x) } else { Ok(()) })), - Err(2)); - - // test that it does not take more elements than it needs - let mut functions = [|| Ok(()), || Err(1i), || fail!()]; - - assert_eq!(fold_(functions.iter_mut() - .map(|f| (*f)())), - Err(1)); -} - #[test] pub fn test_fmt_default() { let ok: Result = Ok(100); diff --git a/src/libgraphviz/maybe_owned_vec.rs b/src/libgraphviz/maybe_owned_vec.rs index f67a9c2c84ce7..c7659dc1b9fd7 100644 --- a/src/libgraphviz/maybe_owned_vec.rs +++ b/src/libgraphviz/maybe_owned_vec.rs @@ -127,14 +127,6 @@ impl<'a,T:Clone> CloneableVector for MaybeOwnedVector<'a,T> { fn to_vec(&self) -> Vec { self.as_slice().to_vec() } - - /// Convert `self` into an owned slice, not making a copy if possible. - fn into_vec(self) -> Vec { - match self { - Growable(v) => v.as_slice().to_vec(), - Borrowed(v) => v.to_vec(), - } - } } impl<'a, T: Clone> Clone for MaybeOwnedVector<'a, T> { diff --git a/src/libgreen/basic.rs b/src/libgreen/basic.rs index 4bb4eeb4950ab..b592ba477c2a1 100644 --- a/src/libgreen/basic.rs +++ b/src/libgreen/basic.rs @@ -89,7 +89,7 @@ impl BasicLoop { fn idle(&mut self) { match self.idle { Some(ref mut idle) => { - if self.idle_active.get_ref().load(atomic::SeqCst) { + if self.idle_active.as_ref().unwrap().load(atomic::SeqCst) { idle.call(); } } @@ -98,7 +98,7 @@ impl BasicLoop { } fn has_idle(&self) -> bool { - self.idle.is_some() && self.idle_active.get_ref().load(atomic::SeqCst) + self.idle.is_some() && self.idle_active.as_ref().unwrap().load(atomic::SeqCst) } } diff --git a/src/libgreen/sched.rs b/src/libgreen/sched.rs index f46d96ffe4a35..6ba29cf5a3d7e 100644 --- a/src/libgreen/sched.rs +++ b/src/libgreen/sched.rs @@ -193,7 +193,7 @@ impl Scheduler { // Before starting our first task, make sure the idle callback // is active. As we do not start in the sleep state this is // important. - self.idle_callback.get_mut_ref().resume(); + self.idle_callback.as_mut().unwrap().resume(); // Now, as far as all the scheduler state is concerned, we are inside // the "scheduler" context. The scheduler immediately hands over control @@ -213,10 +213,10 @@ impl Scheduler { // cleaning up the memory it uses. As we didn't actually call // task.run() on the scheduler task we never get through all // the cleanup code it runs. - rtdebug!("stopping scheduler {}", stask.sched.get_ref().sched_id()); + rtdebug!("stopping scheduler {}", stask.sched.as_ref().unwrap().sched_id()); // Should not have any messages - let message = stask.sched.get_mut_ref().message_queue.pop(); + let message = stask.sched.as_mut().unwrap().message_queue.pop(); rtassert!(match message { msgq::Empty => true, _ => false }); stask.task.take().unwrap().drop(); @@ -279,7 +279,7 @@ impl Scheduler { // Assume that we need to continue idling unless we reach the // end of this function without performing an action. - self.idle_callback.get_mut_ref().resume(); + self.idle_callback.as_mut().unwrap().resume(); // First we check for scheduler messages, these are higher // priority than regular tasks. @@ -333,12 +333,12 @@ impl Scheduler { let handle = sched.make_handle(); sched.sleeper_list.push(handle); // Since we are sleeping, deactivate the idle callback. - sched.idle_callback.get_mut_ref().pause(); + sched.idle_callback.as_mut().unwrap().pause(); } else { rtdebug!("not sleeping, already doing so or no_sleep set"); // We may not be sleeping, but we still need to deactivate // the idle callback. - sched.idle_callback.get_mut_ref().pause(); + sched.idle_callback.as_mut().unwrap().pause(); } // Finished a cycle without using the Scheduler. Place it back @@ -633,7 +633,7 @@ impl Scheduler { unsafe { let sched: &mut Scheduler = - mem::transmute(&**next_task.sched.get_mut_ref()); + mem::transmute(&**next_task.sched.as_mut().unwrap()); let current_task: &mut GreenTask = match sched.cleanup_job { Some(CleanupJob { task: ref mut task, .. }) => &mut **task, @@ -661,7 +661,7 @@ impl Scheduler { let mut current_task: Box = unsafe { mem::transmute(current_task_dupe) }; - current_task.sched.get_mut_ref().run_cleanup_job(); + current_task.sched.as_mut().unwrap().run_cleanup_job(); // See the comments in switch_running_tasks_and_then for why a lock // is acquired here. This is the resumption points and the "bounce" @@ -682,9 +682,9 @@ impl Scheduler { -> (&'a mut Context, &'a mut Context) { let current_task_context = - &mut current_task.coroutine.get_mut_ref().saved_context; + &mut current_task.coroutine.as_mut().unwrap().saved_context; let next_task_context = - &mut next_task.coroutine.get_mut_ref().saved_context; + &mut next_task.coroutine.as_mut().unwrap().saved_context; unsafe { (mem::transmute(current_task_context), mem::transmute(next_task_context)) @@ -1050,7 +1050,7 @@ mod test { let mut task = Local::borrow(None::); match task.maybe_take_runtime::() { Some(green) => { - let ret = green.sched.get_ref().sched_id(); + let ret = green.sched.as_ref().unwrap().sched_id(); task.put_runtime(green); return ret; } @@ -1190,8 +1190,8 @@ mod test { fn on_appropriate_sched() -> bool { use task::{TypeGreen, TypeSched, HomeSched}; let task = GreenTask::convert(Local::take()); - let sched_id = task.sched.get_ref().sched_id(); - let run_any = task.sched.get_ref().run_anything; + let sched_id = task.sched.as_ref().unwrap().sched_id(); + let run_any = task.sched.as_ref().unwrap().run_anything; let ret = match task.task_type { TypeGreen(Some(AnySched)) => { run_any diff --git a/src/libgreen/task.rs b/src/libgreen/task.rs index 3b751a5a28d89..b6bd8c3cec4a7 100644 --- a/src/libgreen/task.rs +++ b/src/libgreen/task.rs @@ -100,7 +100,7 @@ extern fn bootstrap_green_task(task: uint, code: *mut (), env: *mut ()) -> ! { // First code after swap to this new context. Run our cleanup job task.pool_id = { - let sched = task.sched.get_mut_ref(); + let sched = task.sched.as_mut().unwrap(); sched.run_cleanup_job(); sched.task_state.increment(); sched.pool_id @@ -179,7 +179,7 @@ impl GreenTask { let mut green = GreenTask::new(pool, stack_size, f); { - let task = green.task.get_mut_ref(); + let task = green.task.as_mut().unwrap(); task.name = name; task.death.on_exit = on_exit; } @@ -314,7 +314,7 @@ impl GreenTask { fn reawaken_remotely(mut self: Box) { unsafe { let mtx = &mut self.nasty_deschedule_lock as *mut NativeMutex; - let handle = self.handle.get_mut_ref() as *mut SchedHandle; + let handle = self.handle.as_mut().unwrap() as *mut SchedHandle; let _guard = (*mtx).lock(); (*handle).send(RunOnce(self)); } @@ -460,7 +460,7 @@ impl Runtime for GreenTask { // // Upon returning, our task is back in TLS and we're good to return. let sibling = { - let sched = bomb.inner.get_mut_ref().sched.get_mut_ref(); + let sched = bomb.inner.as_mut().unwrap().sched.as_mut().unwrap(); GreenTask::configure(&mut sched.stack_pool, opts, f) }; let mut me = bomb.inner.take().unwrap(); @@ -470,7 +470,7 @@ impl Runtime for GreenTask { // Local I/O is provided by the scheduler's event loop fn local_io<'a>(&'a mut self) -> Option> { - match self.sched.get_mut_ref().event_loop.io() { + match self.sched.as_mut().unwrap().event_loop.io() { Some(io) => Some(rtio::LocalIo::new(io)), None => None, } diff --git a/src/libnative/io/addrinfo.rs b/src/libnative/io/addrinfo.rs index 7a07b6221277f..d40438e4272a3 100644 --- a/src/libnative/io/addrinfo.rs +++ b/src/libnative/io/addrinfo.rs @@ -11,7 +11,7 @@ use libc::{c_char, c_int}; use libc; use std::mem; -use std::ptr::{null, mut_null}; +use std::ptr::{null, null_mut}; use std::rt::rtio; use std::rt::rtio::IoError; @@ -38,16 +38,16 @@ impl GetAddrInfoRequest { ai_socktype: 0, ai_protocol: 0, ai_addrlen: 0, - ai_canonname: mut_null(), - ai_addr: mut_null(), - ai_next: mut_null() + ai_canonname: null_mut(), + ai_addr: null_mut(), + ai_next: null_mut() } }); let hint_ptr = hint.as_ref().map_or(null(), |x| { x as *const libc::addrinfo }); - let mut res = mut_null(); + let mut res = null_mut(); // Make the call let s = unsafe { diff --git a/src/libnative/io/helper_thread.rs b/src/libnative/io/helper_thread.rs index 8aff1732a41fc..d1368ad31f475 100644 --- a/src/libnative/io/helper_thread.rs +++ b/src/libnative/io/helper_thread.rs @@ -22,13 +22,14 @@ #![macro_escape] +use std::cell::UnsafeCell; use std::mem; use std::rt::bookkeeping; use std::rt::mutex::StaticNativeMutex; use std::rt; -use std::cell::UnsafeCell; +use std::task::TaskBuilder; -use task; +use NativeTaskBuilder; /// A structure for management of a helper thread. /// @@ -86,7 +87,7 @@ impl Helper { *self.signal.get() = send as uint; let t = f(); - task::spawn(proc() { + TaskBuilder::new().native().spawn(proc() { bookkeeping::decrement(); helper(receive, rx, t); self.lock.lock().signal() diff --git a/src/libnative/io/timer_unix.rs b/src/libnative/io/timer_unix.rs index 4d4ba33aec45f..6f57a5e88ba14 100644 --- a/src/libnative/io/timer_unix.rs +++ b/src/libnative/io/timer_unix.rs @@ -115,7 +115,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { // signals the first requests in the queue, possible re-enqueueing it. fn signal(active: &mut Vec>, dead: &mut Vec<(uint, Box)>) { - let mut timer = match active.shift() { + let mut timer = match active.remove(0) { Some(timer) => timer, None => return }; let mut cb = timer.cb.take().unwrap(); @@ -137,7 +137,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { let now = now(); // If this request has already expired, then signal it and go // through another iteration - if active.get(0).target <= now { + if active[0].target <= now { signal(&mut active, &mut dead); continue; } @@ -145,7 +145,7 @@ fn helper(input: libc::c_int, messages: Receiver, _: ()) { // The actual timeout listed in the requests array is an // absolute date, so here we translate the absolute time to a // relative time. - let tm = active.get(0).target - now; + let tm = active[0].target - now; timeout.tv_sec = (tm / 1000) as libc::time_t; timeout.tv_usec = ((tm % 1000) * 1000) as libc::suseconds_t; &mut timeout as *mut libc::timeval diff --git a/src/libnative/lib.rs b/src/libnative/lib.rs index 71a1645f9ff15..656c7e4103c6e 100644 --- a/src/libnative/lib.rs +++ b/src/libnative/lib.rs @@ -56,7 +56,7 @@ html_root_url = "http://doc.rust-lang.org/nightly/")] #![deny(unused_result, unused_must_use)] -#![allow(non_camel_case_types, deprecated)] +#![allow(non_camel_case_types)] #![allow(unknown_features)] #![feature(default_type_params, lang_items, slicing_syntax)] diff --git a/src/libnative/task.rs b/src/libnative/task.rs index ba3f101720fa8..48e2c440dfc7b 100644 --- a/src/libnative/task.rs +++ b/src/libnative/task.rs @@ -26,7 +26,6 @@ use std::rt::thread::Thread; use std::rt; use io; -use task; use std::task::{TaskBuilder, Spawner}; /// Creates a new Task which is ready to execute as a 1:1 task. @@ -48,61 +47,49 @@ fn ops() -> Box { } } -/// Spawns a function with the default configuration -#[deprecated = "use the native method of NativeTaskBuilder instead"] -pub fn spawn(f: proc():Send) { - spawn_opts(TaskOpts { name: None, stack_size: None, on_exit: None }, f) -} - -/// Spawns a new task given the configuration options and a procedure to run -/// inside the task. -#[deprecated = "use the native method of NativeTaskBuilder instead"] -pub fn spawn_opts(opts: TaskOpts, f: proc():Send) { - let TaskOpts { name, stack_size, on_exit } = opts; - - let mut task = box Task::new(); - task.name = name; - task.death.on_exit = on_exit; - - let stack = stack_size.unwrap_or(rt::min_stack()); - let task = task; - let ops = ops(); - - // Note that this increment must happen *before* the spawn in order to - // guarantee that if this task exits it will always end up waiting for the - // spawned task to exit. - let token = bookkeeping::increment(); - - // Spawning a new OS thread guarantees that __morestack will never get - // triggered, but we must manually set up the actual stack bounds once this - // function starts executing. This raises the lower limit by a bit because - // by the time that this function is executing we've already consumed at - // least a little bit of stack (we don't know the exact byte address at - // which our stack started). - Thread::spawn_stack(stack, proc() { - let something_around_the_top_of_the_stack = 1; - let addr = &something_around_the_top_of_the_stack as *const int; - let my_stack = addr as uint; - unsafe { - stack::record_os_managed_stack_bounds(my_stack - stack + 1024, my_stack); - } - let mut ops = ops; - ops.stack_bounds = (my_stack - stack + 1024, my_stack); - - let mut f = Some(f); - let mut task = task; - task.put_runtime(ops); - drop(task.run(|| { f.take().unwrap()() }).destroy()); - drop(token); - }) -} - /// A spawner for native tasks pub struct NativeSpawner; impl Spawner for NativeSpawner { fn spawn(self, opts: TaskOpts, f: proc():Send) { - spawn_opts(opts, f) + let TaskOpts { name, stack_size, on_exit } = opts; + + let mut task = box Task::new(); + task.name = name; + task.death.on_exit = on_exit; + + let stack = stack_size.unwrap_or(rt::min_stack()); + let task = task; + let ops = ops(); + + // Note that this increment must happen *before* the spawn in order to + // guarantee that if this task exits it will always end up waiting for + // the spawned task to exit. + let token = bookkeeping::increment(); + + // Spawning a new OS thread guarantees that __morestack will never get + // triggered, but we must manually set up the actual stack bounds once + // this function starts executing. This raises the lower limit by a bit + // because by the time that this function is executing we've already + // consumed at least a little bit of stack (we don't know the exact byte + // address at which our stack started). + Thread::spawn_stack(stack, proc() { + let something_around_the_top_of_the_stack = 1; + let addr = &something_around_the_top_of_the_stack as *const int; + let my_stack = addr as uint; + unsafe { + stack::record_os_managed_stack_bounds(my_stack - stack + 1024, + my_stack); + } + let mut ops = ops; + ops.stack_bounds = (my_stack - stack + 1024, my_stack); + + let mut f = Some(f); + let mut task = task; + task.put_runtime(ops); + drop(task.run(|| { f.take().unwrap()() }).destroy()); + drop(token); + }) } } @@ -270,7 +257,7 @@ impl rt::Runtime for Ops { cur_task.put_runtime(self); Local::put(cur_task); - task::spawn_opts(opts, f); + NativeSpawner.spawn(opts, f); } fn local_io<'a>(&'a mut self) -> Option> { @@ -283,8 +270,9 @@ mod tests { use std::rt::local::Local; use std::rt::task::{Task, TaskOpts}; use std::task; - use std::task::TaskBuilder; - use super::{spawn, spawn_opts, Ops, NativeTaskBuilder}; + use std::task::{TaskBuilder, Spawner}; + + use super::{Ops, NativeTaskBuilder, NativeSpawner}; #[test] fn smoke() { @@ -312,7 +300,7 @@ mod tests { opts.stack_size = Some(20 * 4096); let (tx, rx) = channel(); opts.on_exit = Some(proc(r) tx.send(r)); - spawn_opts(opts, proc() {}); + NativeSpawner.spawn(opts, proc() {}); assert!(rx.recv().is_ok()); } @@ -321,7 +309,7 @@ mod tests { let mut opts = TaskOpts::new(); let (tx, rx) = channel(); opts.on_exit = Some(proc(r) tx.send(r)); - spawn_opts(opts, proc() { fail!() }); + NativeSpawner.spawn(opts, proc() { fail!() }); assert!(rx.recv().is_err()); } diff --git a/src/librand/isaac.rs b/src/librand/isaac.rs index 9bfd9177e348b..3d83012cecbf0 100644 --- a/src/librand/isaac.rs +++ b/src/librand/isaac.rs @@ -377,10 +377,10 @@ impl Isaac64Rng { let x = *self.mem.unsafe_get(base + mr_offset); a = mix + *self.mem.unsafe_get(base + m2_offset); let y = ind!(x) + a + b; - self.mem.unsafe_set(base + mr_offset, y); + *self.mem.unsafe_mut(base + mr_offset) = y; b = ind!(y >> RAND_SIZE_64_LEN) + x; - self.rsl.unsafe_set(base + mr_offset, b); + *self.rsl.unsafe_mut(base + mr_offset) = b; } }} ); @@ -394,10 +394,10 @@ impl Isaac64Rng { let x = *self.mem.unsafe_get(base + mr_offset); a = mix + *self.mem.unsafe_get(base + m2_offset); let y = ind!(x) + a + b; - self.mem.unsafe_set(base + mr_offset, y); + *self.mem.unsafe_mut(base + mr_offset) = y; b = ind!(y >> RAND_SIZE_64_LEN) + x; - self.rsl.unsafe_set(base + mr_offset, b); + *self.rsl.unsafe_mut(base + mr_offset) = b; } }} ); diff --git a/src/librand/lib.rs b/src/librand/lib.rs index ff7d3c296203e..ebaa0349f5b72 100644 --- a/src/librand/lib.rs +++ b/src/librand/lib.rs @@ -239,12 +239,6 @@ pub trait Rng { } } - /// Deprecated name for `choose()`. - #[deprecated = "replaced by .choose()"] - fn choose_option<'a, T>(&mut self, values: &'a [T]) -> Option<&'a T> { - self.choose(values) - } - /// Shuffle a mutable slice in place. /// /// # Example diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index fc5d726bf67c2..d47ca892b13b1 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -129,8 +129,6 @@ pub const RLIB_BYTECODE_OBJECT_V1_DATA_OFFSET: uint = pub fn find_crate_name(sess: Option<&Session>, attrs: &[ast::Attribute], input: &Input) -> String { - use syntax::crateid::CrateId; - let validate = |s: String, span: Option| { creader::validate_crate_name(sess, s.as_slice(), span); s @@ -168,25 +166,6 @@ pub fn find_crate_name(sess: Option<&Session>, Some((attr, s)) => return validate(s.get().to_string(), Some(attr.span)), None => {} } - let crate_id = attrs.iter().find(|at| at.check_name("crate_id")) - .and_then(|at| at.value_str().map(|s| (at, s))) - .and_then(|(at, s)| { - from_str::(s.get()).map(|id| (at, id)) - }); - match crate_id { - Some((attr, id)) => { - match sess { - Some(sess) => { - sess.span_warn(attr.span, "the #[crate_id] attribute is \ - deprecated for the \ - #[crate_name] attribute"); - } - None => {} - } - return validate(id.name, Some(attr.span)) - } - None => {} - } match *input { FileInput(ref path) => { match path.filestem_str() { @@ -274,18 +253,18 @@ pub fn sanitize(s: &str) -> String { // '.' doesn't occur in types and functions, so reuse it // for ':' and '-' - '-' | ':' => result.push_char('.'), + '-' | ':' => result.push('.'), // These are legal symbols 'a' ... 'z' | 'A' ... 'Z' | '0' ... '9' - | '_' | '.' | '$' => result.push_char(c), + | '_' | '.' | '$' => result.push(c), _ => { let mut tstr = String::new(); - char::escape_unicode(c, |c| tstr.push_char(c)); - result.push_char('$'); + char::escape_unicode(c, |c| tstr.push(c)); + result.push('$'); result.push_str(tstr.as_slice().slice_from(1)); } } @@ -334,7 +313,7 @@ pub fn mangle>(mut path: PI, None => {} } - n.push_char('E'); // End name-sequence. + n.push('E'); // End name-sequence. n } @@ -360,9 +339,9 @@ pub fn mangle_exported_name(ccx: &CrateContext, path: PathElems, let extra2 = id % EXTRA_CHARS.len(); let id = id / EXTRA_CHARS.len(); let extra3 = id % EXTRA_CHARS.len(); - hash.push_char(EXTRA_CHARS.as_bytes()[extra1] as char); - hash.push_char(EXTRA_CHARS.as_bytes()[extra2] as char); - hash.push_char(EXTRA_CHARS.as_bytes()[extra3] as char); + hash.push(EXTRA_CHARS.as_bytes()[extra1] as char); + hash.push(EXTRA_CHARS.as_bytes()[extra2] as char); + hash.push(EXTRA_CHARS.as_bytes()[extra3] as char); exported_name(path, hash.as_slice()) } @@ -838,8 +817,8 @@ fn link_natively(sess: &Session, trans: &CrateTranslation, dylib: bool, sess.note(str::from_utf8(output.as_slice()).unwrap()); sess.abort_if_errors(); } - debug!("linker stderr:\n{}", str::from_utf8_owned(prog.error).unwrap()); - debug!("linker stdout:\n{}", str::from_utf8_owned(prog.output).unwrap()); + debug!("linker stderr:\n{}", String::from_utf8(prog.error).unwrap()); + debug!("linker stdout:\n{}", String::from_utf8(prog.output).unwrap()); }, Err(e) => { sess.err(format!("could not exec the linker `{}`: {}", @@ -1088,7 +1067,7 @@ fn link_args(cmd: &mut Command, cmd.args(["-dynamiclib", "-Wl,-dylib"]); if sess.opts.cg.rpath { - let mut v = Vec::from_slice("-Wl,-install_name,@rpath/".as_bytes()); + let mut v = "-Wl,-install_name,@rpath/".as_bytes().to_vec(); v.push_all(out_filename.filename().unwrap()); cmd.arg(v.as_slice()); } @@ -1247,9 +1226,9 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session, // involves just passing the right -l flag. let data = if dylib { - trans.crate_formats.get(&config::CrateTypeDylib) + &trans.crate_formats[config::CrateTypeDylib] } else { - trans.crate_formats.get(&config::CrateTypeExecutable) + &trans.crate_formats[config::CrateTypeExecutable] }; // Invoke get_used_crates to ensure that we get a topological sorting of @@ -1260,7 +1239,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session, // We may not pass all crates through to the linker. Some crates may // appear statically in an existing dylib, meaning we'll pick up all the // symbols from the dylib. - let kind = match *data.get(cnum as uint - 1) { + let kind = match data[cnum as uint - 1] { Some(t) => t, None => continue }; @@ -1279,7 +1258,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.os != abi::OsWindows { - stem.tailn(3) + stem[3..] } else { stem } @@ -1362,7 +1341,7 @@ fn add_upstream_rust_crates(cmd: &mut Command, sess: &Session, let dir = cratepath.dirname(); if !dir.is_empty() { cmd.arg("-L").arg(dir); } - let mut v = Vec::from_slice("-l".as_bytes()); + let mut v = "-l".as_bytes().to_vec(); v.push_all(unlib(&sess.targ_cfg, cratepath.filestem().unwrap())); cmd.arg(v.as_slice()); } diff --git a/src/librustc/driver/config.rs b/src/librustc/driver/config.rs index f5423b22fe2ef..1f44808275f6c 100644 --- a/src/librustc/driver/config.rs +++ b/src/librustc/driver/config.rs @@ -487,7 +487,9 @@ pub fn build_configuration(sess: &Session) -> ast::CrateConfig { if sess.opts.test { append_configuration(&mut user_cfg, InternedString::new("test")) } - user_cfg.into_iter().collect::>().append(default_cfg.as_slice()) + let mut v = user_cfg.into_iter().collect::>(); + v.push_all(default_cfg.as_slice()); + v } pub fn get_os(triple: &str) -> Option { diff --git a/src/librustc/driver/driver.rs b/src/librustc/driver/driver.rs index ba9ec904bae4c..f6aab6ef47777 100644 --- a/src/librustc/driver/driver.rs +++ b/src/librustc/driver/driver.rs @@ -284,7 +284,7 @@ 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().get_dylib_search_paths(); - new_path.push_all_move(os::split_paths(_old_path.as_slice())); + new_path.extend(os::split_paths(_old_path.as_slice()).into_iter()); os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap()); } let cfg = syntax::ext::expand::ExpansionConfig { @@ -569,7 +569,7 @@ 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 = os::split_paths(old_path.as_slice()); - new_path.push_all_move(sess.host_filesearch().get_tools_search_paths()); + new_path.extend(sess.host_filesearch().get_tools_search_paths().into_iter()); os::setenv("PATH", os::join_paths(new_path.as_slice()).unwrap()); time(sess.time_passes(), "linking", (), |_| @@ -818,17 +818,6 @@ pub fn build_output_filenames(input: &Input, // If a crate name is present, we use it as the link name let stem = sess.opts.crate_name.clone().or_else(|| { attr::find_crate_name(attrs).map(|n| n.get().to_string()) - }).or_else(|| { - // NB: this clause can be removed once #[crate_id] is no longer - // deprecated. - // - // Also note that this will be warned about later so we don't - // warn about it here. - use syntax::crateid::CrateId; - attrs.iter().find(|at| at.check_name("crate_id")) - .and_then(|at| at.value_str()) - .and_then(|s| from_str::(s.get())) - .map(|id| id.name) }).unwrap_or(input.filestem()); OutputFilenames { diff --git a/src/librustc/driver/mod.rs b/src/librustc/driver/mod.rs index cb671d6e85f61..4a2e209f56282 100644 --- a/src/librustc/driver/mod.rs +++ b/src/librustc/driver/mod.rs @@ -43,7 +43,7 @@ static BUG_REPORT_URL: &'static str = "http://doc.rust-lang.org/complement-bugreport.html"; fn run_compiler(args: &[String]) { - let matches = match handle_options(Vec::from_slice(args)) { + let matches = match handle_options(args.to_vec()) { Some(matches) => matches, None => return }; @@ -76,7 +76,7 @@ fn run_compiler(args: &[String]) { early_error("no input filename given"); } 1u => { - let ifile = matches.free.get(0).as_slice(); + let ifile = matches.free[0].as_slice(); if ifile == "-" { let contents = io::stdin().read_to_end().unwrap(); let src = String::from_utf8(contents).unwrap(); @@ -216,7 +216,9 @@ Available lint options: .map(|&s| s.name.width(true)) .max().unwrap_or(0); let padded = |x: &str| { - " ".repeat(max_name_len - x.char_len()).append(x) + let mut s = " ".repeat(max_name_len - x.char_len()); + s.push_str(x); + s }; println!("Lint checks provided by rustc:\n"); @@ -240,7 +242,9 @@ Available lint options: .map(|&(s, _)| s.width(true)) .max().unwrap_or(0); let padded = |x: &str| { - " ".repeat(max_name_len - x.char_len()).append(x) + let mut s = " ".repeat(max_name_len - x.char_len()); + s.push_str(x); + s }; println!("Lint groups provided by rustc:\n"); @@ -313,7 +317,7 @@ fn describe_codegen_flags() { /// returns None. pub fn handle_options(mut args: Vec) -> Option { // Throw away the first argument, the name of the binary - let _binary = args.shift().unwrap(); + let _binary = args.remove(0).unwrap(); if args.is_empty() { usage(); diff --git a/src/librustc/driver/pretty.rs b/src/librustc/driver/pretty.rs index 75171af741110..19cd03f10a781 100644 --- a/src/librustc/driver/pretty.rs +++ b/src/librustc/driver/pretty.rs @@ -434,10 +434,8 @@ pub fn pretty_print_input(sess: Session, }; let src_name = driver::source_name(input); - let src = Vec::from_slice(sess.codemap() - .get_filemap(src_name.as_slice()) - .src - .as_bytes()); + let src = sess.codemap().get_filemap(src_name.as_slice()) + .src.as_bytes().to_vec(); let mut rdr = MemReader::new(src); let out = match ofile { diff --git a/src/librustc/lib.rs b/src/librustc/lib.rs index eb78762906e24..390648eab2e54 100644 --- a/src/librustc/lib.rs +++ b/src/librustc/lib.rs @@ -28,7 +28,6 @@ This API is completely unstable and subject to change. html_favicon_url = "http://www.rust-lang.org/favicon.ico", html_root_url = "http://doc.rust-lang.org/nightly/")] -#![allow(deprecated)] #![feature(default_type_params, globs, if_let, import_shadowing, macro_rules, phase, quote)] #![feature(slicing_syntax, struct_variant, unsafe_destructor)] #![feature(rustc_diagnostic_macros)] diff --git a/src/librustc/lint/builtin.rs b/src/librustc/lint/builtin.rs index 76234c4163721..2205dc42d47d6 100644 --- a/src/librustc/lint/builtin.rs +++ b/src/librustc/lint/builtin.rs @@ -883,7 +883,7 @@ impl NonSnakeCase { buf = String::new(); } last_upper = ch.is_uppercase(); - buf.push_char(ch.to_lowercase()); + buf.push(ch.to_lowercase()); } words.push(buf); } @@ -1062,7 +1062,7 @@ impl UnusedParens { ast::ExprMethodCall(_, _, ref exprs) => { // X { y: 1 }.bar(...) - contains_exterior_struct_lit(&**exprs.get(0)) + contains_exterior_struct_lit(&*exprs[0]) } _ => false @@ -1220,7 +1220,7 @@ impl UnusedMut { let used_mutables = cx.tcx.used_mut_nodes.borrow(); for (_, v) in mutables.iter() { if !v.iter().any(|e| used_mutables.contains(e)) { - cx.span_lint(UNUSED_MUT, cx.tcx.map.span(*v.get(0)), + cx.span_lint(UNUSED_MUT, cx.tcx.map.span(v[0]), "variable does not need to be mutable"); } } diff --git a/src/librustc/lint/context.rs b/src/librustc/lint/context.rs index 0f63000bff113..1107e44be3b03 100644 --- a/src/librustc/lint/context.rs +++ b/src/librustc/lint/context.rs @@ -141,7 +141,7 @@ impl LintStore { self.levels.insert(id, (lint.default_level, Default)); } } - self.passes.get_mut_ref().push(pass); + self.passes.as_mut().unwrap().push(pass); } pub fn register_group(&mut self, sess: Option<&Session>, diff --git a/src/librustc/metadata/csearch.rs b/src/librustc/metadata/csearch.rs index b7bd97e021965..7ec74eb1c3faf 100644 --- a/src/librustc/metadata/csearch.rs +++ b/src/librustc/metadata/csearch.rs @@ -93,8 +93,9 @@ pub fn get_item_path(tcx: &ty::ctxt, def: ast::DefId) -> Vec // FIXME #1920: This path is not always correct if the crate is not linked // into the root namespace. - (vec!(ast_map::PathMod(token::intern(cdata.name.as_slice())))).append( - path.as_slice()) + let mut r = vec![ast_map::PathMod(token::intern(cdata.name.as_slice()))]; + r.push_all(path.as_slice()); + r } pub enum found_ast<'ast> { diff --git a/src/librustc/metadata/cstore.rs b/src/librustc/metadata/cstore.rs index 5dafb7a661dfd..1d1012d9e4f04 100644 --- a/src/librustc/metadata/cstore.rs +++ b/src/librustc/metadata/cstore.rs @@ -95,7 +95,7 @@ impl CStore { } pub fn get_crate_data(&self, cnum: ast::CrateNum) -> Rc { - self.metas.borrow().get(&cnum).clone() + (*self.metas.borrow())[cnum].clone() } pub fn get_crate_hash(&self, cnum: ast::CrateNum) -> Svh { diff --git a/src/librustc/metadata/decoder.rs b/src/librustc/metadata/decoder.rs index dcf394aa3f406..456cf93d9b5c5 100644 --- a/src/librustc/metadata/decoder.rs +++ b/src/librustc/metadata/decoder.rs @@ -643,7 +643,7 @@ pub fn maybe_get_item_ast<'tcx>(cdata: Cmd, tcx: &ty::ctxt<'tcx>, id: ast::NodeI -> csearch::found_ast<'tcx> { debug!("Looking up item: {}", id); let item_doc = lookup_item(id, cdata.data()); - let path = Vec::from_slice(item_path(item_doc).init()); + let path = item_path(item_doc).init().to_vec(); match decode_inlined_item(cdata, tcx, path, item_doc) { Ok(ii) => csearch::found(ii), Err(path) => { diff --git a/src/librustc/metadata/encoder.rs b/src/librustc/metadata/encoder.rs index b9135e974c5d7..9106adcd3ef38 100644 --- a/src/librustc/metadata/encoder.rs +++ b/src/librustc/metadata/encoder.rs @@ -347,9 +347,9 @@ fn encode_enum_variant_info(ecx: &EncodeContext, encode_index(rbml_w, idx, write_i64); } } - if vi.get(i).disr_val != disr_val { - encode_disr_val(ecx, rbml_w, vi.get(i).disr_val); - disr_val = vi.get(i).disr_val; + if (*vi)[i].disr_val != disr_val { + encode_disr_val(ecx, rbml_w, (*vi)[i].disr_val); + disr_val = (*vi)[i].disr_val; } encode_bounds_and_type(rbml_w, ecx, &lookup_item_type(ecx.tcx, def_id)); @@ -401,7 +401,7 @@ fn encode_reexported_static_base_methods(ecx: &EncodeContext, match ecx.tcx.inherent_impls.borrow().find(&exp.def_id) { Some(implementations) => { for base_impl_did in implementations.iter() { - for &method_did in impl_items.get(base_impl_did).iter() { + for &method_did in (*impl_items)[*base_impl_did].iter() { let impl_item = ty::impl_or_trait_item( ecx.tcx, method_did.def_id()); @@ -515,7 +515,7 @@ fn each_auxiliary_node_id(item: &Item, callback: |NodeId| -> bool) -> bool { // If this is a newtype struct, return the constructor. match struct_def.ctor_id { Some(ctor_id) if struct_def.fields.len() > 0 && - struct_def.fields.get(0).node.kind.is_unnamed() => { + struct_def.fields[0].node.kind.is_unnamed() => { continue_ = callback(ctor_id); } _ => {} @@ -912,7 +912,7 @@ fn encode_info_for_associated_type(ecx: &EncodeContext, encode_stability(rbml_w, stab); let elem = ast_map::PathName(associated_type.ident.name); - encode_path(rbml_w, impl_path.chain(Some(elem).move_iter())); + encode_path(rbml_w, impl_path.chain(Some(elem).into_iter())); match typedef_opt { None => {} @@ -1229,7 +1229,7 @@ fn encode_info_for_item(ecx: &EncodeContext, // We need to encode information about the default methods we // have inherited, so we drive this based on the impl structure. let impl_items = tcx.impl_items.borrow(); - let items = impl_items.get(&def_id); + let items = &(*impl_items)[def_id]; add_to_index(item, rbml_w, index); rbml_w.start_tag(tag_items_data_item); @@ -1277,7 +1277,7 @@ fn encode_info_for_item(ecx: &EncodeContext, let num_implemented_methods = ast_items.len(); for (i, &trait_item_def_id) in items.iter().enumerate() { let ast_item = if i < num_implemented_methods { - Some(ast_items.get(i)) + Some(&ast_items[i]) } else { None }; @@ -1421,7 +1421,7 @@ fn encode_info_for_item(ecx: &EncodeContext, ty::TypeTraitItem(associated_type) => { let elem = ast_map::PathName(associated_type.ident.name); encode_path(rbml_w, - path.clone().chain(Some(elem).move_iter())); + path.clone().chain(Some(elem).into_iter())); encode_family(rbml_w, 'y'); @@ -1431,8 +1431,8 @@ fn encode_info_for_item(ecx: &EncodeContext, encode_parent_sort(rbml_w, 't'); - let trait_item = ms.get(i); - match ms.get(i) { + let trait_item = &ms[i]; + match &ms[i] { &RequiredMethod(ref tm) => { encode_attributes(rbml_w, tm.attrs.as_slice()); encode_item_sort(rbml_w, 'r'); diff --git a/src/librustc/metadata/loader.rs b/src/librustc/metadata/loader.rs index d6b02a1d0639e..36e04d84aa9d6 100644 --- a/src/librustc/metadata/loader.rs +++ b/src/librustc/metadata/loader.rs @@ -418,11 +418,11 @@ impl<'a> Context<'a> { (file.slice(rlib_prefix.len(), file.len() - ".rlib".len()), true) } else if dypair.map_or(false, |(_, suffix)| { - file.starts_with(dylib_prefix.get_ref().as_slice()) && + file.starts_with(dylib_prefix.as_ref().unwrap().as_slice()) && file.ends_with(suffix) }) { let (_, suffix) = dypair.unwrap(); - let dylib_prefix = dylib_prefix.get_ref().as_slice(); + let dylib_prefix = dylib_prefix.as_ref().unwrap().as_slice(); (file.slice(dylib_prefix.len(), file.len() - suffix.len()), false) } else { @@ -553,7 +553,7 @@ impl<'a> Context<'a> { self.crate_name).as_slice()); self.sess.span_note(self.span, format!(r"candidate #1: {}", - ret.get_ref() + ret.as_ref().unwrap() .display()).as_slice()); error = 1; ret = None; diff --git a/src/librustc/metadata/tydecode.rs b/src/librustc/metadata/tydecode.rs index fb2c8aace9514..6fbdceea37f9d 100644 --- a/src/librustc/metadata/tydecode.rs +++ b/src/librustc/metadata/tydecode.rs @@ -123,9 +123,9 @@ fn data_log_string(data: &[u8], pos: uint) -> String { for i in range(pos, data.len()) { let c = data[i]; if c > 0x20 && c <= 0x7F { - buf.push_char(c as char); + buf.push(c as char); } else { - buf.push_char('.'); + buf.push('.'); } } buf.push_str(">>"); @@ -339,7 +339,7 @@ fn parse_str(st: &mut PState, term: char) -> String { let mut result = String::new(); while peek(st) != term { unsafe { - result.push_bytes([next_byte(st)]) + result.as_mut_vec().push_all([next_byte(st)]) } } next(st); diff --git a/src/librustc/middle/astencode.rs b/src/librustc/middle/astencode.rs index 32fc045012d8c..f72d14ba68aae 100644 --- a/src/librustc/middle/astencode.rs +++ b/src/librustc/middle/astencode.rs @@ -1517,7 +1517,7 @@ impl<'a> rbml_decoder_decoder_helpers for reader::Decoder<'a> { fn type_string(doc: rbml::Doc) -> String { let mut str = String::new(); for i in range(doc.start, doc.end) { - str.push_char(doc.data[i] as char); + str.push(doc.data[i] as char); } str } diff --git a/src/librustc/middle/borrowck/gather_loans/move_error.rs b/src/librustc/middle/borrowck/gather_loans/move_error.rs index b1757a4eb2cbc..887c6bc3e3fdf 100644 --- a/src/librustc/middle/borrowck/gather_loans/move_error.rs +++ b/src/librustc/middle/borrowck/gather_loans/move_error.rs @@ -98,7 +98,7 @@ fn group_errors_with_same_origin(errors: &Vec) for ge in grouped_errors.iter_mut() { if move_from_id == ge.move_from.id && error.move_to.is_some() { debug!("appending move_to to list"); - ge.move_to_places.push_all_move(move_to); + ge.move_to_places.extend(move_to.into_iter()); return } } diff --git a/src/librustc/middle/borrowck/graphviz.rs b/src/librustc/middle/borrowck/graphviz.rs index 63d49dcd3036e..aab7fe8f31edc 100644 --- a/src/librustc/middle/borrowck/graphviz.rs +++ b/src/librustc/middle/borrowck/graphviz.rs @@ -91,14 +91,15 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> { saw_some = true; true }); - set.append("}") + set.push_str("}"); + set } fn dataflow_loans_for(&self, e: EntryOrExit, cfgidx: CFGIndex) -> String { let dfcx = &self.analysis_data.loans; let loan_index_to_path = |loan_index| { let all_loans = &self.analysis_data.all_loans; - all_loans.get(loan_index).loan_path() + all_loans[loan_index].loan_path() }; self.build_set(e, cfgidx, dfcx, loan_index_to_path) } @@ -108,7 +109,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> { let move_index_to_path = |move_index| { let move_data = &self.analysis_data.move_data.move_data; let moves = move_data.moves.borrow(); - let the_move = moves.get(move_index); + let the_move = &(*moves)[move_index]; move_data.path_loan_path(the_move.path) }; self.build_set(e, cfgidx, dfcx, move_index_to_path) @@ -119,7 +120,7 @@ impl<'a, 'tcx> DataflowLabeller<'a, 'tcx> { let assign_index_to_path = |assign_index| { let move_data = &self.analysis_data.move_data.move_data; let assignments = move_data.var_assignments.borrow(); - let assignment = assignments.get(assign_index); + let assignment = &(*assignments)[assign_index]; move_data.path_loan_path(assignment.path) }; self.build_set(e, cfgidx, dfcx, assign_index_to_path) diff --git a/src/librustc/middle/borrowck/mod.rs b/src/librustc/middle/borrowck/mod.rs index b4828e42cef86..4b552b5c17316 100644 --- a/src/librustc/middle/borrowck/mod.rs +++ b/src/librustc/middle/borrowck/mod.rs @@ -821,11 +821,11 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { self.append_autoderefd_loan_path_to_string(&**lp_base, out); match fname { mc::NamedField(fname) => { - out.push_char('.'); + out.push('.'); out.push_str(token::get_name(fname).get()); } mc::PositionalField(idx) => { - out.push_char('.'); + out.push('.'); out.push_str(idx.to_string().as_slice()); } } @@ -837,7 +837,7 @@ impl<'a, 'tcx> BorrowckCtxt<'a, 'tcx> { } LpExtend(ref lp_base, _, LpDeref(_)) => { - out.push_char('*'); + out.push('*'); self.append_loan_path_to_string(&**lp_base, out); } } diff --git a/src/librustc/middle/borrowck/move_data.rs b/src/librustc/middle/borrowck/move_data.rs index 4c2ee9fe551c4..5f3c46fcf4cd5 100644 --- a/src/librustc/middle/borrowck/move_data.rs +++ b/src/librustc/middle/borrowck/move_data.rs @@ -192,23 +192,23 @@ impl MoveData { } pub fn path_loan_path(&self, index: MovePathIndex) -> Rc { - self.paths.borrow().get(index.get()).loan_path.clone() + (*self.paths.borrow())[index.get()].loan_path.clone() } fn path_parent(&self, index: MovePathIndex) -> MovePathIndex { - self.paths.borrow().get(index.get()).parent + (*self.paths.borrow())[index.get()].parent } fn path_first_move(&self, index: MovePathIndex) -> MoveIndex { - self.paths.borrow().get(index.get()).first_move + (*self.paths.borrow())[index.get()].first_move } fn path_first_child(&self, index: MovePathIndex) -> MovePathIndex { - self.paths.borrow().get(index.get()).first_child + (*self.paths.borrow())[index.get()].first_child } fn path_next_sibling(&self, index: MovePathIndex) -> MovePathIndex { - self.paths.borrow().get(index.get()).next_sibling + (*self.paths.borrow())[index.get()].next_sibling } fn set_path_first_move(&self, @@ -225,7 +225,7 @@ impl MoveData { fn move_next_move(&self, index: MoveIndex) -> MoveIndex { //! Type safe indexing operator - self.moves.borrow().get(index.get()).next_move + (*self.moves.borrow())[index.get()].next_move } fn is_var_path(&self, index: MovePathIndex) -> bool { @@ -434,12 +434,12 @@ impl MoveData { match *path.loan_path { LpVar(id) => { let kill_id = tcx.region_maps.var_scope(id); - let path = *self.path_map.borrow().get(&path.loan_path); + let path = (*self.path_map.borrow())[path.loan_path]; self.kill_moves(path, kill_id, dfcx_moves); } LpUpvar(ty::UpvarId { var_id: _, closure_expr_id }) => { let kill_id = closure_to_block(closure_expr_id, tcx); - let path = *self.path_map.borrow().get(&path.loan_path); + let path = (*self.path_map.borrow())[path.loan_path]; self.kill_moves(path, kill_id, dfcx_moves); } LpExtend(..) => {} @@ -580,7 +580,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { for loan_path_index in self.move_data.path_map.borrow().find(&*loan_path).iter() { self.dfcx_moves.each_gen_bit(id, |move_index| { let the_move = self.move_data.moves.borrow(); - let the_move = the_move.get(move_index); + let the_move = (*the_move)[move_index]; if the_move.path == **loan_path_index { ret = Some(the_move.kind); false @@ -625,7 +625,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { self.dfcx_moves.each_bit_on_entry(id, |index| { let the_move = self.move_data.moves.borrow(); - let the_move = the_move.get(index); + let the_move = &(*the_move)[index]; let moved_path = the_move.path; if base_indices.iter().any(|x| x == &moved_path) { // Scenario 1 or 2: `loan_path` or some base path of @@ -675,7 +675,7 @@ impl<'a, 'tcx> FlowedMoveData<'a, 'tcx> { self.dfcx_assign.each_bit_on_entry(id, |index| { let assignment = self.move_data.var_assignments.borrow(); - let assignment = assignment.get(index); + let assignment = &(*assignment)[index]; if assignment.path == loan_path_index && !f(assignment) { false } else { diff --git a/src/librustc/middle/cfg/construct.rs b/src/librustc/middle/cfg/construct.rs index fa5a6a2e54aad..4b55a0b26098b 100644 --- a/src/librustc/middle/cfg/construct.rs +++ b/src/librustc/middle/cfg/construct.rs @@ -424,7 +424,7 @@ impl<'a, 'tcx> CFGBuilder<'a, 'tcx> { } ast::ExprMethodCall(_, _, ref args) => { - self.call(expr, pred, &**args.get(0), args.slice_from(1).iter().map(|e| &**e)) + self.call(expr, pred, &*args[0], args.slice_from(1).iter().map(|e| &**e)) } ast::ExprIndex(ref l, ref r) | diff --git a/src/librustc/middle/cfg/graphviz.rs b/src/librustc/middle/cfg/graphviz.rs index 84b96edc12652..bc48e476aec07 100644 --- a/src/librustc/middle/cfg/graphviz.rs +++ b/src/librustc/middle/cfg/graphviz.rs @@ -41,9 +41,9 @@ fn replace_newline_with_backslash_l(s: String) -> String { s.as_slice().chars().rev().take(2).collect(); last_two.reverse(); if last_two.as_slice() != ['\\', 'l'] { - s = s.append("\\l"); + s.push_str("\\l"); } - s.to_string() + s } else { s } @@ -76,16 +76,15 @@ impl<'a, 'ast> dot::Labeller<'a, Node<'a>, Edge<'a>> for LabelledCFG<'a, 'ast> { let mut put_one = false; for (i, &node_id) in e.data.exiting_scopes.iter().enumerate() { if put_one { - label = label.append(",\\l"); + label.push_str(",\\l"); } else { put_one = true; } let s = self.ast_map.node_to_string(node_id); // left-aligns the lines let s = replace_newline_with_backslash_l(s); - label = label.append(format!("exiting scope_{} {}", - i, - s.as_slice()).as_slice()); + label.push_str(format!("exiting scope_{} {}", i, + s.as_slice()).as_slice()); } dot::EscStr(label.into_maybe_owned()) } diff --git a/src/librustc/middle/check_match.rs b/src/librustc/middle/check_match.rs index abccc7623a759..7ffe5f42a5cce 100644 --- a/src/librustc/middle/check_match.rs +++ b/src/librustc/middle/check_match.rs @@ -66,7 +66,7 @@ impl<'a> fmt::Show for Matrix<'a> { let column_count = m.iter().map(|row| row.len()).max().unwrap_or(0u); assert!(m.iter().all(|row| row.len() == column_count)); let column_widths: Vec = range(0, column_count).map(|col| { - pretty_printed_matrix.iter().map(|row| row.get(col).len()).max().unwrap_or(0u) + pretty_printed_matrix.iter().map(|row| row[col].len()).max().unwrap_or(0u) }).collect(); let total_width = column_widths.iter().map(|n| *n).sum() + column_count * 3 + 1; @@ -76,7 +76,7 @@ impl<'a> fmt::Show for Matrix<'a> { try!(write!(f, "+")); for (column, pat_str) in row.into_iter().enumerate() { try!(write!(f, " ")); - f.width = Some(*column_widths.get(column)); + f.width = Some(column_widths[column]); try!(f.pad(pat_str.as_slice())); try!(write!(f, " +")); } @@ -269,7 +269,7 @@ fn check_arms(cx: &MatchCheckCtxt, arms: &[(Vec>, Option<&Expr>)], source } else { // find the first arm pattern so we can use its span let &(ref first_arm_pats, _) = &arms[0]; - let first_pat = first_arm_pats.get(0); + let first_pat = &first_arm_pats[0]; let span = first_pat.span; span_err!(cx.tcx.sess, span, E0162, "irrefutable if-let pattern"); printed_if_let_err = true; @@ -279,7 +279,7 @@ fn check_arms(cx: &MatchCheckCtxt, arms: &[(Vec>, Option<&Expr>)], source MatchWhileLetDesugar => { // find the first arm pattern so we can use its span let &(ref first_arm_pats, _) = &arms[0]; - let first_pat = first_arm_pats.get(0); + let first_pat = &first_arm_pats[0]; let span = first_pat.span; span_err!(cx.tcx.sess, span, E0165, "irrefutable while-let pattern"); }, @@ -475,7 +475,7 @@ fn construct_witness(cx: &MatchCheckCtxt, ctor: &Constructor, fn missing_constructor(cx: &MatchCheckCtxt, &Matrix(ref rows): &Matrix, left_ty: ty::t, max_slice_length: uint) -> Option { let used_constructors: Vec = rows.iter() - .flat_map(|row| pat_constructors(cx, *row.get(0), left_ty, max_slice_length).into_iter()) + .flat_map(|row| pat_constructors(cx, row[0], left_ty, max_slice_length).into_iter()) .collect(); all_constructors(cx, left_ty, max_slice_length) .into_iter() @@ -538,11 +538,11 @@ fn is_useful(cx: &MatchCheckCtxt, LeaveOutWitness => Useful }; } - if rows.get(0).len() == 0u { + if rows[0].len() == 0u { return NotUseful; } - let real_pat = match rows.iter().find(|r| r.get(0).id != DUMMY_NODE_ID) { - Some(r) => raw_pat(*r.get(0)), + let real_pat = match rows.iter().find(|r| (*r)[0].id != DUMMY_NODE_ID) { + Some(r) => raw_pat(r[0]), None if v.len() == 0 => return NotUseful, None => v[0] }; @@ -552,7 +552,7 @@ fn is_useful(cx: &MatchCheckCtxt, ty::pat_ty(cx.tcx, &*real_pat) }; - let max_slice_length = rows.iter().filter_map(|row| match row.get(0).node { + let max_slice_length = rows.iter().filter_map(|row| match row[0].node { PatVec(ref before, _, ref after) => Some(before.len() + after.len()), _ => None }).max().map_or(0, |v| v + 1); @@ -583,7 +583,7 @@ fn is_useful(cx: &MatchCheckCtxt, Some(constructor) => { let matrix = rows.iter().filter_map(|r| { if pat_is_binding_or_wild(&cx.tcx.def_map, raw_pat(r[0])) { - Some(Vec::from_slice(r.tail())) + Some(r.tail().to_vec()) } else { None } @@ -883,7 +883,11 @@ pub fn specialize<'a>(cx: &MatchCheckCtxt, r: &[&'a Pat], None } }; - head.map(|head| head.append(r[..col]).append(r[col + 1..])) + head.map(|mut head| { + head.push_all(r[..col]); + head.push_all(r[col + 1..]); + head + }) } fn check_local(cx: &mut MatchCheckCtxt, loc: &Local) { diff --git a/src/librustc/middle/dataflow.rs b/src/librustc/middle/dataflow.rs index a8b8eb2e3394d..d5557dfeeff1a 100644 --- a/src/librustc/middle/dataflow.rs +++ b/src/librustc/middle/dataflow.rs @@ -418,7 +418,7 @@ impl<'a, 'tcx, O:DataFlowOperator> DataFlowContext<'a, 'tcx, O> { let bits = self.kills.slice_mut(start, end); debug!("{:s} add_kills_from_flow_exits flow_exit={} bits={} [before]", self.analysis_name, flow_exit, mut_bits_to_string(bits)); - bits.copy_from(orig_kills.as_slice()); + bits.clone_from_slice(orig_kills.as_slice()); debug!("{:s} add_kills_from_flow_exits flow_exit={} bits={} [after]", self.analysis_name, flow_exit, mut_bits_to_string(bits)); } @@ -484,7 +484,7 @@ impl<'a, 'b, 'tcx, O:DataFlowOperator> PropagationContext<'a, 'b, 'tcx, O> { let (start, end) = self.dfcx.compute_id_range(node_index); // Initialize local bitvector with state on-entry. - in_out.copy_from(self.dfcx.on_entry.slice(start, end)); + in_out.clone_from_slice(self.dfcx.on_entry.slice(start, end)); // Compute state on-exit by applying transfer function to // state on-entry. @@ -550,13 +550,13 @@ fn bits_to_string(words: &[uint]) -> String { for &word in words.iter() { let mut v = word; for _ in range(0u, uint::BYTES) { - result.push_char(sep); + result.push(sep); result.push_str(format!("{:02x}", v & 0xFF).as_slice()); v >>= 8; sep = '-'; } } - result.push_char(']'); + result.push(']'); return result } diff --git a/src/librustc/middle/dead.rs b/src/librustc/middle/dead.rs index 61b013d795ea0..513d65c335d0f 100644 --- a/src/librustc/middle/dead.rs +++ b/src/librustc/middle/dead.rs @@ -157,8 +157,8 @@ impl<'a, 'tcx> MarkSymbolVisitor<'a, 'tcx> { } fn handle_field_pattern_match(&mut self, lhs: &ast::Pat, pats: &[ast::FieldPat]) { - let id = match self.tcx.def_map.borrow().get(&lhs.id) { - &def::DefVariant(_, id, _) => id, + let id = match (*self.tcx.def_map.borrow())[lhs.id] { + def::DefVariant(_, id, _) => id, _ => { match ty::ty_to_def_id(ty::node_id_to_type(self.tcx, lhs.id)) { @@ -494,7 +494,7 @@ impl<'a, 'tcx> DeadVisitor<'a, 'tcx> { None => (), Some(impl_list) => { for impl_did in impl_list.iter() { - for item_did in impl_items.get(impl_did).iter() { + for item_did in (*impl_items)[*impl_did].iter() { if self.live_symbols.contains(&item_did.def_id() .node) { return true; diff --git a/src/librustc/middle/effect.rs b/src/librustc/middle/effect.rs index bde868cdf6d07..d4c8335d8e55f 100644 --- a/src/librustc/middle/effect.rs +++ b/src/librustc/middle/effect.rs @@ -145,7 +145,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EffectCheckVisitor<'a, 'tcx> { match expr.node { ast::ExprMethodCall(_, _, _) => { let method_call = MethodCall::expr(expr.id); - let base_type = self.tcx.method_map.borrow().get(&method_call).ty; + let base_type = (*self.tcx.method_map.borrow())[method_call].ty; debug!("effect: method call case, base type is {}", ppaux::ty_to_string(self.tcx, base_type)); if type_is_unsafe_function(base_type) { diff --git a/src/librustc/middle/expr_use_visitor.rs b/src/librustc/middle/expr_use_visitor.rs index 65633cfb34cd7..c413eb67a73ac 100644 --- a/src/librustc/middle/expr_use_visitor.rs +++ b/src/librustc/middle/expr_use_visitor.rs @@ -738,7 +738,7 @@ impl<'d,'t,'tcx,TYPER:mc::Typer<'tcx>> ExprUseVisitor<'d,'t,TYPER> { 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).get(0); + let self_ty = ty::ty_fn_args(method_ty)[0]; let (m, r) = match ty::get(self_ty).sty { ty::ty_rptr(r, ref m) => (m.mutbl, r), _ => self.tcx().sess.span_bug(expr.span, diff --git a/src/librustc/middle/graph.rs b/src/librustc/middle/graph.rs index 463eaa40ae03e..4775f945f5c1f 100644 --- a/src/librustc/middle/graph.rs +++ b/src/librustc/middle/graph.rs @@ -146,11 +146,11 @@ impl Graph { } pub fn node_data<'a>(&'a self, idx: NodeIndex) -> &'a N { - &self.nodes.get(idx.get()).data + &self.nodes[idx.get()].data } pub fn node<'a>(&'a self, idx: NodeIndex) -> &'a Node { - self.nodes.get(idx.get()) + &self.nodes[idx.get()] } /////////////////////////////////////////////////////////////////////////// @@ -167,9 +167,9 @@ impl Graph { let idx = self.next_edge_index(); // read current first of the list of edges from each node - let source_first = self.nodes.get(source.get()) + let source_first = self.nodes[source.get()] .first_edge[Outgoing.repr]; - let target_first = self.nodes.get(target.get()) + let target_first = self.nodes[target.get()] .first_edge[Incoming.repr]; // create the new edge, with the previous firsts from each node @@ -193,11 +193,11 @@ impl Graph { } pub fn edge_data<'a>(&'a self, idx: EdgeIndex) -> &'a E { - &self.edges.get(idx.get()).data + &self.edges[idx.get()].data } pub fn edge<'a>(&'a self, idx: EdgeIndex) -> &'a Edge { - self.edges.get(idx.get()) + &self.edges[idx.get()] } pub fn first_adjacent(&self, node: NodeIndex, dir: Direction) -> EdgeIndex { @@ -205,7 +205,7 @@ impl Graph { //! This is useful if you wish to modify the graph while walking //! the linked list of edges. - self.nodes.get(node.get()).first_edge[dir.repr] + self.nodes[node.get()].first_edge[dir.repr] } pub fn next_adjacent(&self, edge: EdgeIndex, dir: Direction) -> EdgeIndex { @@ -213,7 +213,7 @@ impl Graph { //! This is useful if you wish to modify the graph while walking //! the linked list of edges. - self.edges.get(edge.get()).next_edge[dir.repr] + self.edges[edge.get()].next_edge[dir.repr] } /////////////////////////////////////////////////////////////////////////// @@ -257,7 +257,7 @@ impl Graph { let mut edge_idx = self.first_adjacent(node, dir); while edge_idx != InvalidEdgeIndex { - let edge = self.edges.get(edge_idx.get()); + let edge = &self.edges[edge_idx.get()]; if !f(edge_idx, edge) { return false; } diff --git a/src/librustc/middle/intrinsicck.rs b/src/librustc/middle/intrinsicck.rs index de291595cccfb..d7707be58bb58 100644 --- a/src/librustc/middle/intrinsicck.rs +++ b/src/librustc/middle/intrinsicck.rs @@ -126,7 +126,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for IntrinsicCheckingVisitor<'a, 'tcx> { match ty::get(typ).sty { ty_bare_fn(ref bare_fn_ty) if bare_fn_ty.abi == RustIntrinsic => { - let from = *bare_fn_ty.sig.inputs.get(0); + let from = bare_fn_ty.sig.inputs[0]; let to = bare_fn_ty.sig.output; self.check_transmute(expr.span, from, to, expr.id); } diff --git a/src/librustc/middle/lang_items.rs b/src/librustc/middle/lang_items.rs index 68411549c3cef..f2d1a5e1d9272 100644 --- a/src/librustc/middle/lang_items.rs +++ b/src/librustc/middle/lang_items.rs @@ -76,9 +76,9 @@ impl LanguageItems { } pub fn require(&self, it: LangItem) -> Result { - match self.items.get(it as uint) { - &Some(id) => Ok(id), - &None => { + match self.items[it as uint] { + Some(id) => Ok(id), + None => { Err(format!("requires `{}` lang_item", LanguageItems::item_name(it as uint))) } @@ -113,7 +113,7 @@ impl LanguageItems { $( #[allow(dead_code)] pub fn $method(&self) -> Option { - *self.items.get($variant as uint) + self.items[$variant as uint] } )* } @@ -162,12 +162,12 @@ impl<'a> LanguageItemCollector<'a> { pub fn collect_item(&mut self, item_index: uint, item_def_id: ast::DefId, span: Span) { // Check for duplicates. - match self.items.items.get(item_index) { - &Some(original_def_id) if original_def_id != item_def_id => { + match self.items.items[item_index] { + Some(original_def_id) if original_def_id != item_def_id => { span_err!(self.session, span, E0152, "duplicate entry for `{}`", LanguageItems::item_name(item_index)); } - &Some(_) | &None => { + Some(_) | None => { // OK. } } diff --git a/src/librustc/middle/liveness.rs b/src/librustc/middle/liveness.rs index 490e49d051ee5..63e9a80adc61a 100644 --- a/src/librustc/middle/liveness.rs +++ b/src/librustc/middle/liveness.rs @@ -327,11 +327,11 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> { } fn variable_name(&self, var: Variable) -> String { - match self.var_kinds.get(var.get()) { - &Local(LocalInfo { ident: nm, .. }) | &Arg(_, nm) => { + match self.var_kinds[var.get()] { + Local(LocalInfo { ident: nm, .. }) | Arg(_, nm) => { token::get_ident(nm).get().to_string() }, - &ImplicitRet => "".to_string() + ImplicitRet => "".to_string() } } @@ -340,7 +340,7 @@ impl<'a, 'tcx> IrMaps<'a, 'tcx> { } fn lnk(&self, ln: LiveNode) -> LiveNodeKind { - *self.lnks.get(ln.get()) + self.lnks[ln.get()] } } @@ -647,7 +647,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { fn live_on_entry(&self, ln: LiveNode, var: Variable) -> Option { assert!(ln.is_valid()); - let reader = self.users.get(self.idx(ln, var)).reader; + let reader = self.users[self.idx(ln, var)].reader; if reader.is_valid() {Some(self.ir.lnk(reader))} else {None} } @@ -656,25 +656,25 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { */ fn live_on_exit(&self, ln: LiveNode, var: Variable) -> Option { - let successor = *self.successors.get(ln.get()); + let successor = self.successors[ln.get()]; self.live_on_entry(successor, var) } fn used_on_entry(&self, ln: LiveNode, var: Variable) -> bool { assert!(ln.is_valid()); - self.users.get(self.idx(ln, var)).used + self.users[self.idx(ln, var)].used } fn assigned_on_entry(&self, ln: LiveNode, var: Variable) -> Option { assert!(ln.is_valid()); - let writer = self.users.get(self.idx(ln, var)).writer; + let writer = self.users[self.idx(ln, var)].writer; if writer.is_valid() {Some(self.ir.lnk(writer))} else {None} } fn assigned_on_exit(&self, ln: LiveNode, var: Variable) -> Option { - let successor = *self.successors.get(ln.get()); + let successor = self.successors[ln.get()]; self.assigned_on_entry(successor, var) } @@ -736,10 +736,10 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { { let wr = &mut wr as &mut io::Writer; write!(wr, "[ln({}) of kind {} reads", ln.get(), self.ir.lnk(ln)); - self.write_vars(wr, ln, |idx| self.users.get(idx).reader); + self.write_vars(wr, ln, |idx| self.users[idx].reader); write!(wr, " writes"); - self.write_vars(wr, ln, |idx| self.users.get(idx).writer); - write!(wr, " precedes {}]", self.successors.get(ln.get()).to_string()); + self.write_vars(wr, ln, |idx| self.users[idx].writer); + write!(wr, " precedes {}]", self.successors[ln.get()].to_string()); } str::from_utf8(wr.unwrap().as_slice()).unwrap().to_string() } @@ -762,7 +762,7 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { *self.successors.get_mut(ln.get()) = succ_ln; self.indices2(ln, succ_ln, |this, idx, succ_idx| { - *this.users.get_mut(idx) = *this.users.get(succ_idx) + *this.users.get_mut(idx) = this.users[succ_idx] }); debug!("init_from_succ(ln={}, succ={})", self.ln_str(ln), self.ln_str(succ_ln)); @@ -777,11 +777,11 @@ impl<'a, 'tcx> Liveness<'a, 'tcx> { let mut changed = false; self.indices2(ln, succ_ln, |this, idx, succ_idx| { - changed |= copy_if_invalid(this.users.get(succ_idx).reader, + changed |= copy_if_invalid(this.users[succ_idx].reader, &mut this.users.get_mut(idx).reader); - changed |= copy_if_invalid(this.users.get(succ_idx).writer, + changed |= copy_if_invalid(this.users[succ_idx].writer, &mut this.users.get_mut(idx).writer); - if this.users.get(succ_idx).used && !this.users.get(idx).used { + if this.users[succ_idx].used && !this.users[idx].used { this.users.get_mut(idx).used = true; changed = true; } diff --git a/src/librustc/middle/mem_categorization.rs b/src/librustc/middle/mem_categorization.rs index e43996559417b..9bd3f49eea6ba 100644 --- a/src/librustc/middle/mem_categorization.rs +++ b/src/librustc/middle/mem_categorization.rs @@ -500,7 +500,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } ast::ExprPath(_) => { - let def = *self.tcx().def_map.borrow().get(&expr.id); + let def = (*self.tcx().def_map.borrow())[expr.id]; self.cat_def(expr.id, expr.span, expr_ty, def) } @@ -597,7 +597,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { } ty::ty_unboxed_closure(closure_id, _) => { let unboxed_closures = self.typer.unboxed_closures().borrow(); - let kind = unboxed_closures.get(&closure_id).kind; + let kind = (*unboxed_closures)[closure_id].kind; let mode = self.typer.capture_mode(fn_node_id); self.cat_upvar(id, span, var_id, fn_node_id, kind, mode, true) } @@ -953,7 +953,7 @@ impl<'t,'tcx,TYPER:Typer<'tcx>> MemCategorizationContext<'t,TYPER> { Some(method_ty) => { let ref_ty = ty::ty_fn_ret(method_ty); base_cmt = self.cat_rvalue_node(elt.id(), elt.span(), ref_ty); - *ty::ty_fn_args(method_ty).get(0) + ty::ty_fn_args(method_ty)[0] } None => { match ty::array_element_ty(base_cmt.ty) { diff --git a/src/librustc/middle/privacy.rs b/src/librustc/middle/privacy.rs index 6e430760e368f..138c671ceb66b 100644 --- a/src/librustc/middle/privacy.rs +++ b/src/librustc/middle/privacy.rs @@ -348,7 +348,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for EmbargoVisitor<'a, 'tcx> { // crate module gets processed as well. if self.prev_exported { assert!(self.exp_map2.contains_key(&id), "wut {}", id); - for export in self.exp_map2.get(&id).iter() { + for export in self.exp_map2[id].iter() { if is_local(export.def_id) { self.reexports.insert(export.def_id.node); } @@ -524,7 +524,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { // if we've reached the root, then everything was allowable and this // access is public. if closest_private_id == ast::CRATE_NODE_ID { return Allowable } - closest_private_id = *self.parents.get(&closest_private_id); + closest_private_id = self.parents[closest_private_id]; // If we reached the top, then we were public all the way down and // we can allow this access. @@ -542,7 +542,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { /// whether the node is accessible by the current module that iteration is /// inside. fn private_accessible(&self, id: ast::NodeId) -> bool { - let parent = *self.parents.get(&id); + let parent = self.parents[id]; debug!("privacy - accessible parent {}", self.nodestr(parent)); // After finding `did`'s closest private member, we roll ourselves back @@ -566,7 +566,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { _ => {} } - cur = *self.parents.get(&cur); + cur = self.parents[cur]; } } @@ -658,7 +658,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { debug!("privacy - check named field {} in struct {}", ident.name, id); fields.iter().find(|f| f.name == ident.name).unwrap() } - UnnamedField(idx) => fields.get(idx) + UnnamedField(idx) => &fields[idx] }; if field.vis == ast::Public || (is_local(field.id) && self.private_accessible(field.id.node)) { @@ -734,7 +734,7 @@ impl<'a, 'tcx> PrivacyVisitor<'a, 'tcx> { name).as_slice()) }; - match *self.last_private_map.get(&path_id) { + match self.last_private_map[path_id] { resolve::LastMod(resolve::AllPublic) => {}, resolve::LastMod(resolve::DependsOn(def)) => { self.report_error(ck_public(def)); diff --git a/src/librustc/middle/reachable.rs b/src/librustc/middle/reachable.rs index 5d6f7048b82e1..4506cd7e46349 100644 --- a/src/librustc/middle/reachable.rs +++ b/src/librustc/middle/reachable.rs @@ -138,7 +138,7 @@ impl<'a, 'tcx, 'v> Visitor<'v> for ReachableContext<'a, 'tcx> { } ast::ExprMethodCall(..) => { let method_call = typeck::MethodCall::expr(expr.id); - match self.tcx.method_map.borrow().get(&method_call).origin { + match (*self.tcx.method_map.borrow())[method_call].origin { typeck::MethodStatic(def_id) => { if is_local(def_id) { if self.def_id_represents_local_inlined_item(def_id) { diff --git a/src/librustc/middle/region.rs b/src/librustc/middle/region.rs index cf48e1899d18e..7c16196f5c216 100644 --- a/src/librustc/middle/region.rs +++ b/src/librustc/middle/region.rs @@ -334,7 +334,7 @@ impl RegionMaps { // where they diverge. If one vector is a suffix of the other, // then the corresponding scope is a superscope of the other. - if *a_ancestors.get(a_index) != *b_ancestors.get(b_index) { + if a_ancestors[a_index] != b_ancestors[b_index] { return None; } @@ -345,8 +345,8 @@ impl RegionMaps { if b_index == 0u { return Some(scope_b); } a_index -= 1u; b_index -= 1u; - if *a_ancestors.get(a_index) != *b_ancestors.get(b_index) { - return Some(*a_ancestors.get(a_index + 1u)); + if a_ancestors[a_index] != b_ancestors[b_index] { + return Some(a_ancestors[a_index + 1]); } } diff --git a/src/librustc/middle/resolve.rs b/src/librustc/middle/resolve.rs index 0aff56ba3cfc5..eaec715a6a7e4 100644 --- a/src/librustc/middle/resolve.rs +++ b/src/librustc/middle/resolve.rs @@ -1307,11 +1307,13 @@ impl<'a> Resolver<'a> { // If this is a newtype or unit-like struct, define a name // in the value namespace as well - ctor_id.while_some(|cid| { - name_bindings.define_value(DefStruct(local_def(cid)), sp, - is_public); - None - }); + match ctor_id { + Some(cid) => { + name_bindings.define_value(DefStruct(local_def(cid)), + sp, is_public); + } + None => {} + } // Record the def ID and fields of this struct. let named_fields = struct_def.fields.iter().filter_map(|f| { @@ -1644,7 +1646,7 @@ impl<'a> Resolver<'a> { } }; let module_path = module_path.as_slice().init(); - (Vec::from_slice(module_path), name) + (module_path.to_vec(), name) } }; self.build_import_directive( @@ -2232,7 +2234,7 @@ impl<'a> Resolver<'a> { let import_count = imports.len(); while module.resolved_import_count.get() < import_count { let import_index = module.resolved_import_count.get(); - let import_directive = imports.get(import_index); + let import_directive = &(*imports)[import_index]; match self.resolve_import_for_module(module.clone(), import_directive) { Failed(err) => { @@ -3669,15 +3671,15 @@ impl<'a> Resolver<'a> { if index != import_count { let sn = self.session .codemap() - .span_to_snippet(imports.get(index).span) + .span_to_snippet((*imports)[index].span) .unwrap(); if sn.as_slice().contains("::") { - self.resolve_error(imports.get(index).span, + self.resolve_error((*imports)[index].span, "unresolved import"); } else { let err = format!("unresolved import (maybe you meant `{}::*`?)", sn.as_slice().slice(0, sn.len())); - self.resolve_error(imports.get(index).span, err.as_slice()); + self.resolve_error((*imports)[index].span, err.as_slice()); } } @@ -3905,12 +3907,17 @@ impl<'a> Resolver<'a> { def = DefUpvar(node_id, function_id, last_proc_body_id); let mut seen = self.freevars_seen.borrow_mut(); - let seen = seen.find_or_insert(function_id, NodeSet::new()); + let seen = match seen.entry(function_id) { + Occupied(v) => v.into_mut(), + Vacant(v) => v.set(NodeSet::new()), + }; if seen.contains(&node_id) { continue; } - self.freevars.borrow_mut().find_or_insert(function_id, vec![]) - .push(Freevar { def: prev_def, span: span }); + match self.freevars.borrow_mut().entry(function_id) { + Occupied(v) => v.into_mut(), + Vacant(v) => v.set(vec![]), + }.push(Freevar { def: prev_def, span: span }); seen.insert(node_id); } MethodRibKind(item_id, _) => { @@ -4714,7 +4721,7 @@ impl<'a> Resolver<'a> { if arm.pats.len() == 0 { return } - let map_0 = self.binding_mode_map(&**arm.pats.get(0)); + let map_0 = self.binding_mode_map(&*arm.pats[0]); for (i, p) in arm.pats.iter().enumerate() { let map_i = self.binding_mode_map(&**p); @@ -5695,18 +5702,18 @@ impl<'a> Resolver<'a> { for (i, other) in maybes.iter().enumerate() { *values.get_mut(i) = name.lev_distance(other.get()); - if *values.get(i) <= *values.get(smallest) { + if values[i] <= values[smallest] { smallest = i; } } if values.len() > 0 && - *values.get(smallest) != uint::MAX && - *values.get(smallest) < name.len() + 2 && - *values.get(smallest) <= max_distance && - name != maybes.get(smallest).get() { + values[smallest] != uint::MAX && + values[smallest] < name.len() + 2 && + values[smallest] <= max_distance && + name != maybes[smallest].get() { - Some(maybes.get(smallest).get().to_string()) + Some(maybes[smallest].get().to_string()) } else { None diff --git a/src/librustc/middle/resolve_lifetime.rs b/src/librustc/middle/resolve_lifetime.rs index 6f517f1f166b9..eda4c241f86cf 100644 --- a/src/librustc/middle/resolve_lifetime.rs +++ b/src/librustc/middle/resolve_lifetime.rs @@ -399,7 +399,7 @@ impl<'a> LifetimeContext<'a> { fn check_lifetime_defs(&mut self, lifetimes: &Vec) { for i in range(0, lifetimes.len()) { - let lifetime_i = lifetimes.get(i); + let lifetime_i = &lifetimes[i]; let special_idents = [special_idents::static_lifetime]; for lifetime in lifetimes.iter() { @@ -413,7 +413,7 @@ impl<'a> LifetimeContext<'a> { } for j in range(i + 1, lifetimes.len()) { - let lifetime_j = lifetimes.get(j); + let lifetime_j = &lifetimes[j]; if lifetime_i.lifetime.name == lifetime_j.lifetime.name { self.sess.span_err( diff --git a/src/librustc/middle/save/mod.rs b/src/librustc/middle/save/mod.rs index 9dfde7ec08415..dd9601f1c3cfa 100644 --- a/src/librustc/middle/save/mod.rs +++ b/src/librustc/middle/save/mod.rs @@ -208,7 +208,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { self.sess.bug(format!("def_map has no key for {} in lookup_type_ref", ref_id).as_slice()); } - let def = *self.analysis.ty_cx.def_map.borrow().get(&ref_id); + let def = (*self.analysis.ty_cx.def_map.borrow())[ref_id]; match def { def::DefPrimTy(_) => None, _ => Some(def.def_id()), @@ -221,7 +221,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { self.sess.span_bug(span, format!("def_map has no key for {} in lookup_def_kind", ref_id).as_slice()); } - let def = *def_map.get(&ref_id); + let def = (*def_map)[ref_id]; match def { def::DefMod(_) | def::DefForeignMod(_) => Some(recorder::ModRef), @@ -261,7 +261,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { let span_utils = self.span; for &(id, ref p, _, _) in self.collected_paths.iter() { let typ = ppaux::ty_to_string(&self.analysis.ty_cx, - *self.analysis.ty_cx.node_types.borrow().get(&(id as uint))); + (*self.analysis.ty_cx.node_types.borrow())[id as uint]); // get the span only for the name of the variable (I hope the path is only ever a // variable name, but who knows?) self.fmt.formal_str(p.span, @@ -302,7 +302,8 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { }, None => {} } - result.append(">::") + result.push_str(">::"); + result } _ => { self.sess.span_bug(method.span, @@ -326,8 +327,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { scope_id = def_id.node; match self.analysis.ty_cx.map.get(def_id.node) { NodeItem(_) => { - let result = ty::item_path_str(&self.analysis.ty_cx, def_id); - result.append("::") + let mut result = ty::item_path_str(&self.analysis.ty_cx, def_id); + result.push_str("::"); + result } _ => { self.sess.span_bug(method.span, @@ -350,12 +352,16 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { // record the decl for this def (if it has one) let decl_id = ty::trait_item_of_item(&self.analysis.ty_cx, ast_util::local_def(method.id)) - .filtered(|def_id| { - match *def_id { + .and_then(|def_id| { + if match def_id { ty::MethodTraitItemId(def_id) => { method.id != 0 && def_id.node == 0 } ty::TypeTraitItemId(_) => false, + } { + Some(def_id) + } else { + None } }); let decl_id = match decl_id { @@ -421,7 +427,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { let name = get_ident(ident); let qualname = format!("{}::{}", qualname, name); let typ = ppaux::ty_to_string(&self.analysis.ty_cx, - *self.analysis.ty_cx.node_types.borrow().get(&(field.node.id as uint))); + (*self.analysis.ty_cx.node_types.borrow())[field.node.id as uint]); match self.span.sub_span_before_token(field.span, token::COLON) { Some(sub_span) => self.fmt.field_str(field.span, Some(sub_span), @@ -590,7 +596,9 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { for variant in enum_definition.variants.iter() { let name = get_ident(variant.node.name); let name = name.get(); - let qualname = qualname.clone().append("::").append(name); + let mut qualname = qualname.clone(); + qualname.push_str("::"); + qualname.push_str(name); let val = self.span.snippet(variant.span); match variant.node.kind { ast::TupleVariantKind(ref args) => { @@ -758,7 +766,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { format!("def_map has no key for {} in visit_expr", ex.id).as_slice()); } - let def = def_map.get(&ex.id); + let def = &(*def_map)[ex.id]; let sub_span = self.span.span_for_last_ident(ex.span); match *def { def::DefUpvar(..) | @@ -796,7 +804,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { .ty_cx .impl_items .borrow(); - Some(impl_items.get(&def_id) + Some((*impl_items)[def_id] .iter() .find(|mr| { ty::impl_or_trait_item( @@ -897,7 +905,7 @@ impl <'l, 'tcx> DxrVisitor<'l, 'tcx> { ex: &ast::Expr, args: &Vec>) { let method_map = self.analysis.ty_cx.method_map.borrow(); - let method_callee = method_map.get(&typeck::MethodCall::expr(ex.id)); + let method_callee = &(*method_map)[typeck::MethodCall::expr(ex.id)]; let (def_id, decl_id) = match method_callee.origin { typeck::MethodStatic(def_id) | typeck::MethodStaticUnboxedClosure(def_id) => { @@ -1116,7 +1124,9 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { ast_util::local_def(method_type.id)) { Some(def_id) => { scope_id = def_id.node; - ty::item_path_str(&self.analysis.ty_cx, def_id).append("::") + let mut s = ty::item_path_str(&self.analysis.ty_cx, def_id); + s.push_str("::"); + s }, None => { self.sess.span_bug(method_type.span, @@ -1347,7 +1357,8 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { return } - let id = String::from_str("$").append(ex.id.to_string().as_slice()); + let mut id = String::from_str("$"); + id.push_str(ex.id.to_string().as_slice()); self.process_formals(&decl.inputs, id.as_slice()); // walk arg and return types @@ -1399,7 +1410,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { format!("def_map has no key for {} in visit_arm", id).as_slice()); } - let def = def_map.get(&id); + let def = &(*def_map)[id]; match *def { def::DefLocal(id) => self.fmt.variable_str(p.span, sub_span, @@ -1449,7 +1460,7 @@ impl<'l, 'tcx, 'v> Visitor<'v> for DxrVisitor<'l, 'tcx> { for &(id, ref p, ref immut, _) in self.collected_paths.iter() { let value = if *immut { value.to_string() } else { "".to_string() }; let types = self.analysis.ty_cx.node_types.borrow(); - let typ = ppaux::ty_to_string(&self.analysis.ty_cx, *types.get(&(id as uint))); + let typ = ppaux::ty_to_string(&self.analysis.ty_cx, (*types)[id as uint]); // Get the span only for the name of the variable (I hope the path // is only ever a variable name, but who knows?). let sub_span = self.span.span_for_last_ident(p.span); diff --git a/src/librustc/middle/save/recorder.rs b/src/librustc/middle/save/recorder.rs index 0695b6b360c2c..9dd2e8d143770 100644 --- a/src/librustc/middle/save/recorder.rs +++ b/src/librustc/middle/save/recorder.rs @@ -165,12 +165,18 @@ impl<'a> FmtStrs<'a> { let pairs = fields.iter().zip(values); let mut strs = pairs.map(|(f, v)| format!(",{},\"{}\"", f, escape( if *f == "qualname" { - self.krate.clone().append("::").append(v) + let mut n = self.krate.clone(); + n.push_str("::"); + n.push_str(v); + n } else { String::from_str(v) } ))); - Some(strs.fold(String::new(), |s, ss| s.append(ss.as_slice()))) + Some(strs.fold(String::new(), |mut s, ss| { + s.push_str(ss.as_slice()); + s + })) } pub fn record_without_span(&mut self, @@ -195,8 +201,10 @@ impl<'a> FmtStrs<'a> { None => return, }; - let result = String::from_str(label); - self.recorder.record(result.append(values_str.as_slice()).append("\n").as_slice()); + let mut result = String::from_str(label); + result.push_str(values_str.as_slice()); + result.push_str("\n"); + self.recorder.record(result.as_slice()); } pub fn record_with_span(&mut self, @@ -252,7 +260,9 @@ impl<'a> FmtStrs<'a> { // the local case they can be overridden in one block and there is no nice way // to refer to such a scope in english, so we just hack it by appending the // variable def's node id - let qualname = String::from_str(name).append("$").append(id.to_string().as_slice()); + let mut qualname = String::from_str(name); + qualname.push_str("$"); + qualname.push_str(id.to_string().as_slice()); self.check_and_record(Variable, span, sub_span, @@ -267,7 +277,9 @@ impl<'a> FmtStrs<'a> { fn_name: &str, name: &str, typ: &str) { - let qualname = String::from_str(fn_name).append("::").append(name); + let mut qualname = String::from_str(fn_name); + qualname.push_str("::"); + qualname.push_str(name); self.check_and_record(Variable, span, sub_span, diff --git a/src/librustc/middle/subst.rs b/src/librustc/middle/subst.rs index e05a3237b264b..54ae4d124f61f 100644 --- a/src/librustc/middle/subst.rs +++ b/src/librustc/middle/subst.rs @@ -315,8 +315,8 @@ impl VecPerParamSpace { let type_limit = t.len(); let self_limit = t.len() + s.len(); let mut content = t; - content.push_all_move(s); - content.push_all_move(f); + content.extend(s.into_iter()); + content.extend(f.into_iter()); VecPerParamSpace { type_limit: type_limit, self_limit: self_limit, diff --git a/src/librustc/middle/traits/select.rs b/src/librustc/middle/traits/select.rs index 4040b452e9988..9acd9be8a410c 100644 --- a/src/librustc/middle/traits/select.rs +++ b/src/librustc/middle/traits/select.rs @@ -31,7 +31,6 @@ use middle::ty_fold::TypeFoldable; use std::cell::RefCell; use std::collections::hashmap::HashMap; use std::rc::Rc; -use std::result; use syntax::ast; use util::ppaux::Repr; @@ -1230,18 +1229,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { nested: Vec) -> VtableBuiltinData { - let obligations = - result::collect( - nested - .iter() - .map(|&t| { - util::obligation_for_builtin_bound( - self.tcx(), - obligation.cause, - bound, - obligation.recursion_depth + 1, - t) - })); + let obligations = nested.iter().map(|&t| { + util::obligation_for_builtin_bound( + self.tcx(), + obligation.cause, + bound, + obligation.recursion_depth + 1, + t) + }).collect::>(); let obligations = match obligations { Ok(o) => o, Err(ErrorReported) => Vec::new() @@ -1311,7 +1306,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> { |br| self.infcx.next_region_var( infer::LateBoundRegion(obligation.cause.span, br))); - let arguments_tuple = *new_signature.inputs.get(0); + let arguments_tuple = new_signature.inputs[0]; let trait_ref = Rc::new(ty::TraitRef { def_id: obligation.trait_ref.def_id, substs: Substs::new_trait( diff --git a/src/librustc/middle/traits/util.rs b/src/librustc/middle/traits/util.rs index 31266ff199fa8..9ee2c3aa14907 100644 --- a/src/librustc/middle/traits/util.rs +++ b/src/librustc/middle/traits/util.rs @@ -110,7 +110,7 @@ impl<'cx, 'tcx> Iterator> for Supertraits<'cx, 'tcx> { fn next(&mut self) -> Option> { loop { // Extract next item from top-most stack frame, if any. - let next_trait = match self.stack.mut_last() { + let next_trait = match self.stack.last_mut() { None => { // No more stack frames. Done. return None; @@ -121,8 +121,7 @@ impl<'cx, 'tcx> Iterator> for Supertraits<'cx, 'tcx> { // Still more supertraits left in the top stack frame. entry.position += 1; - let next_trait = - (*entry.supertraits.get(p)).clone(); + let next_trait = entry.supertraits[p].clone(); Some(next_trait) } else { None diff --git a/src/librustc/middle/trans/_match.rs b/src/librustc/middle/trans/_match.rs index 0ff9f9f26e867..fffc710a7ff33 100644 --- a/src/librustc/middle/trans/_match.rs +++ b/src/librustc/middle/trans/_match.rs @@ -369,7 +369,7 @@ impl<'a, 'p, 'blk, 'tcx> Repr for Match<'a, 'p, 'blk, 'tcx> { fn has_nested_bindings(m: &[Match], col: uint) -> bool { for br in m.iter() { - match br.pats.get(col).node { + match br.pats[col].node { ast::PatIdent(_, _, Some(_)) => return true, _ => () } @@ -391,7 +391,7 @@ fn expand_nested_bindings<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, m.iter().map(|br| { let mut bound_ptrs = br.bound_ptrs.clone(); - let mut pat = *br.pats.get(col); + let mut pat = br.pats[col]; loop { pat = match pat.node { ast::PatIdent(_, ref path, Some(ref inner)) => { @@ -430,7 +430,7 @@ fn enter_match<'a, 'b, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, m.iter().filter_map(|br| { e(br.pats.as_slice()).map(|pats| { - let this = *br.pats.get(col); + let this = br.pats[col]; let mut bound_ptrs = br.bound_ptrs.clone(); match this.node { ast::PatIdent(_, ref path, None) => { @@ -476,7 +476,9 @@ 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]) { - Some(Vec::from_slice(pats[..col]).append(pats[col + 1..])) + let mut r = pats[..col].to_vec(); + r.push_all(pats[col + 1..]); + Some(r) } else { None } @@ -561,7 +563,7 @@ fn get_branches<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let mut found: Vec = vec![]; for br in m.iter() { - let cur = *br.pats.get(col); + let cur = br.pats[col]; let opt = match cur.node { ast::PatLit(ref l) => ConstantValue(ConstantExpr(&**l)), ast::PatIdent(..) | ast::PatEnum(..) | ast::PatStruct(..) => { @@ -672,7 +674,7 @@ fn extract_vec_elems<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, macro_rules! any_pat ( ($m:expr, $col:expr, $pattern:pat) => ( ($m).iter().any(|br| { - match br.pats.get($col).node { + match br.pats[$col].node { $pattern => true, _ => false } @@ -690,7 +692,7 @@ fn any_region_pat(m: &[Match], col: uint) -> bool { fn any_irrefutable_adt_pat(tcx: &ty::ctxt, m: &[Match], col: uint) -> bool { m.iter().any(|br| { - let pat = *br.pats.get(col); + let pat = br.pats[col]; match pat.node { ast::PatTup(_) => true, ast::PatStruct(..) => { @@ -967,7 +969,7 @@ fn compile_submatch<'a, 'p, 'blk, 'tcx>(bcx: Block<'blk, 'tcx>, None => { let data = &m[0].data; for &(ref ident, ref value_ptr) in m[0].bound_ptrs.iter() { - let llmatch = data.bindings_map.get(ident).llmatch; + let llmatch = data.bindings_map[*ident].llmatch; call_lifetime_start(bcx, llmatch); Store(bcx, *value_ptr, llmatch); } @@ -999,12 +1001,13 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let tcx = bcx.tcx(); let dm = &tcx.def_map; - let vals_left = Vec::from_slice(vals[0u..col]).append(vals[col + 1u..vals.len()]); + let mut vals_left = vals[0u..col].to_vec(); + vals_left.push_all(vals[col + 1u..]); let ccx = bcx.fcx.ccx; // Find a real id (we're adding placeholder wildcard patterns, but // each column is guaranteed to have at least one real pattern) - let pat_id = m.iter().map(|br| br.pats.get(col).id) + let pat_id = m.iter().map(|br| br.pats[col].id) .find(|&id| id != DUMMY_NODE_ID) .unwrap_or(DUMMY_NODE_ID); @@ -1041,7 +1044,8 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, &check_match::Single, col, field_vals.len()) ); - let vals = field_vals.append(vals_left.as_slice()); + let mut vals = field_vals; + vals.push_all(vals_left.as_slice()); compile_submatch(bcx, pats.as_slice(), vals.as_slice(), chk, has_genuine_default); return; } @@ -1055,7 +1059,7 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, let mut test_val = val; debug!("test_val={}", bcx.val_to_string(test_val)); if opts.len() > 0u { - match *opts.get(0) { + match opts[0] { ConstantValue(_) | ConstantRange(_, _) => { test_val = load_if_immediate(bcx, val, left_ty); kind = if ty::type_is_integral(left_ty) { @@ -1194,7 +1198,8 @@ fn compile_submatch_continue<'a, 'p, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, ConstantValue(_) | ConstantRange(_, _) => () } let opt_ms = enter_opt(opt_cx, pat_id, dm, m, opt, col, size, val); - let opt_vals = unpacked.append(vals_left.as_slice()); + let mut opt_vals = unpacked; + opt_vals.push_all(vals_left.as_slice()); compile_submatch(opt_cx, opt_ms.as_slice(), opt_vals.as_slice(), @@ -1358,7 +1363,7 @@ fn trans_match_inner<'blk, 'tcx>(scope_cx: Block<'blk, 'tcx>, let arm_datas: Vec = arms.iter().map(|arm| ArmData { bodycx: fcx.new_id_block("case_body", arm.body.id), arm: arm, - bindings_map: create_bindings_map(bcx, &**arm.pats.get(0), discr_expr, &*arm.body) + bindings_map: create_bindings_map(bcx, &*arm.pats[0], discr_expr, &*arm.body) }).collect(); let mut static_inliner = StaticInliner::new(scope_cx.tcx()); @@ -1654,7 +1659,7 @@ fn bind_irrefutable_pat<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, val); for sub_pat in sub_pats.iter() { for (i, &argval) in args.vals.iter().enumerate() { - bcx = bind_irrefutable_pat(bcx, &**sub_pat.get(i), + bcx = bind_irrefutable_pat(bcx, &*sub_pat[i], argval, cleanup_scope); } } diff --git a/src/librustc/middle/trans/adt.rs b/src/librustc/middle/trans/adt.rs index 2f06f16ace131..91d198e50b4f2 100644 --- a/src/librustc/middle/trans/adt.rs +++ b/src/librustc/middle/trans/adt.rs @@ -224,7 +224,7 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { // Equivalent to a struct/tuple/newtype. // (Typechecking will reject discriminant-sizing attrs.) assert_eq!(hint, attr::ReprAny); - let mut ftys = cases.get(0).tys.clone(); + let mut ftys = cases[0].tys.clone(); if dtor { ftys.push(ty::mk_bool()); } return Univariant(mk_struct(cx, ftys.as_slice(), false), dtor); } @@ -233,14 +233,14 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { // Nullable pointer optimization let mut discr = 0; while discr < 2 { - if cases.get(1 - discr).is_zerolen(cx) { - let st = mk_struct(cx, cases.get(discr).tys.as_slice(), false); - match cases.get(discr).find_ptr() { + if cases[1 - discr].is_zerolen(cx) { + let st = mk_struct(cx, cases[discr].tys.as_slice(), false); + match cases[discr].find_ptr() { Some(ThinPointer(_)) if st.fields.len() == 1 => { return RawNullablePointer { nndiscr: discr as Disr, - nnty: *st.fields.get(0), - nullfields: cases.get(1 - discr).tys.clone() + nnty: st.fields[0], + nullfields: cases[1 - discr].tys.clone() }; } Some(ptrfield) => { @@ -248,7 +248,7 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { nndiscr: discr as Disr, nonnull: st, ptrfield: ptrfield, - nullfields: cases.get(1 - discr).tys.clone() + nullfields: cases[1 - discr].tys.clone() }; } None => { } @@ -265,7 +265,8 @@ fn represent_type_uncached(cx: &CrateContext, t: ty::t) -> Repr { let ity = range_to_inttype(cx, hint, &bounds); return General(ity, cases.iter().map(|c| { - let mut ftys = vec!(ty_of_inttype(ity)).append(c.tys.as_slice()); + let mut ftys = vec![ty_of_inttype(ity)]; + ftys.push_all(c.tys.as_slice()); if dtor { ftys.push(ty::mk_bool()); } mk_struct(cx, ftys.as_slice(), false) }).collect(), dtor); @@ -354,7 +355,7 @@ fn mk_struct(cx: &CrateContext, tys: &[ty::t], packed: bool) -> Struct { align: machine::llalign_of_min(cx, llty_rec), sized: true, packed: packed, - fields: Vec::from_slice(tys), + fields: tys.to_vec(), } } else { // Ignore any dynamically sized fields. @@ -366,7 +367,7 @@ fn mk_struct(cx: &CrateContext, tys: &[ty::t], packed: bool) -> Struct { align: machine::llalign_of_min(cx, llty_rec), sized: false, packed: packed, - fields: Vec::from_slice(tys), + fields: tys.to_vec(), } } } @@ -701,7 +702,7 @@ pub fn trans_set_discr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr) { General(ity, ref cases, dtor) => { if dtor { let ptr = trans_field_ptr(bcx, r, val, discr, - cases.get(discr as uint).fields.len() - 2); + cases[discr as uint].fields.len() - 2); Store(bcx, C_u8(bcx.ccx(), 1), ptr); } Store(bcx, C_integral(ll_inttype(bcx.ccx(), ity), discr as u64, true), @@ -725,7 +726,7 @@ pub fn trans_set_discr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr) { let (llptrptr, llptrty) = match ptrfield { ThinPointer(field) => (GEPi(bcx, val, [0, field]), - type_of::type_of(bcx.ccx(), *nonnull.fields.get(field))), + type_of::type_of(bcx.ccx(), nonnull.fields[field])), FatPointer(field, pair) => { let v = GEPi(bcx, val, [0, field, pair]); (v, val_ty(v).element_type()) @@ -756,7 +757,7 @@ pub fn num_args(r: &Repr, discr: Disr) -> uint { st.fields.len() - (if dtor { 1 } else { 0 }) } General(_, ref cases, dtor) => { - cases.get(discr as uint).fields.len() - 1 - (if dtor { 1 } else { 0 }) + cases[discr as uint].fields.len() - 1 - (if dtor { 1 } else { 0 }) } RawNullablePointer { nndiscr, ref nullfields, .. } => { if discr == nndiscr { 1 } else { nullfields.len() } @@ -783,13 +784,13 @@ pub fn trans_field_ptr(bcx: Block, r: &Repr, val: ValueRef, discr: Disr, struct_field_ptr(bcx, st, val, ix, false) } General(_, ref cases, _) => { - struct_field_ptr(bcx, cases.get(discr as uint), val, ix + 1, true) + struct_field_ptr(bcx, &cases[discr as uint], val, ix + 1, true) } RawNullablePointer { nndiscr, ref nullfields, .. } | StructWrappedNullablePointer { nndiscr, ref nullfields, .. } if discr != nndiscr => { // The unit-like case might have a nonzero number of unit-like fields. // (e.d., Result of Either with (), as one side.) - let ty = type_of::type_of(bcx.ccx(), *nullfields.get(ix)); + let ty = type_of::type_of(bcx.ccx(), nullfields[ix]); assert_eq!(machine::llsize_of_alloc(bcx.ccx(), ty), 0); // The contents of memory at this pointer can't matter, but use // the value that's "reasonable" in case of pointer comparison. @@ -921,14 +922,14 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr, C_integral(ll_inttype(ccx, ity), discr as u64, true) } General(ity, ref cases, _) => { - let case = cases.get(discr as uint); + let case = &cases[discr as uint]; let max_sz = cases.iter().map(|x| x.size).max().unwrap(); let lldiscr = C_integral(ll_inttype(ccx, ity), discr as u64, true); - let contents = build_const_struct(ccx, - case, - (vec!(lldiscr)).append(vals).as_slice()); - C_struct(ccx, contents.append([padding(ccx, max_sz - case.size)]).as_slice(), - false) + let mut f = vec![lldiscr]; + f.push_all(vals); + let mut contents = build_const_struct(ccx, case, f.as_slice()); + contents.push_all([padding(ccx, max_sz - case.size)]); + C_struct(ccx, contents.as_slice(), false) } Univariant(ref st, _dro) => { assert!(discr == 0); diff --git a/src/librustc/middle/trans/asm.rs b/src/librustc/middle/trans/asm.rs index f4586fca52fd6..04237a2d44925 100644 --- a/src/librustc/middle/trans/asm.rs +++ b/src/librustc/middle/trans/asm.rs @@ -62,7 +62,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) }).collect::>(); // Now the input operands - let inputs = ia.inputs.iter().map(|&(ref c, ref input)| { + let mut inputs = ia.inputs.iter().map(|&(ref c, ref input)| { constraints.push((*c).clone()); let in_datum = unpack_datum!(bcx, expr::trans(bcx, &**input)); @@ -73,7 +73,8 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) cleanup::CustomScope(temp_scope), callee::DontAutorefArg) }) - }).collect::>().append(ext_inputs.as_slice()); + }).collect::>(); + inputs.push_all(ext_inputs.as_slice()); // no failure occurred preparing operands, no need to cleanup fcx.pop_custom_cleanup_scope(temp_scope); @@ -95,7 +96,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) // Add the clobbers to our constraints list if clobbers.len() != 0 && constraints.len() != 0 { - constraints.push_char(','); + constraints.push(','); constraints.push_str(clobbers.as_slice()); } else { constraints.push_str(clobbers.as_slice()); @@ -109,7 +110,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) let output_type = if num_outputs == 0 { Type::void(bcx.ccx()) } else if num_outputs == 1 { - *output_types.get(0) + output_types[0] } else { Type::struct_(bcx.ccx(), output_types.as_slice(), false) }; @@ -134,7 +135,7 @@ pub fn trans_inline_asm<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ia: &ast::InlineAsm) // Again, based on how many outputs we have if num_outputs == 1 { - Store(bcx, r, *outputs.get(0)); + Store(bcx, r, outputs[0]); } else { for (i, o) in outputs.iter().enumerate() { let v = ExtractValue(bcx, r, i); diff --git a/src/librustc/middle/trans/base.rs b/src/librustc/middle/trans/base.rs index c780969034444..d5b939603673a 100644 --- a/src/librustc/middle/trans/base.rs +++ b/src/librustc/middle/trans/base.rs @@ -259,7 +259,7 @@ pub fn self_type_for_unboxed_closure(ccx: &CrateContext, closure_id, ty::ReStatic); let unboxed_closures = ccx.tcx().unboxed_closures.borrow(); - let unboxed_closure = unboxed_closures.get(&closure_id); + let unboxed_closure = &(*unboxed_closures)[closure_id]; match unboxed_closure.kind { ty::FnUnboxedClosureKind => { ty::mk_imm_rptr(ccx.tcx(), ty::ReStatic, unboxed_closure_type) @@ -274,7 +274,7 @@ pub fn self_type_for_unboxed_closure(ccx: &CrateContext, pub fn kind_for_unboxed_closure(ccx: &CrateContext, closure_id: ast::DefId) -> ty::UnboxedClosureKind { let unboxed_closures = ccx.tcx().unboxed_closures.borrow(); - unboxed_closures.get(&closure_id).kind + (*unboxed_closures)[closure_id].kind } pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef { @@ -287,7 +287,7 @@ pub fn decl_rust_fn(ccx: &CrateContext, fn_ty: ty::t, name: &str) -> ValueRef { } ty::ty_unboxed_closure(closure_did, _) => { let unboxed_closures = ccx.tcx().unboxed_closures.borrow(); - let unboxed_closure = unboxed_closures.get(&closure_did); + let unboxed_closure = &(*unboxed_closures)[closure_did]; let function_type = unboxed_closure.closure_type.clone(); let self_type = self_type_for_unboxed_closure(ccx, closure_did); let llenvironment_type = type_of_explicit_arg(ccx, self_type); @@ -771,7 +771,7 @@ pub fn iter_structural_ty<'a, 'blk, 'tcx>(cx: Block<'blk, 'tcx>, match adt::trans_switch(cx, &*repr, av) { (_match::Single, None) => { - cx = iter_variant(cx, &*repr, av, &**variants.get(0), + cx = iter_variant(cx, &*repr, av, &*(*variants)[0], substs, f); } (_match::Switch, Some(lldiscrim_a)) => { @@ -2121,7 +2121,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &ast::EnumDef, sp: Span, ({} bytes) than the next largest (ignoring padding)", largest).as_slice()); - ccx.sess().span_note(enum_def.variants.get(largest_index).span, + ccx.sess().span_note(enum_def.variants[largest_index].span, "this variant is the largest"); } } @@ -2353,7 +2353,7 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) ty::ty_bare_fn(ref f) => (f.sig.clone(), f.abi, false), ty::ty_unboxed_closure(closure_did, _) => { let unboxed_closures = ccx.tcx().unboxed_closures.borrow(); - let ref function_type = unboxed_closures.get(&closure_did) + let ref function_type = (*unboxed_closures)[closure_did] .closure_type; (function_type.sig.clone(), RustCall, true) @@ -2381,11 +2381,14 @@ pub fn get_fn_llvm_attributes(ccx: &CrateContext, fn_ty: ty::t) } }, ty::ty_bare_fn(_) if abi == RustCall => { - let inputs = vec![fn_sig.inputs[0]]; + let mut inputs = vec![fn_sig.inputs[0]]; match ty::get(fn_sig.inputs[1]).sty { ty::ty_nil => inputs, - ty::ty_tup(ref t_in) => inputs.append(t_in.as_slice()), + ty::ty_tup(ref t_in) => { + inputs.push_all(t_in.as_slice()); + inputs + } _ => ccx.sess().bug("expected tuple'd inputs") } } @@ -2904,13 +2907,11 @@ pub fn write_metadata(cx: &SharedCrateContext, krate: &ast::Crate) -> Vec { let encode_parms = crate_ctxt_to_encode_parms(cx, encode_inlined_item); let metadata = encoder::encode_metadata(encode_parms, krate); - let compressed = Vec::from_slice(encoder::metadata_encoding_version) - .append(match flate::deflate_bytes(metadata.as_slice()) { - Some(compressed) => compressed, - None => { - cx.sess().fatal("failed to compress metadata") - } - }.as_slice()); + let mut compressed = encoder::metadata_encoding_version.to_vec(); + compressed.push_all(match flate::deflate_bytes(metadata.as_slice()) { + Some(compressed) => compressed, + None => cx.sess().fatal("failed to compress metadata"), + }.as_slice()); let llmeta = C_bytes_in_context(cx.metadata_llcx(), compressed.as_slice()); let llconst = C_struct_in_context(cx.metadata_llcx(), [llmeta], false); let name = format!("rust_metadata_{}_{}", diff --git a/src/librustc/middle/trans/builder.rs b/src/librustc/middle/trans/builder.rs index dbc668a04bac9..99f3768ef64a4 100644 --- a/src/librustc/middle/trans/builder.rs +++ b/src/librustc/middle/trans/builder.rs @@ -72,13 +72,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { let mut s = String::from_str("."); i = 0u; while i < len { - i = *mm.get(&v[i]); - s.push_char('/'); + i = mm[v[i]]; + s.push('/'); s.push_str(v[i]); i += 1u; } - s.push_char('/'); + s.push('/'); s.push_str(category); let n = match h.find(&s) { diff --git a/src/librustc/middle/trans/cabi_x86_64.rs b/src/librustc/middle/trans/cabi_x86_64.rs index 2fd58303de309..1b8a354259ad7 100644 --- a/src/librustc/middle/trans/cabi_x86_64.rs +++ b/src/librustc/middle/trans/cabi_x86_64.rs @@ -316,7 +316,7 @@ fn llreg_ty(ccx: &CrateContext, cls: &[RegClass]) -> Type { tys.push(Type::i64(ccx)); } SSEFv => { - let vec_len = llvec_len(cls.tailn(i + 1u)); + let vec_len = llvec_len(cls[i + 1u..]); let vec_ty = Type::vector(&Type::f32(ccx), (vec_len * 2u) as u64); tys.push(vec_ty); i += vec_len; diff --git a/src/librustc/middle/trans/callee.rs b/src/librustc/middle/trans/callee.rs index f607dfdd17f49..1cb8292d5c25b 100644 --- a/src/librustc/middle/trans/callee.rs +++ b/src/librustc/middle/trans/callee.rs @@ -260,7 +260,7 @@ pub fn trans_unboxing_shim(bcx: Block, let tcx = bcx.tcx(); // Transform the self type to `Box`. - let self_type = *fty.sig.inputs.get(0); + let self_type = fty.sig.inputs[0]; let boxed_self_type = ty::mk_uniq(tcx, self_type); let boxed_function_type = ty::FnSig { binder_id: fty.sig.binder_id, @@ -308,9 +308,9 @@ pub fn trans_unboxing_shim(bcx: Block, let arg_scope = fcx.push_custom_cleanup_scope(); let arg_scope_id = cleanup::CustomScope(arg_scope); let boxed_arg_types = ty::ty_fn_args(boxed_function_type); - let boxed_self_type = *boxed_arg_types.get(0); + let boxed_self_type = boxed_arg_types[0]; let arg_types = ty::ty_fn_args(function_type); - let self_type = *arg_types.get(0); + let self_type = arg_types[0]; let boxed_self_kind = arg_kind(&fcx, boxed_self_type); // Create a datum for self. @@ -517,7 +517,7 @@ pub fn trans_fn_ref_with_substs( let ref_ty = match node { ExprId(id) => node_id_type(bcx, id), MethodCall(method_call) => { - let t = bcx.tcx().method_map.borrow().get(&method_call).ty; + let t = (*bcx.tcx().method_map.borrow())[method_call].ty; monomorphize_type(bcx, t) } }; @@ -604,7 +604,7 @@ pub fn trans_method_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let _icx = push_ctxt("trans_method_call"); debug!("trans_method_call(call_ex={})", call_ex.repr(bcx.tcx())); let method_call = MethodCall::expr(call_ex.id); - let method_ty = bcx.tcx().method_map.borrow().get(&method_call).ty; + let method_ty = (*bcx.tcx().method_map.borrow())[method_call].ty; trans_call_inner( bcx, Some(common::expr_info(call_ex)), @@ -891,7 +891,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>( let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &*arg_exprs[0])); llargs.push(unpack_result!(bcx, { trans_arg_datum(bcx, - *arg_tys.get(0), + arg_tys[0], arg_datum, arg_cleanup_scope, DontAutorefArg) @@ -916,7 +916,7 @@ fn trans_args_under_call_abi<'blk, 'tcx>( for i in range(0, field_types.len()) { let arg_datum = tuple_lvalue_datum.get_element( bcx, - *field_types.get(i), + field_types[i], |srcval| { adt::trans_field_ptr(bcx, repr_ptr, srcval, 0, i) }); @@ -952,7 +952,7 @@ fn trans_overloaded_call_args<'blk, 'tcx>( let arg_datum = unpack_datum!(bcx, expr::trans(bcx, arg_exprs[0])); llargs.push(unpack_result!(bcx, { trans_arg_datum(bcx, - *arg_tys.get(0), + arg_tys[0], arg_datum, arg_cleanup_scope, DontAutorefArg) @@ -960,7 +960,7 @@ fn trans_overloaded_call_args<'blk, 'tcx>( } // Now untuple the rest of the arguments. - let tuple_type = *arg_tys.get(1); + let tuple_type = arg_tys[1]; match ty::get(tuple_type).sty { ty::ty_tup(ref field_types) => { for (i, &field_type) in field_types.iter().enumerate() { @@ -1026,7 +1026,7 @@ pub fn trans_args<'blk, 'tcx>(cx: Block<'blk, 'tcx>, assert!(variadic); expr_ty_adjusted(cx, &**arg_expr) } else { - *arg_tys.get(i) + arg_tys[i] }; let arg_datum = unpack_datum!(bcx, expr::trans(bcx, &**arg_expr)); @@ -1049,15 +1049,15 @@ pub fn trans_args<'blk, 'tcx>(cx: Block<'blk, 'tcx>, assert!(!variadic); llargs.push(unpack_result!(bcx, { - trans_arg_datum(bcx, *arg_tys.get(0), lhs, + trans_arg_datum(bcx, arg_tys[0], lhs, arg_cleanup_scope, DontAutorefArg) })); assert_eq!(arg_tys.len(), 1 + rhs.len()); - for (rhs, rhs_id) in rhs.move_iter() { + for (rhs, rhs_id) in rhs.into_iter() { llargs.push(unpack_result!(bcx, { - trans_arg_datum(bcx, *arg_tys.get(1), rhs, + trans_arg_datum(bcx, arg_tys[1], rhs, arg_cleanup_scope, DoAutorefArg(rhs_id)) })); diff --git a/src/librustc/middle/trans/cleanup.rs b/src/librustc/middle/trans/cleanup.rs index 9edca215aef8d..827df48071af9 100644 --- a/src/librustc/middle/trans/cleanup.rs +++ b/src/librustc/middle/trans/cleanup.rs @@ -549,7 +549,7 @@ impl<'blk, 'tcx> CleanupHelperMethods<'blk, 'tcx> for FunctionContext<'blk, 'tcx fn is_valid_custom_scope(&self, custom_scope: CustomScopeIndex) -> bool { let scopes = self.scopes.borrow(); custom_scope.index < scopes.len() && - scopes.get(custom_scope.index).kind.is_temp() + (*scopes)[custom_scope.index].kind.is_temp() } fn trans_scope_cleanups(&self, // cannot borrow self, will recurse diff --git a/src/librustc/middle/trans/closure.rs b/src/librustc/middle/trans/closure.rs index 8f877f981c8d9..d620b03754943 100644 --- a/src/librustc/middle/trans/closure.rs +++ b/src/librustc/middle/trans/closure.rs @@ -473,7 +473,7 @@ pub fn trans_unboxed_closure<'blk, 'tcx>( closure_id).unwrap(); let unboxed_closures = bcx.tcx().unboxed_closures.borrow(); - let function_type = unboxed_closures.get(&closure_id) + let function_type = (*unboxed_closures)[closure_id] .closure_type .clone(); let function_type = ty::mk_closure(bcx.tcx(), function_type); diff --git a/src/librustc/middle/trans/common.rs b/src/librustc/middle/trans/common.rs index a681a750f0b43..ba7da5af9f78d 100644 --- a/src/librustc/middle/trans/common.rs +++ b/src/librustc/middle/trans/common.rs @@ -58,9 +58,9 @@ fn type_is_newtype_immediate(ccx: &CrateContext, ty: ty::t) -> bool { ty::ty_struct(def_id, ref substs) => { let fields = ty::struct_fields(ccx.tcx(), def_id, substs); fields.len() == 1 && - fields.get(0).ident.name == + fields[0].ident.name == token::special_idents::unnamed_field.name && - type_is_immediate(ccx, fields.get(0).mt.ty) + type_is_immediate(ccx, fields[0].mt.ty) } _ => false } @@ -884,7 +884,7 @@ pub fn node_id_substs(bcx: Block, ty::node_id_item_substs(tcx, id).substs } MethodCall(method_call) => { - tcx.method_map.borrow().get(&method_call).substs.clone() + (*tcx.method_map.borrow())[method_call].substs.clone() } }; diff --git a/src/librustc/middle/trans/consts.rs b/src/librustc/middle/trans/consts.rs index d83c46be14ab8..399d2a0ec2805 100644 --- a/src/librustc/middle/trans/consts.rs +++ b/src/librustc/middle/trans/consts.rs @@ -311,7 +311,7 @@ pub fn const_expr(cx: &CrateContext, e: &ast::Expr) -> (ValueRef, ty::t) { fn const_expr_unadjusted(cx: &CrateContext, e: &ast::Expr) -> ValueRef { let map_list = |exprs: &[P]| { exprs.iter().map(|e| const_expr(cx, &**e).val0()) - .fold(Vec::new(), |l, val| l.append_one(val)) + .fold(Vec::new(), |mut l, val| { l.push(val); l }) }; unsafe { let _icx = push_ctxt("const_expr"); diff --git a/src/librustc/middle/trans/controlflow.rs b/src/librustc/middle/trans/controlflow.rs index fe9f832e44a18..e5d726b86df25 100644 --- a/src/librustc/middle/trans/controlflow.rs +++ b/src/librustc/middle/trans/controlflow.rs @@ -291,10 +291,9 @@ pub fn trans_for<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, // Set up the method call (to `.next()`). let method_call = MethodCall::expr(loop_info.id); - let method_type = loopback_bcx_in.tcx() + let method_type = (*loopback_bcx_in.tcx() .method_map - .borrow() - .get(&method_call) + .borrow())[method_call] .ty; let method_type = monomorphize_type(loopback_bcx_in, method_type); let method_result_type = ty::ty_fn_ret(method_type); diff --git a/src/librustc/middle/trans/debuginfo.rs b/src/librustc/middle/trans/debuginfo.rs index 4e3eaf26f42e8..2de1e0fe1923f 100644 --- a/src/librustc/middle/trans/debuginfo.rs +++ b/src/librustc/middle/trans/debuginfo.rs @@ -348,7 +348,7 @@ impl TypeMap { }; let mut unique_type_id = String::with_capacity(256); - unique_type_id.push_char('{'); + unique_type_id.push('{'); match ty::get(type_).sty { ty::ty_nil | @@ -380,13 +380,13 @@ impl TypeMap { } }, ty::ty_uniq(inner_type) => { - unique_type_id.push_char('~'); + 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.as_slice()); }, ty::ty_ptr(ty::mt { ty: inner_type, mutbl } ) => { - unique_type_id.push_char('*'); + unique_type_id.push('*'); if mutbl == ast::MutMutable { unique_type_id.push_str("mut"); } @@ -396,7 +396,7 @@ impl TypeMap { unique_type_id.push_str(inner_type_id.as_slice()); }, ty::ty_rptr(_, ty::mt { ty: inner_type, mutbl }) => { - unique_type_id.push_char('&'); + unique_type_id.push('&'); if mutbl == ast::MutMutable { unique_type_id.push_str("mut"); } @@ -443,7 +443,7 @@ impl TypeMap { let parameter_type_id = self.get_unique_type_id_as_string(parameter_type_id); unique_type_id.push_str(parameter_type_id.as_slice()); - unique_type_id.push_char(','); + unique_type_id.push(','); } if sig.variadic { @@ -474,7 +474,7 @@ impl TypeMap { } }; - unique_type_id.push_char('}'); + unique_type_id.push('}'); // Trim to size before storing permanently unique_type_id.shrink_to_fit(); @@ -489,8 +489,6 @@ impl TypeMap { def_id: ast::DefId, substs: &subst::Substs, output: &mut String) { - use std::num::ToStrRadix; - // First, find out the 'real' def_id of the type. Items inlined from // other crates have to be mapped back to their source. let source_def_id = if def_id.krate == ast::LOCAL_CRATE { @@ -515,13 +513,13 @@ impl TypeMap { output.push_str(crate_hash.as_str()); output.push_str("/"); - output.push_str(def_id.node.to_str_radix(16).as_slice()); + output.push_str(format!("{:x}", def_id.node).as_slice()); // Maybe check that there is no self type here. let tps = substs.types.get_slice(subst::TypeSpace); if tps.len() > 0 { - output.push_char('<'); + output.push('<'); for &type_parameter in tps.iter() { let param_type_id = @@ -529,10 +527,10 @@ impl TypeMap { let param_type_id = type_map.get_unique_type_id_as_string(param_type_id); output.push_str(param_type_id.as_slice()); - output.push_char(','); + output.push(','); } - output.push_char('>'); + output.push('>'); } } } @@ -571,7 +569,7 @@ impl TypeMap { let parameter_type_id = self.get_unique_type_id_as_string(parameter_type_id); unique_type_id.push_str(parameter_type_id.as_slice()); - unique_type_id.push_char(','); + unique_type_id.push(','); } if sig.variadic { @@ -584,7 +582,7 @@ impl TypeMap { let return_type_id = self.get_unique_type_id_as_string(return_type_id); unique_type_id.push_str(return_type_id.as_slice()); - unique_type_id.push_char(':'); + unique_type_id.push(':'); for bound in bounds.builtin_bounds.iter() { match bound { @@ -593,7 +591,7 @@ impl TypeMap { ty::BoundCopy => unique_type_id.push_str("Copy"), ty::BoundSync => unique_type_id.push_str("Sync"), }; - unique_type_id.push_char('+'); + unique_type_id.push('+'); } } @@ -1402,7 +1400,7 @@ pub fn create_function_debug_context(cx: &CrateContext, return create_DIArray(DIB(cx), []); } - name_to_append_suffix_to.push_char('<'); + name_to_append_suffix_to.push('<'); // The list to be filled with template parameters: let mut template_params: Vec = @@ -1483,7 +1481,7 @@ pub fn create_function_debug_context(cx: &CrateContext, } } - name_to_append_suffix_to.push_char('>'); + name_to_append_suffix_to.push('>'); return create_DIArray(DIB(cx), template_params.as_slice()); } @@ -1526,7 +1524,7 @@ fn compile_unit_metadata(cx: &CrateContext) { // prepend "./" if necessary let dotdot = b".."; let prefix = &[dotdot[0], ::std::path::SEP_BYTE]; - let mut path_bytes = Vec::from_slice(p.as_vec()); + let mut path_bytes = p.as_vec().to_vec(); if path_bytes.slice_to(2) != prefix && path_bytes.slice_to(2) != dotdot { @@ -1927,7 +1925,7 @@ impl StructMemberDescriptionFactory { } let field_size = if self.is_simd { - machine::llsize_of_alloc(cx, type_of::type_of(cx, self.fields.get(0).mt.ty)) as uint + machine::llsize_of_alloc(cx, type_of::type_of(cx, self.fields[0].mt.ty)) as uint } else { 0xdeadbeef }; @@ -2038,7 +2036,7 @@ fn prepare_tuple_metadata(cx: &CrateContext, UNKNOWN_SCOPE_METADATA), tuple_llvm_type, TupleMDF(TupleMemberDescriptionFactory { - component_types: Vec::from_slice(component_types), + component_types: component_types.to_vec(), span: span, }) ) @@ -2081,7 +2079,7 @@ impl EnumMemberDescriptionFactory { describe_enum_variant(cx, self.enum_type, struct_def, - &**self.variants.get(i), + &*(*self.variants)[i], discriminant_info, self.containing_scope, self.span); @@ -2114,7 +2112,7 @@ impl EnumMemberDescriptionFactory { describe_enum_variant(cx, self.enum_type, struct_def, - &**self.variants.get(0), + &*(*self.variants)[0], NoDiscriminant, self.containing_scope, self.span); @@ -2143,7 +2141,7 @@ impl EnumMemberDescriptionFactory { // DWARF representation of enums uniform. // First create a description of the artificial wrapper struct: - let non_null_variant = self.variants.get(non_null_variant_index as uint); + let non_null_variant = &(*self.variants)[non_null_variant_index as uint]; let non_null_variant_ident = non_null_variant.name; let non_null_variant_name = token::get_ident(non_null_variant_ident); @@ -2160,7 +2158,7 @@ impl EnumMemberDescriptionFactory { // MemberDescription of the struct's single field. let sole_struct_member_description = MemberDescription { name: match non_null_variant.arg_names { - Some(ref names) => token::get_ident(*names.get(0)).get().to_string(), + Some(ref names) => token::get_ident(names[0]).get().to_string(), None => "".to_string() }, llvm_type: non_null_llvm_type, @@ -2190,7 +2188,7 @@ impl EnumMemberDescriptionFactory { // Encode the information about the null variant in the union // member's name. let null_variant_index = (1 - non_null_variant_index) as uint; - let null_variant_ident = self.variants.get(null_variant_index).name; + let null_variant_ident = (*self.variants)[null_variant_index].name; let null_variant_name = token::get_ident(null_variant_ident); let union_member_name = format!("RUST$ENCODED$ENUM${}${}", 0u, @@ -2216,7 +2214,7 @@ impl EnumMemberDescriptionFactory { describe_enum_variant(cx, self.enum_type, struct_def, - &**self.variants.get(nndiscr as uint), + &*(*self.variants)[nndiscr as uint], OptimizedDiscriminant(ptrfield), self.containing_scope, self.span); @@ -2232,7 +2230,7 @@ impl EnumMemberDescriptionFactory { // Encode the information about the null variant in the union // member's name. let null_variant_index = (1 - nndiscr) as uint; - let null_variant_ident = self.variants.get(null_variant_index).name; + let null_variant_ident = (*self.variants)[null_variant_index].name; let null_variant_name = token::get_ident(null_variant_ident); let discrfield = match ptrfield { adt::ThinPointer(field) => format!("{}", field), @@ -2706,14 +2704,14 @@ fn vec_slice_metadata(cx: &CrateContext, let member_descriptions = [ MemberDescription { name: "data_ptr".to_string(), - llvm_type: *member_llvm_types.get(0), + llvm_type: member_llvm_types[0], type_metadata: element_type_metadata, offset: ComputedMemberOffset, flags: FLAGS_NONE }, MemberDescription { name: "length".to_string(), - llvm_type: *member_llvm_types.get(1), + llvm_type: member_llvm_types[1], type_metadata: type_metadata(cx, ty::mk_uint(), span), offset: ComputedMemberOffset, flags: FLAGS_NONE @@ -3081,14 +3079,14 @@ fn bytes_to_bits(bytes: u64) -> c_ulonglong { #[inline] fn debug_context<'a>(cx: &'a CrateContext) -> &'a CrateDebugContext { - let debug_context: &'a CrateDebugContext = cx.dbg_cx().get_ref(); + let debug_context: &'a CrateDebugContext = cx.dbg_cx().as_ref().unwrap(); debug_context } #[inline] #[allow(non_snake_case)] fn DIB(cx: &CrateContext) -> DIBuilderRef { - cx.dbg_cx().get_ref().builder + cx.dbg_cx().as_ref().unwrap().builder } fn fn_should_be_ignored(fcx: &FunctionContext) -> bool { @@ -3576,7 +3574,7 @@ fn populate_scope_map(cx: &CrateContext, // same binding names. for arm_ref in arms.iter() { - let arm_span = arm_ref.pats.get(0).span; + let arm_span = arm_ref.pats[0].span; with_new_scope(cx, arm_span, @@ -3671,22 +3669,22 @@ fn push_debuginfo_type_name(cx: &CrateContext, push_type_params(cx, substs, output); }, ty::ty_tup(ref component_types) => { - output.push_char('('); + output.push('('); for &component_type in component_types.iter() { push_debuginfo_type_name(cx, component_type, true, output); output.push_str(", "); } - output.pop_char(); - output.pop_char(); - output.push_char(')'); + output.pop(); + output.pop(); + output.push(')'); }, ty::ty_uniq(inner_type) => { output.push_str("Box<"); push_debuginfo_type_name(cx, inner_type, true, output); - output.push_char('>'); + output.push('>'); }, ty::ty_ptr(ty::mt { ty: inner_type, mutbl } ) => { - output.push_char('*'); + output.push('*'); match mutbl { ast::MutImmutable => output.push_str("const "), ast::MutMutable => output.push_str("mut "), @@ -3695,7 +3693,7 @@ fn push_debuginfo_type_name(cx: &CrateContext, push_debuginfo_type_name(cx, inner_type, true, output); }, ty::ty_rptr(_, ty::mt { ty: inner_type, mutbl }) => { - output.push_char('&'); + output.push('&'); if mutbl == ast::MutMutable { output.push_str("mut "); } @@ -3703,7 +3701,7 @@ fn push_debuginfo_type_name(cx: &CrateContext, push_debuginfo_type_name(cx, inner_type, true, output); }, ty::ty_vec(inner_type, optional_length) => { - output.push_char('['); + output.push('['); push_debuginfo_type_name(cx, inner_type, true, output); match optional_length { @@ -3713,7 +3711,7 @@ fn push_debuginfo_type_name(cx: &CrateContext, None => { /* nothing to do */ } }; - output.push_char(']'); + output.push(']'); }, ty::ty_trait(ref trait_data) => { push_item_name(cx, trait_data.def_id, false, output); @@ -3737,8 +3735,8 @@ fn push_debuginfo_type_name(cx: &CrateContext, push_debuginfo_type_name(cx, parameter_type, true, output); output.push_str(", "); } - output.pop_char(); - output.pop_char(); + output.pop(); + output.pop(); } if sig.variadic { @@ -3749,7 +3747,7 @@ fn push_debuginfo_type_name(cx: &CrateContext, } } - output.push_char(')'); + output.push(')'); if !ty::type_is_nil(sig.output) { output.push_str(" -> "); @@ -3791,8 +3789,8 @@ fn push_debuginfo_type_name(cx: &CrateContext, push_debuginfo_type_name(cx, parameter_type, true, output); output.push_str(", "); } - output.pop_char(); - output.pop_char(); + output.pop(); + output.pop(); } if sig.variadic { @@ -3803,7 +3801,7 @@ fn push_debuginfo_type_name(cx: &CrateContext, } } - output.push_char(param_list_closing_char); + output.push(param_list_closing_char); if !ty::type_is_nil(sig.output) { output.push_str(" -> "); @@ -3845,8 +3843,8 @@ fn push_debuginfo_type_name(cx: &CrateContext, cx.sess().bug("debuginfo: Encountered empty item path!"); } - output.pop_char(); - output.pop_char(); + output.pop(); + output.pop(); } else { let name = token::get_name(path.last() .expect("debuginfo: Empty item path?") @@ -3868,17 +3866,17 @@ fn push_debuginfo_type_name(cx: &CrateContext, return; } - output.push_char('<'); + output.push('<'); for &type_parameter in substs.types.iter() { push_debuginfo_type_name(cx, type_parameter, true, output); output.push_str(", "); } - output.pop_char(); - output.pop_char(); + output.pop(); + output.pop(); - output.push_char('>'); + output.push('>'); } } @@ -3909,7 +3907,7 @@ impl NamespaceTreeNode { fill_nested(self, &mut name); name.push_str(format!("{}", item_name.len()).as_slice()); name.push_str(item_name); - name.push_char('E'); + name.push('E'); name } } diff --git a/src/librustc/middle/trans/expr.rs b/src/librustc/middle/trans/expr.rs index bcbc9fff834da..bde006c716ab0 100644 --- a/src/librustc/middle/trans/expr.rs +++ b/src/librustc/middle/trans/expr.rs @@ -1079,7 +1079,7 @@ fn trans_rvalue_dps_unadjusted<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, ast::ExprMethodCall(_, _, ref args) => { callee::trans_method_call(bcx, expr, - &**args.get(0), + &*args[0], callee::ArgExprs(args.as_slice()), dest) } @@ -1787,7 +1787,7 @@ fn trans_overloaded_op<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, rhs: Vec<(Datum, ast::NodeId)>, dest: Option) -> Result<'blk, 'tcx> { - let method_ty = bcx.tcx().method_map.borrow().get(&method_call).ty; + let method_ty = (*bcx.tcx().method_map.borrow())[method_call].ty; callee::trans_call_inner(bcx, Some(expr_info(expr)), monomorphize_type(bcx, method_ty), @@ -1808,11 +1808,10 @@ fn trans_overloaded_call<'a, 'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, dest: Option) -> Block<'blk, 'tcx> { let method_call = MethodCall::expr(expr.id); - let method_type = bcx.tcx() - .method_map - .borrow() - .get(&method_call) - .ty; + let method_type = (*bcx.tcx() + .method_map + .borrow())[method_call] + .ty; let mut all_args = vec!(callee); all_args.extend(args.iter().map(|e| &**e)); unpack_result!(bcx, diff --git a/src/librustc/middle/trans/foreign.rs b/src/librustc/middle/trans/foreign.rs index cc28b8032087f..3905dfd859a76 100644 --- a/src/librustc/middle/trans/foreign.rs +++ b/src/librustc/middle/trans/foreign.rs @@ -321,8 +321,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, } // Does Rust pass this argument by pointer? - let rust_indirect = type_of::arg_is_indirect(ccx, - *passed_arg_tys.get(i)); + let rust_indirect = type_of::arg_is_indirect(ccx, passed_arg_tys[i]); debug!("argument {}, llarg_rust={}, rust_indirect={}, arg_ty={}", i, @@ -335,9 +334,9 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, if !rust_indirect { let scratch = base::alloca(bcx, - type_of::type_of(ccx, *passed_arg_tys.get(i)), + type_of::type_of(ccx, passed_arg_tys[i]), "__arg"); - base::store_ty(bcx, llarg_rust, scratch, *passed_arg_tys.get(i)); + base::store_ty(bcx, llarg_rust, scratch, passed_arg_tys[i]); llarg_rust = scratch; } @@ -358,7 +357,7 @@ pub fn trans_native_call<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, let llarg_foreign = if foreign_indirect { llarg_rust } else { - if ty::type_is_bool(*passed_arg_tys.get(i)) { + if ty::type_is_bool(passed_arg_tys[i]) { let val = LoadRangeAssert(bcx, llarg_rust, 0, 2, llvm::False); Trunc(bcx, val, Type::i1(bcx.ccx())) } else { @@ -746,10 +745,10 @@ pub fn trans_rust_fn_with_foreign_abi(ccx: &CrateContext, // 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.inputs.len()) { - let rust_ty = *tys.fn_sig.inputs.get(i); - let llrust_ty = *tys.llsig.llarg_tys.get(i); + 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.get(i); + let llforeign_arg_ty = tys.fn_ty.arg_tys[i]; let foreign_indirect = llforeign_arg_ty.is_indirect(); if llforeign_arg_ty.is_ignore() { diff --git a/src/librustc/middle/trans/glue.rs b/src/librustc/middle/trans/glue.rs index f0b0d9d33e53e..a03f8b2c055aa 100644 --- a/src/librustc/middle/trans/glue.rs +++ b/src/librustc/middle/trans/glue.rs @@ -262,9 +262,9 @@ fn trans_struct_drop<'blk, 'tcx>(bcx: Block<'blk, 'tcx>, // use the fake info. info.unwrap_or(C_null(Type::i8p(bcx.ccx()))), GEPi(bcx, scratch.val, [0, abi::slice_elt_len])); - PointerCast(variant_cx, scratch.val, *params.get(0)) + PointerCast(variant_cx, scratch.val, params[0]) } else { - PointerCast(variant_cx, value, *params.get(0)) + PointerCast(variant_cx, value, params[0]) }; let args = vec!(self_arg); diff --git a/src/librustc/middle/trans/intrinsic.rs b/src/librustc/middle/trans/intrinsic.rs index cf47bbd2a526e..4b35e9f72ff3c 100644 --- a/src/librustc/middle/trans/intrinsic.rs +++ b/src/librustc/middle/trans/intrinsic.rs @@ -259,11 +259,11 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N let tp_ty = *substs.types.get(FnSpace, 0); let mode = appropriate_rvalue_mode(ccx, tp_ty); let src = Datum { - val: *llargs.get(1), + val: llargs[1], ty: tp_ty, kind: Rvalue::new(mode) }; - bcx = src.store_to(bcx, *llargs.get(0)); + bcx = src.store_to(bcx, llargs[0]); C_nil(ccx) } (_, "get_tydesc") => { @@ -307,130 +307,130 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N C_bool(ccx, ty::type_contents(ccx.tcx(), tp_ty).owns_managed()) } (_, "offset") => { - let ptr = *llargs.get(0); - let offset = *llargs.get(1); + let ptr = llargs[0]; + let offset = llargs[1]; InBoundsGEP(bcx, ptr, [offset]) } (_, "copy_nonoverlapping_memory") => { copy_intrinsic(bcx, false, false, *substs.types.get(FnSpace, 0), - *llargs.get(0), *llargs.get(1), *llargs.get(2)) + llargs[0], llargs[1], llargs[2]) } (_, "copy_memory") => { copy_intrinsic(bcx, true, false, *substs.types.get(FnSpace, 0), - *llargs.get(0), *llargs.get(1), *llargs.get(2)) + llargs[0], llargs[1], llargs[2]) } (_, "set_memory") => { memset_intrinsic(bcx, false, *substs.types.get(FnSpace, 0), - *llargs.get(0), *llargs.get(1), *llargs.get(2)) + llargs[0], llargs[1], llargs[2]) } (_, "volatile_copy_nonoverlapping_memory") => { copy_intrinsic(bcx, false, true, *substs.types.get(FnSpace, 0), - *llargs.get(0), *llargs.get(1), *llargs.get(2)) + llargs[0], llargs[1], llargs[2]) } (_, "volatile_copy_memory") => { copy_intrinsic(bcx, true, true, *substs.types.get(FnSpace, 0), - *llargs.get(0), *llargs.get(1), *llargs.get(2)) + llargs[0], llargs[1], llargs[2]) } (_, "volatile_set_memory") => { memset_intrinsic(bcx, true, *substs.types.get(FnSpace, 0), - *llargs.get(0), *llargs.get(1), *llargs.get(2)) + llargs[0], llargs[1], llargs[2]) } (_, "volatile_load") => { - VolatileLoad(bcx, *llargs.get(0)) + VolatileLoad(bcx, llargs[0]) }, (_, "volatile_store") => { - VolatileStore(bcx, *llargs.get(1), *llargs.get(0)); + VolatileStore(bcx, llargs[1], llargs[0]); C_nil(ccx) }, - (_, "ctlz8") => count_zeros_intrinsic(bcx, "llvm.ctlz.i8", *llargs.get(0)), - (_, "ctlz16") => count_zeros_intrinsic(bcx, "llvm.ctlz.i16", *llargs.get(0)), - (_, "ctlz32") => count_zeros_intrinsic(bcx, "llvm.ctlz.i32", *llargs.get(0)), - (_, "ctlz64") => count_zeros_intrinsic(bcx, "llvm.ctlz.i64", *llargs.get(0)), - (_, "cttz8") => count_zeros_intrinsic(bcx, "llvm.cttz.i8", *llargs.get(0)), - (_, "cttz16") => count_zeros_intrinsic(bcx, "llvm.cttz.i16", *llargs.get(0)), - (_, "cttz32") => count_zeros_intrinsic(bcx, "llvm.cttz.i32", *llargs.get(0)), - (_, "cttz64") => count_zeros_intrinsic(bcx, "llvm.cttz.i64", *llargs.get(0)), + (_, "ctlz8") => count_zeros_intrinsic(bcx, "llvm.ctlz.i8", llargs[0]), + (_, "ctlz16") => count_zeros_intrinsic(bcx, "llvm.ctlz.i16", llargs[0]), + (_, "ctlz32") => count_zeros_intrinsic(bcx, "llvm.ctlz.i32", llargs[0]), + (_, "ctlz64") => count_zeros_intrinsic(bcx, "llvm.ctlz.i64", llargs[0]), + (_, "cttz8") => count_zeros_intrinsic(bcx, "llvm.cttz.i8", llargs[0]), + (_, "cttz16") => count_zeros_intrinsic(bcx, "llvm.cttz.i16", llargs[0]), + (_, "cttz32") => count_zeros_intrinsic(bcx, "llvm.cttz.i32", llargs[0]), + (_, "cttz64") => count_zeros_intrinsic(bcx, "llvm.cttz.i64", llargs[0]), (_, "i8_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.sadd.with.overflow.i8", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i16_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.sadd.with.overflow.i16", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i32_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.sadd.with.overflow.i32", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i64_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.sadd.with.overflow.i64", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u8_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.uadd.with.overflow.i8", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u16_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.uadd.with.overflow.i16", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u32_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.uadd.with.overflow.i32", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u64_add_with_overflow") => with_overflow_intrinsic(bcx, "llvm.uadd.with.overflow.i64", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i8_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.ssub.with.overflow.i8", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i16_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.ssub.with.overflow.i16", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i32_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.ssub.with.overflow.i32", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i64_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.ssub.with.overflow.i64", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u8_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.usub.with.overflow.i8", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u16_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.usub.with.overflow.i16", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u32_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.usub.with.overflow.i32", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u64_sub_with_overflow") => with_overflow_intrinsic(bcx, "llvm.usub.with.overflow.i64", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i8_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.smul.with.overflow.i8", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i16_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.smul.with.overflow.i16", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i32_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.smul.with.overflow.i32", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "i64_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.smul.with.overflow.i64", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u8_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.umul.with.overflow.i8", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u16_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.umul.with.overflow.i16", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u32_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.umul.with.overflow.i32", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "u64_mul_with_overflow") => with_overflow_intrinsic(bcx, "llvm.umul.with.overflow.i64", ret_ty, - *llargs.get(0), *llargs.get(1)), + llargs[0], llargs[1]), (_, "return_address") => { if !fcx.caller_expects_out_pointer { @@ -452,7 +452,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N let order = if split.len() == 2 { llvm::SequentiallyConsistent } else { - match *split.get(2) { + match split[2] { "relaxed" => llvm::Monotonic, "acq" => llvm::Acquire, "rel" => llvm::Release, @@ -461,7 +461,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N } }; - match *split.get(1) { + match split[1] { "cxchg" => { // See include/llvm/IR/Instructions.h for their implementation // of this, I assume that it's good enough for us to use for @@ -480,8 +480,8 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N llvm::SequentiallyConsistent }; - let res = AtomicCmpXchg(bcx, *llargs.get(0), *llargs.get(1), - *llargs.get(2), order, + let res = AtomicCmpXchg(bcx, llargs[0], llargs[1], + llargs[2], order, strongest_failure_ordering); if unsafe { llvm::LLVMVersionMinor() >= 5 } { ExtractValue(bcx, res, 0) @@ -491,10 +491,10 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N } "load" => { - AtomicLoad(bcx, *llargs.get(0), order) + AtomicLoad(bcx, llargs[0], order) } "store" => { - AtomicStore(bcx, *llargs.get(1), *llargs.get(0), order); + AtomicStore(bcx, llargs[1], llargs[0], order); C_nil(ccx) } @@ -520,7 +520,7 @@ pub fn trans_intrinsic_call<'blk, 'tcx>(mut bcx: Block<'blk, 'tcx>, node: ast::N _ => ccx.sess().fatal("unknown atomic operation") }; - AtomicRMW(bcx, atom_op, *llargs.get(0), *llargs.get(1), order) + AtomicRMW(bcx, atom_op, llargs[0], llargs[1], order) } } diff --git a/src/librustc/middle/trans/meth.rs b/src/librustc/middle/trans/meth.rs index 0b3f1c9840c4a..1484983cd588e 100644 --- a/src/librustc/middle/trans/meth.rs +++ b/src/librustc/middle/trans/meth.rs @@ -718,7 +718,7 @@ fn emit_vtable_methods(bcx: Block, debug!("(making impl vtable) method has self or type \ params: {}", token::get_ident(ident)); - Some(C_null(Type::nil(ccx).ptr_to())).move_iter() + Some(C_null(Type::nil(ccx).ptr_to())).into_iter() } else { let mut fn_ref = trans_fn_ref_with_substs( bcx, @@ -732,11 +732,11 @@ fn emit_vtable_methods(bcx: Block, m_id, substs.clone()); } - Some(fn_ref).move_iter() + Some(fn_ref).into_iter() } } ty::TypeTraitItem(_) => { - None.move_iter() + None.into_iter() } } }).collect() diff --git a/src/librustc/middle/ty.rs b/src/librustc/middle/ty.rs index 832e9a79acae0..6ecd1c1ea140d 100644 --- a/src/librustc/middle/ty.rs +++ b/src/librustc/middle/ty.rs @@ -2042,7 +2042,7 @@ pub fn simd_type(cx: &ctxt, ty: t) -> t { match get(ty).sty { ty_struct(did, ref substs) => { let fields = lookup_struct_fields(cx, did); - lookup_field_type(cx, did, fields.get(0).id, substs) + lookup_field_type(cx, did, fields[0].id, substs) } _ => fail!("simd_type called on invalid type") } @@ -2501,12 +2501,12 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { if variants.len() == 2 { let mut data_idx = 0; - if variants.get(0).args.len() == 0 { + if variants[0].args.len() == 0 { data_idx = 1; } - if variants.get(data_idx).args.len() == 1 { - match get(*variants.get(data_idx).args.get(0)).sty { + if variants[data_idx].args.len() == 1 { + match get(variants[data_idx].args[0]).sty { ty_bare_fn(..) => { res = res - TC::ReachesFfiUnsafe; } _ => { } } @@ -2530,7 +2530,7 @@ pub fn type_contents(cx: &ctxt, ty: t) -> TypeContents { assert_eq!(p.def_id.krate, ast::LOCAL_CRATE); let ty_param_defs = cx.ty_param_defs.borrow(); - let tp_def = ty_param_defs.get(&p.def_id.node); + let tp_def = &(*ty_param_defs)[p.def_id.node]; kind_bounds_to_contents( cx, tp_def.bounds.builtin_bounds, @@ -3977,8 +3977,7 @@ fn lookup_locally_or_in_crate_store( pub fn trait_item(cx: &ctxt, trait_did: ast::DefId, idx: uint) -> ImplOrTraitItem { - let method_def_id = ty::trait_item_def_ids(cx, trait_did).get(idx) - .def_id(); + let method_def_id = (*ty::trait_item_def_ids(cx, trait_did))[idx].def_id(); impl_or_trait_item(cx, method_def_id) } diff --git a/src/librustc/middle/typeck/astconv.rs b/src/librustc/middle/typeck/astconv.rs index 0e9d255adf9da..d29720e1a1a95 100644 --- a/src/librustc/middle/typeck/astconv.rs +++ b/src/librustc/middle/typeck/astconv.rs @@ -156,7 +156,7 @@ pub fn opt_ast_region_to_region<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( Some(v) => { let mut m = String::new(); let len = v.len(); - for (i, (name, n)) in v.move_iter().enumerate() { + for (i, (name, n)) in v.into_iter().enumerate() { m.push_str(if n == 1 { format!("`{}`", name) } else { @@ -194,9 +194,7 @@ pub fn opt_ast_region_to_region<'tcx, AC: AstConv<'tcx>, RS: RegionScope>( ty::ReStatic } - Ok(rs) => { - *rs.get(0) - } + Ok(rs) => rs[0], } } }; @@ -1251,7 +1249,7 @@ fn determine_explicit_self_category<'tcx, AC: AstConv<'tcx>, self_info.explicit_self.span, self_info.untransformed_self_ty, tm.ty, - || "not a valid type for `self`".to_owned()); + || "not a valid type for `self`".to_string()); return ty::ByReferenceExplicitSelfCategory(region, tm.mutbl) } @@ -1263,7 +1261,7 @@ fn determine_explicit_self_category<'tcx, AC: AstConv<'tcx>, self_info.explicit_self.span, self_info.untransformed_self_ty, typ, - || "not a valid type for `self`".to_owned()); + || "not a valid type for `self`".to_string()); return ty::ByBoxExplicitSelfCategory } _ => { @@ -1301,7 +1299,7 @@ pub fn ty_of_closure<'tcx, AC: AstConv<'tcx>>( // no guarantee that the correct number of expected args // were supplied if i < e.inputs.len() { - Some(*e.inputs.get(i)) + Some(e.inputs[i]) } else { None } @@ -1357,7 +1355,7 @@ pub fn conv_existential_bounds<'tcx, AC: AstConv<'tcx>, RS:RegionScope>( partition_bounds(this.tcx(), span, ast_bound_refs.as_slice()); if !trait_bounds.is_empty() { - let b = trait_bounds.get(0); + let b = &trait_bounds[0]; this.tcx().sess.span_err( b.path.span, format!("only the builtin traits can be used \ @@ -1453,7 +1451,7 @@ pub fn compute_opt_region_bound(tcx: &ty::ctxt, // Determine whether there is exactly one unique region in the set // of derived region bounds. If so, use that. Otherwise, report an // error. - let r = *derived_region_bounds.get(0); + let r = derived_region_bounds[0]; if derived_region_bounds.slice_from(1).iter().any(|r1| r != *r1) { tcx.sess.span_err( span, diff --git a/src/librustc/middle/typeck/check/_match.rs b/src/librustc/middle/typeck/check/_match.rs index 9463bafc9d277..455300ecd3bad 100644 --- a/src/librustc/middle/typeck/check/_match.rs +++ b/src/librustc/middle/typeck/check/_match.rs @@ -45,7 +45,7 @@ pub fn check_match(fcx: &FnCtxt, for arm in arms.iter() { let mut pcx = pat_ctxt { fcx: fcx, - map: pat_id_map(&tcx.def_map, &**arm.pats.get(0)), + map: pat_id_map(&tcx.def_map, &*arm.pats[0]), }; for p in arm.pats.iter() { check_pat(&mut pcx, &**p, discrim_ty);} @@ -322,7 +322,7 @@ pub fn check_struct_pat_fields(pcx: &pat_ctxt, } Some(&(index, ref mut used)) => { *used = true; - let class_field = class_fields.get(index).clone(); + let class_field = class_fields[index].clone(); let field_type = ty::lookup_field_type(tcx, class_id, class_field.id, @@ -496,7 +496,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) { } } - let canon_id = *pcx.map.get(&path1.node); + let canon_id = pcx.map[path1.node]; if canon_id != pat.id { let ct = fcx.local_ty(pat.span, canon_id); demand::eqtype(fcx, pat.span, ct, typ); @@ -528,7 +528,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) { match *structure { ty::ty_struct(cid, ref substs) => { // Verify that the pattern named the right structure. - let item_did = tcx.def_map.borrow().get(&pat.id).def_id(); + let item_did = (*tcx.def_map.borrow())[pat.id].def_id(); match ty::ty_to_def_id(ty::lookup_item_type(tcx, item_did).ty) { Some(struct_did) if struct_did != cid => { span_err!(tcx.sess, path.span, E0032, @@ -599,7 +599,7 @@ pub fn check_pat(pcx: &pat_ctxt, pat: &ast::Pat, expected: ty::t) { match *s { ty::ty_tup(ref ex_elts) if e_count == ex_elts.len() => { for (i, elt) in elts.iter().enumerate() { - check_pat(pcx, &**elt, *ex_elts.get(i)); + check_pat(pcx, &**elt, ex_elts[i]); } fcx.write_ty(pat.id, expected); } diff --git a/src/librustc/middle/typeck/check/method.rs b/src/librustc/middle/typeck/check/method.rs index c2e7be2781fd6..798e4acd2910e 100644 --- a/src/librustc/middle/typeck/check/method.rs +++ b/src/librustc/middle/typeck/check/method.rs @@ -276,7 +276,7 @@ fn construct_transformed_self_ty_for_object( ty::mk_uniq(tcx, tr) } ByReferenceExplicitSelfCategory(..) | ByBoxExplicitSelfCategory => { - let transformed_self_ty = *method_ty.fty.sig.inputs.get(0); + let transformed_self_ty = method_ty.fty.sig.inputs[0]; match ty::get(transformed_self_ty).sty { ty::ty_rptr(r, mt) => { // must be SelfRegion let r = r.subst(tcx, rcvr_substs); // handle Early-Bound lifetime @@ -490,7 +490,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { let impl_items = self.tcx().impl_items.borrow(); for impl_infos in self.tcx().trait_impls.borrow().find(&trait_did).iter() { for impl_did in impl_infos.borrow().iter() { - let items = impl_items.get(impl_did); + let items = &(*impl_items)[*impl_did]; self.push_candidates_from_impl(*impl_did, items.as_slice(), true); @@ -521,7 +521,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { trait_did: DefId, closure_did: DefId, closure_function_type: &ClosureTy) { - let trait_item = ty::trait_items(self.tcx(), trait_did).get(0) + let trait_item = (*ty::trait_items(self.tcx(), trait_did))[0] .clone(); let method = match trait_item { ty::MethodTraitItem(method) => method, @@ -538,7 +538,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { } // Get the tupled type of the arguments. - let arguments_type = *closure_function_type.sig.inputs.get(0); + let arguments_type = closure_function_type.sig.inputs[0]; let return_type = closure_function_type.sig.output; let closure_region = @@ -552,7 +552,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { rcvr_substs: subst::Substs::new_trait( vec![arguments_type, return_type], vec![], - *self.fcx.infcx().next_ty_vars(1).get(0)), + self.fcx.infcx().next_ty_vars(1)[0]), method_ty: method, origin: MethodStaticUnboxedClosure(closure_did), }); @@ -733,7 +733,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { } }) { Some(pos) => { - let method = match *trait_items.get(pos) { + let method = match (*trait_items)[pos] { ty::MethodTraitItem(ref method) => (*method).clone(), ty::TypeTraitItem(_) => { tcx.sess.bug("typechecking associated type as \ @@ -771,7 +771,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { let impl_items = self.tcx().impl_items.borrow(); for impl_infos in self.tcx().inherent_impls.borrow().find(&did).iter() { for impl_did in impl_infos.iter() { - let items = impl_items.get(impl_did); + let items = &(*impl_items)[*impl_did]; self.push_candidates_from_impl(*impl_did, items.as_slice(), false); @@ -1211,7 +1211,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { // return something so we don't get errors for every mutability return Some(MethodCallee { - origin: relevant_candidates.get(0).origin.clone(), + origin: relevant_candidates[0].origin.clone(), ty: ty::mk_err(), substs: subst::Substs::empty() }); @@ -1225,7 +1225,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { } } - Some(self.confirm_candidate(rcvr_ty, relevant_candidates.get(0))) + Some(self.confirm_candidate(rcvr_ty, &relevant_candidates[0])) } fn filter_candidates(&self, rcvr_ty: ty::t, candidates: &[Candidate]) -> Vec { @@ -1299,7 +1299,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { "incorrect number of type parameters given for this method"); self.fcx.infcx().next_ty_vars(num_method_tps) } else { - Vec::from_slice(self.supplied_tps) + self.supplied_tps.to_vec() } }; @@ -1329,7 +1329,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { let args = fn_sig.inputs.slice_from(1).iter().map(|t| { t.subst(tcx, &all_substs) }); - Some(*fn_sig.inputs.get(0)).into_iter().chain(args).collect() + Some(fn_sig.inputs[0]).into_iter().chain(args).collect() } _ => fn_sig.inputs.subst(tcx, &all_substs) }; @@ -1348,7 +1348,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { tcx, &fn_sig, |br| self.fcx.infcx().next_region_var( infer::LateBoundRegion(self.span, br))); - let transformed_self_ty = *fn_sig.inputs.get(0); + let transformed_self_ty = fn_sig.inputs[0]; let fty = ty::mk_bare_fn(tcx, ty::BareFnTy { sig: fn_sig, fn_style: bare_fn_ty.fn_style, @@ -1394,7 +1394,7 @@ impl<'a, 'tcx> LookupContext<'a, 'tcx> { _ => return, }; - match ty::get(*sig.inputs.get(0)).sty { + match ty::get(sig.inputs[0]).sty { ty::ty_rptr(_, ty::mt { ty: _, mutbl: ast::MutMutable, diff --git a/src/librustc/middle/typeck/check/mod.rs b/src/librustc/middle/typeck/check/mod.rs index be622bd685501..d632ef8d58f5c 100644 --- a/src/librustc/middle/typeck/check/mod.rs +++ b/src/librustc/middle/typeck/check/mod.rs @@ -1059,8 +1059,8 @@ fn compare_impl_method(tcx: &ty::ctxt, let trait_to_skol_substs = trait_to_impl_substs .subst(tcx, &impl_to_skol_substs) - .with_method(Vec::from_slice(skol_tps.get_slice(subst::FnSpace)), - Vec::from_slice(skol_regions.get_slice(subst::FnSpace))); + .with_method(skol_tps.get_slice(subst::FnSpace).to_vec(), + skol_regions.get_slice(subst::FnSpace).to_vec()); // Check region bounds. if !check_region_bounds_on_impl_method(tcx, @@ -2592,7 +2592,7 @@ fn check_argument_types<'a>(fcx: &FnCtxt, if is_block == check_blocks { debug!("checking the argument"); - let mut formal_ty = *formal_tys.get(i); + let mut formal_ty = formal_tys[i]; match deref_args { DoDerefArgs => { @@ -3295,7 +3295,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, fcx.ccx.tcx.sess.span_bug(expr.span, "can't make anon regions here?!") } - Ok(regions) => *regions.get(0), + Ok(regions) => regions[0], }; let closure_type = ty::mk_unboxed_closure(fcx.ccx.tcx, local_def(expr.id), @@ -3637,7 +3637,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, let mut missing_fields = Vec::new(); for class_field in field_types.iter() { let name = class_field.name; - let (_, seen) = *class_field_map.get(&name); + let (_, seen) = class_field_map[name]; if !seen { missing_fields.push( format!("`{}`", token::get_name(name).get())) @@ -3865,7 +3865,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, ty::ty_struct(did, ref substs) => { let fields = ty::struct_fields(fcx.tcx(), did, substs); fields.len() == 1 - && fields.get(0).ident == + && fields[0].ident == token::special_idents::unnamed_field } _ => false @@ -4252,7 +4252,7 @@ fn check_expr_with_unifier(fcx: &FnCtxt, let elt_ts = elts.iter().enumerate().map(|(i, e)| { let t = match flds { Some(ref fs) if i < fs.len() => { - let ety = *fs.get(i); + let ety = fs[i]; check_expr_coercable_to_type(fcx, &**e, ety); ety } @@ -4757,7 +4757,7 @@ pub fn check_const(ccx: &CrateCtxt, let inh = static_inherited_fields(ccx); let rty = ty::node_id_to_type(ccx.tcx, id); let fcx = blank_fn_ctxt(ccx, &inh, rty, e.id); - let declty = fcx.ccx.tcx.tcache.borrow().get(&local_def(id)).ty; + let declty = (*fcx.ccx.tcx.tcache.borrow())[local_def(id)].ty; check_const_with_ty(&fcx, sp, e, declty); } @@ -4847,7 +4847,7 @@ pub fn check_simd(tcx: &ty::ctxt, sp: Span, id: ast::NodeId) { span_err!(tcx.sess, sp, E0075, "SIMD vector cannot be empty"); return; } - let e = ty::lookup_field_type(tcx, did, fields.get(0).id, substs); + let e = ty::lookup_field_type(tcx, did, fields[0].id, substs); if !fields.iter().all( |f| ty::lookup_field_type(tcx, did, f.id, substs) == e) { span_err!(tcx.sess, sp, E0076, "SIMD vector should be homogeneous"); @@ -5508,7 +5508,7 @@ pub fn check_intrinsic_type(ccx: &CrateCtxt, it: &ast::ForeignItem) { assert!(split.len() >= 2, "Atomic intrinsic not correct format"); //We only care about the operation here - match *split.get(1) { + match split[1] { "cxchg" => (1, vec!(ty::mk_mut_ptr(tcx, param(ccx, 0)), param(ccx, 0), param(ccx, 0)), diff --git a/src/librustc/middle/typeck/check/regionck.rs b/src/librustc/middle/typeck/check/regionck.rs index b595b9b84aed8..76074120c0edb 100644 --- a/src/librustc/middle/typeck/check/regionck.rs +++ b/src/librustc/middle/typeck/check/regionck.rs @@ -641,7 +641,7 @@ fn visit_expr(rcx: &mut Rcx, expr: &ast::Expr) { } ast::ExprMethodCall(_, _, ref args) => { - constrain_call(rcx, expr, Some(&**args.get(0)), + constrain_call(rcx, expr, Some(&*args[0]), args.slice_from(1).iter().map(|e| &**e), false); visit::walk_expr(rcx, expr); @@ -1200,7 +1200,7 @@ fn constrain_autoderefs(rcx: &mut Rcx, // Treat overloaded autoderefs as if an AutoRef adjustment // was applied on the base type, as that is always the case. let fn_sig = ty::ty_fn_sig(method.ty); - let self_ty = *fn_sig.inputs.get(0); + let self_ty = fn_sig.inputs[0]; let (m, r) = match ty::get(self_ty).sty { ty::ty_rptr(r, ref m) => (m.mutbl, r), _ => rcx.tcx().sess.span_bug(deref_expr.span, diff --git a/src/librustc/middle/typeck/coherence/mod.rs b/src/librustc/middle/typeck/coherence/mod.rs index eef466ceebb9f..7906e0101ee16 100644 --- a/src/librustc/middle/typeck/coherence/mod.rs +++ b/src/librustc/middle/typeck/coherence/mod.rs @@ -434,12 +434,12 @@ impl<'a, 'tcx> CoherenceChecker<'a, 'tcx> { }; for &impl_did in trait_impls.borrow().iter() { - let items = impl_items.get(&impl_did); + let items = &(*impl_items)[impl_did]; if items.len() < 1 { // We'll error out later. For now, just don't ICE. continue; } - let method_def_id = *items.get(0); + let method_def_id = items[0]; let self_type = self.get_self_type_for_implementation(impl_did); match ty::get(self_type.ty).sty { @@ -524,10 +524,10 @@ fn subst_receiver_types_in_method_ty(tcx: &ty::ctxt, for &space in [subst::TypeSpace, subst::SelfSpace].iter() { method_generics.types.replace( space, - Vec::from_slice(impl_poly_type.generics.types.get_slice(space))); + impl_poly_type.generics.types.get_slice(space).to_vec()); method_generics.regions.replace( space, - Vec::from_slice(impl_poly_type.generics.regions.get_slice(space))); + impl_poly_type.generics.regions.get_slice(space).to_vec()); } debug!("subst_receiver_types_in_method_ty: method_generics={}", diff --git a/src/librustc/middle/typeck/collect.rs b/src/librustc/middle/typeck/collect.rs index 8e4948bbea980..2ffb90861bf33 100644 --- a/src/librustc/middle/typeck/collect.rs +++ b/src/librustc/middle/typeck/collect.rs @@ -1298,11 +1298,11 @@ pub fn convert_struct(ccx: &CrateCtxt, write_ty_to_tcx(tcx, ctor_id, selfty); tcx.tcache.borrow_mut().insert(local_def(ctor_id), pty); - } else if struct_def.fields.get(0).node.kind.is_unnamed() { + } else if struct_def.fields[0].node.kind.is_unnamed() { // Tuple-like. let inputs: Vec<_> = struct_def.fields.iter().map( - |field| tcx.tcache.borrow().get( - &local_def(field.node.id)).ty).collect(); + |field| (*tcx.tcache.borrow())[ + local_def(field.node.id)].ty).collect(); let ctor_fn_ty = ty::mk_ctor_fn(tcx, ctor_id, inputs.as_slice(), @@ -2124,8 +2124,8 @@ fn conv_param_bounds<'tcx,AC>(this: &AC, unboxed_fn_ty_bounds } = astconv::partition_bounds(this.tcx(), span, all_bounds.as_slice()); - let unboxed_fn_ty_bounds = unboxed_fn_ty_bounds.move_iter().map(|b| { - let trait_id = this.tcx().def_map.borrow().get(&b.ref_id).def_id(); + let unboxed_fn_ty_bounds = unboxed_fn_ty_bounds.into_iter().map(|b| { + let trait_id = (*this.tcx().def_map.borrow())[b.ref_id].def_id(); let mut kind = None; for &(lang_item, this_kind) in [ (this.tcx().lang_items.fn_trait(), ast::FnUnboxedClosureKind), @@ -2170,7 +2170,7 @@ fn conv_param_bounds<'tcx,AC>(this: &AC, .chain(unboxed_fn_ty_bounds) .collect(); let region_bounds: Vec = - region_bounds.move_iter() + region_bounds.into_iter() .map(|r| ast_region_to_region(this.tcx(), r)) .collect(); ty::ParamBounds { diff --git a/src/librustc/middle/typeck/infer/combine.rs b/src/librustc/middle/typeck/infer/combine.rs index 8ae0b603e4871..15c4830646d59 100644 --- a/src/librustc/middle/typeck/infer/combine.rs +++ b/src/librustc/middle/typeck/infer/combine.rs @@ -52,7 +52,6 @@ use middle::typeck::infer::type_variable::{RelationDir, EqTo, use middle::ty_fold::{TypeFoldable}; use util::ppaux::Repr; -use std::result; use syntax::ast::{Onceness, FnStyle}; use syntax::ast; @@ -89,11 +88,10 @@ pub trait Combine<'tcx> { bs.len()))); } - try!(result::fold_(as_ - .iter() - .zip(bs.iter()) - .map(|(a, b)| self.equate().tys(*a, *b)))); - Ok(Vec::from_slice(as_)) + try!(as_.iter().zip(bs.iter()) + .map(|(a, b)| self.equate().tys(*a, *b)) + .collect::>>()); + Ok(as_.to_vec()) } fn substs(&self, @@ -342,8 +340,8 @@ pub fn super_fn_sigs<'tcx, C: Combine<'tcx>>(this: &C, b_args: &[ty::t]) -> cres> { if a_args.len() == b_args.len() { - result::collect(a_args.iter().zip(b_args.iter()) - .map(|(a, b)| this.args(*a, *b))) + a_args.iter().zip(b_args.iter()) + .map(|(a, b)| this.args(*a, *b)).collect() } else { Err(ty::terr_arg_count) } @@ -537,9 +535,10 @@ pub fn super_tys<'tcx, C: Combine<'tcx>>(this: &C, a: ty::t, b: ty::t) -> cres { if as_.len() == bs.len() { - result::collect(as_.iter().zip(bs.iter()) - .map(|(a, b)| this.tys(*a, *b))) - .and_then(|ts| Ok(ty::mk_tup(tcx, ts)) ) + as_.iter().zip(bs.iter()) + .map(|(a, b)| this.tys(*a, *b)) + .collect::>() + .map(|ts| ty::mk_tup(tcx, ts)) } else { Err(ty::terr_tuple_size( expected_found(this, as_.len(), bs.len()))) diff --git a/src/librustc/middle/typeck/infer/error_reporting.rs b/src/librustc/middle/typeck/infer/error_reporting.rs index 2ab585f5ae998..a124523956bc7 100644 --- a/src/librustc/middle/typeck/infer/error_reporting.rs +++ b/src/librustc/middle/typeck/infer/error_reporting.rs @@ -256,7 +256,7 @@ impl<'a, 'tcx> ErrorReporting for InferCtxt<'a, 'tcx> { } } if !same_regions.is_empty() { - let common_scope_id = same_regions.get(0).scope_id; + let common_scope_id = same_regions[0].scope_id; for sr in same_regions.iter() { // Since ProcessedErrors is used to reconstruct the function // declaration, we want to make sure that they are, in fact, @@ -1003,7 +1003,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { names.push(lt_name); } names.sort(); - let name = token::str_to_ident(names.get(0).as_slice()).name; + let name = token::str_to_ident(names[0].as_slice()).name; return (name_to_dummy_lifetime(name), Kept); } return (self.life_giver.give_lifetime(), Fresh); @@ -1209,7 +1209,7 @@ impl<'a, 'tcx> Rebuilder<'a, 'tcx> { let mut new_ty = P(ty.clone()); let mut ty_queue = vec!(ty); while !ty_queue.is_empty() { - let cur_ty = ty_queue.shift().unwrap(); + let cur_ty = ty_queue.remove(0).unwrap(); match cur_ty.node { ast::TyRptr(lt_opt, ref mut_ty) => { let rebuild = match lt_opt { @@ -1768,7 +1768,7 @@ impl LifeGiver { let (n, r) = (counter/26 + 1, counter % 26); let letter: char = from_u32((r+97) as u32).unwrap(); for _ in range(0, n) { - s.push_char(letter); + s.push(letter); } s } diff --git a/src/librustc/middle/typeck/infer/region_inference/mod.rs b/src/librustc/middle/typeck/infer/region_inference/mod.rs index 504550f0d40d2..b4704b2a27c97 100644 --- a/src/librustc/middle/typeck/infer/region_inference/mod.rs +++ b/src/librustc/middle/typeck/infer/region_inference/mod.rs @@ -255,7 +255,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { pub fn commit(&self, snapshot: RegionSnapshot) { debug!("RegionVarBindings: commit({})", snapshot.length); assert!(self.undo_log.borrow().len() > snapshot.length); - assert!(*self.undo_log.borrow().get(snapshot.length) == OpenSnapshot); + assert!((*self.undo_log.borrow())[snapshot.length] == OpenSnapshot); let mut undo_log = self.undo_log.borrow_mut(); if snapshot.length == 0 { @@ -269,7 +269,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { debug!("RegionVarBindings: rollback_to({})", snapshot); let mut undo_log = self.undo_log.borrow_mut(); assert!(undo_log.len() > snapshot.length); - assert!(*undo_log.get(snapshot.length) == OpenSnapshot); + assert!((*undo_log)[snapshot.length] == OpenSnapshot); while undo_log.len() > snapshot.length + 1 { match undo_log.pop().unwrap() { OpenSnapshot => { @@ -529,7 +529,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { match *self.values.borrow() { None => { self.tcx.sess.span_bug( - self.var_origins.borrow().get(rid.index).span(), + (*self.var_origins.borrow())[rid.index].span(), "attempt to resolve region variable before values have \ been computed!") } @@ -608,7 +608,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { let mut result_index = 0; while result_index < result_set.len() { // nb: can't use uint::range() here because result_set grows - let r = *result_set.get(result_index); + let r = result_set[result_index]; debug!("result_index={}, r={}", result_index, r); for undo_entry in @@ -636,13 +636,13 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { ReFree(a), ReInfer(ReVar(b))); } &AddVerify(i) => { - match self.verifys.borrow().get(i) { - &VerifyRegSubReg(_, a, b) => { + match (*self.verifys.borrow())[i] { + VerifyRegSubReg(_, a, b) => { consider_adding_bidirectional_edges( &mut result_set, r, a, b); } - &VerifyParamBound(_, _, a, ref bs) => { + VerifyParamBound(_, _, a, ref bs) => { for &b in bs.iter() { consider_adding_bidirectional_edges( &mut result_set, r, @@ -727,7 +727,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { (ReInfer(ReVar(v_id)), _) | (_, ReInfer(ReVar(v_id))) => { self.tcx.sess.span_bug( - self.var_origins.borrow().get(v_id.index).span(), + (*self.var_origins.borrow())[v_id.index].span(), format!("lub_concrete_regions invoked with \ non-concrete regions: {}, {}", a, @@ -834,7 +834,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { (ReInfer(ReVar(v_id)), _) | (_, ReInfer(ReVar(v_id))) => { self.tcx.sess.span_bug( - self.var_origins.borrow().get(v_id.index).span(), + (*self.var_origins.borrow())[v_id.index].span(), format!("glb_concrete_regions invoked with \ non-concrete regions: {}, {}", a, @@ -1269,7 +1269,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { if opt_graph.is_none() { opt_graph = Some(self.construct_graph()); } - let graph = opt_graph.get_ref(); + let graph = opt_graph.as_ref().unwrap(); let node_vid = RegionVid { index: idx }; match var_data[idx].classification { @@ -1370,7 +1370,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { if !self.is_subregion_of(lower_bound.region, upper_bound.region) { errors.push(SubSupConflict( - self.var_origins.borrow().get(node_idx.index).clone(), + (*self.var_origins.borrow())[node_idx.index].clone(), lower_bound.origin.clone(), lower_bound.region, upper_bound.origin.clone(), @@ -1381,7 +1381,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } self.tcx.sess.span_bug( - self.var_origins.borrow().get(node_idx.index).span(), + (*self.var_origins.borrow())[node_idx.index].span(), format!("collect_error_for_expanding_node() could not find error \ for var {}, lower_bounds={}, upper_bounds={}", node_idx, @@ -1414,7 +1414,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { Ok(_) => {} Err(_) => { errors.push(SupSupConflict( - self.var_origins.borrow().get(node_idx.index).clone(), + (*self.var_origins.borrow())[node_idx.index].clone(), upper_bound_1.origin.clone(), upper_bound_1.region, upper_bound_2.origin.clone(), @@ -1426,7 +1426,7 @@ impl<'a, 'tcx> RegionVarBindings<'a, 'tcx> { } self.tcx.sess.span_bug( - self.var_origins.borrow().get(node_idx.index).span(), + (*self.var_origins.borrow())[node_idx.index].span(), format!("collect_error_for_contracting_node() could not find error \ for var {}, upper_bounds={}", node_idx, @@ -1578,7 +1578,7 @@ fn normalize(values: &Vec, r: ty::Region) -> ty::Region { } fn lookup(values: &Vec, rid: ty::RegionVid) -> ty::Region { - match *values.get(rid.index) { + match values[rid.index] { Value(r) => r, NoValue => ReEmpty, // No constraints, return ty::ReEmpty ErrorValue => ReStatic, // Previously reported error. diff --git a/src/librustc/middle/typeck/variance.rs b/src/librustc/middle/typeck/variance.rs index dd6e087b6727a..20e550f3f306c 100644 --- a/src/librustc/middle/typeck/variance.rs +++ b/src/librustc/middle/typeck/variance.rs @@ -657,7 +657,7 @@ impl<'a, 'tcx> ConstraintContext<'a, 'tcx> { // variance not yet inferred, so return a symbolic // variance. let InferredIndex(index) = self.inferred_index(param_def_id.node); - self.terms_cx.inferred_infos.get(index).term + self.terms_cx.inferred_infos[index].term } else { // Parameter on an item defined within another crate: // variance already inferred, just look it up. @@ -980,15 +980,14 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { let Constraint { inferred, variance: term } = *constraint; let InferredIndex(inferred) = inferred; let variance = self.evaluate(term); - let old_value = *self.solutions.get(inferred); + let old_value = self.solutions[inferred]; let new_value = glb(variance, old_value); if old_value != new_value { debug!("Updating inferred {} (node {}) \ from {} to {} due to {}", inferred, self.terms_cx - .inferred_infos - .get(inferred) + .inferred_infos[inferred] .param_id, old_value, new_value, @@ -1017,14 +1016,14 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { let mut index = 0; let num_inferred = self.terms_cx.num_inferred(); while index < num_inferred { - let item_id = inferred_infos.get(index).item_id; + let item_id = inferred_infos[index].item_id; let mut types = VecPerParamSpace::empty(); let mut regions = VecPerParamSpace::empty(); while index < num_inferred && - inferred_infos.get(index).item_id == item_id { - let info = inferred_infos.get(index); - let variance = *solutions.get(index); + inferred_infos[index].item_id == item_id { + let info = inferred_infos[index]; + let variance = solutions[index]; debug!("Index {} Info {} / {} / {} Variance {}", index, info.index, info.kind, info.space, variance); match info.kind { @@ -1074,7 +1073,7 @@ impl<'a, 'tcx> SolveContext<'a, 'tcx> { } InferredTerm(InferredIndex(index)) => { - *self.solutions.get(index) + self.solutions[index] } } } diff --git a/src/librustc/plugin/load.rs b/src/librustc/plugin/load.rs index ecbe3409139f7..921cd7a4107c9 100644 --- a/src/librustc/plugin/load.rs +++ b/src/librustc/plugin/load.rs @@ -77,8 +77,8 @@ pub fn load_plugins(sess: &Session, krate: &ast::Crate, Some(addl_plugins) => { // Add in the additional plugins requested by the frontend let Plugins { macros: addl_macros, registrars: addl_registrars } = addl_plugins; - plugins.macros.push_all_move(addl_macros); - plugins.registrars.push_all_move(addl_registrars); + plugins.macros.extend(addl_macros.into_iter()); + plugins.registrars.extend(addl_registrars.into_iter()); } None => () } diff --git a/src/librustc/util/common.rs b/src/librustc/util/common.rs index 082dde978d8e7..ed38f6f871d79 100644 --- a/src/librustc/util/common.rs +++ b/src/librustc/util/common.rs @@ -139,7 +139,7 @@ pub fn can_reach,T:Eq+Clone+Hash>( let mut queue = vec!(source); let mut i = 0; while i < queue.len() { - match edges_map.find(queue.get(i)) { + match edges_map.find(&queue[i]) { Some(edges) => { for target in edges.iter() { if *target == destination { diff --git a/src/librustc/util/ppaux.rs b/src/librustc/util/ppaux.rs index 085295cad7d2a..a20a988c881dd 100644 --- a/src/librustc/util/ppaux.rs +++ b/src/librustc/util/ppaux.rs @@ -270,7 +270,7 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { ast::NormalFn => {} _ => { s.push_str(fn_style.to_string().as_slice()); - s.push_char(' '); + s.push(' '); } }; @@ -282,7 +282,7 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { match ident { Some(i) => { - s.push_char(' '); + s.push(' '); s.push_str(token::get_ident(i).get()); } _ => { } @@ -307,7 +307,7 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { ast::NormalFn => {} _ => { s.push_str(cty.fn_style.to_string().as_slice()); - s.push_char(' '); + s.push(' '); } }; @@ -330,7 +330,7 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { } } - s.into_owned() + s } fn push_sig_to_string(cx: &ctxt, @@ -339,13 +339,13 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { ket: char, sig: &ty::FnSig, bounds: &str) { - s.push_char(bra); + s.push(bra); let strs: Vec = sig.inputs.iter().map(|a| fn_input_to_string(cx, *a)).collect(); s.push_str(strs.connect(", ").as_slice()); if sig.variadic { s.push_str(", ..."); } - s.push_char(ket); + s.push(ket); if !bounds.is_empty() { s.push_str(":"); @@ -355,7 +355,7 @@ pub fn ty_to_string(cx: &ctxt, typ: t) -> String { if ty::get(sig.output).sty != ty_nil { s.push_str(" -> "); if ty::type_is_bot(sig.output) { - s.push_char('!'); + s.push('!'); } else { s.push_str(ty_to_string(cx, sig.output).as_slice()); } @@ -670,10 +670,10 @@ impl Repr for ty::BuiltinBounds { let mut res = Vec::new(); for b in self.iter() { res.push(match b { - ty::BoundSend => "Send".to_owned(), - ty::BoundSized => "Sized".to_owned(), - ty::BoundCopy => "Copy".to_owned(), - ty::BoundSync => "Sync".to_owned(), + ty::BoundSend => "Send".to_string(), + ty::BoundSized => "Sized".to_string(), + ty::BoundCopy => "Copy".to_string(), + ty::BoundSync => "Sync".to_string(), }); } res.connect("+") @@ -1007,10 +1007,10 @@ impl Repr for ty::BuiltinBound { impl UserString for ty::BuiltinBound { fn user_string(&self, _tcx: &ctxt) -> String { match *self { - ty::BoundSend => "Send".to_owned(), - ty::BoundSized => "Sized".to_owned(), - ty::BoundCopy => "Copy".to_owned(), - ty::BoundSync => "Sync".to_owned(), + ty::BoundSend => "Send".to_string(), + ty::BoundSized => "Sized".to_string(), + ty::BoundCopy => "Copy".to_string(), + ty::BoundSync => "Sync".to_string(), } } } diff --git a/src/librustc/util/snapshot_vec.rs b/src/librustc/util/snapshot_vec.rs index 03e1559cba2bf..7a7c8f8d94f72 100644 --- a/src/librustc/util/snapshot_vec.rs +++ b/src/librustc/util/snapshot_vec.rs @@ -94,7 +94,7 @@ impl> SnapshotVec { } pub fn get<'a>(&'a self, index: uint) -> &'a T { - self.values.get(index) + &self.values[index] } pub fn get_mut<'a>(&'a mut self, index: uint) -> &'a mut T { @@ -133,7 +133,7 @@ impl> SnapshotVec { // Invariant established by start_snapshot(): assert!( - match *self.undo_log.get(snapshot.length) { + match self.undo_log[snapshot.length] { OpenSnapshot => true, _ => false }); diff --git a/src/librustdoc/html/format.rs b/src/librustdoc/html/format.rs index 02ba4aabc9919..ca8a6cd0c4010 100644 --- a/src/librustdoc/html/format.rs +++ b/src/librustdoc/html/format.rs @@ -708,9 +708,11 @@ impl fmt::Show for ModuleSummary { let path = context.connect("::"); try!(write!(f, "")); - try!(write!(f, "{}", - Vec::from_slice(context.slice_from(1)) - .append_one("index.html").connect("/"), + try!(write!(f, "{}", { + let mut url = context.slice_from(1).to_vec(); + url.push("index.html"); + url.connect("/") + }, path)); try!(write!(f, "")); try!(write!(f, " fmt::Show for Item<'a> { } } try!(write!(fmt, "{}", - shortty(self.item), self.item.name.get_ref().as_slice())); + shortty(self.item), self.item.name.as_ref().unwrap().as_slice())); // Write stability level try!(write!(fmt, "{}", Stability(&self.item.stability))); @@ -1395,12 +1395,12 @@ impl<'a> fmt::Show for Item<'a> { fn item_path(item: &clean::Item) -> String { match item.inner { clean::ModuleItem(..) => { - format!("{}/index.html", item.name.get_ref()) + format!("{}/index.html", item.name.as_ref().unwrap()) } _ => { format!("{}.{}.html", shortty(item).to_static_str(), - *item.name.get_ref()) + *item.name.as_ref().unwrap()) } } } @@ -1560,7 +1560,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, ConciseStability(&myitem.stability), VisSpace(myitem.visibility), MutableSpace(s.mutability), - *myitem.name.get_ref(), + *myitem.name.as_ref().unwrap(), s.type_, Initializer(s.expr.as_slice(), Item { cx: cx, item: myitem }), Markdown(blank(myitem.doc_value())))); @@ -1574,7 +1574,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, ", ConciseStability(&myitem.stability), VisSpace(myitem.visibility), - *myitem.name.get_ref(), + *myitem.name.as_ref().unwrap(), s.type_, Initializer(s.expr.as_slice(), Item { cx: cx, item: myitem }), Markdown(blank(myitem.doc_value())))); @@ -1611,7 +1611,7 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context, {} ", - *myitem.name.get_ref(), + *myitem.name.as_ref().unwrap(), Markdown(shorter(myitem.doc_value())), class = shortty(myitem), href = item_path(myitem), @@ -1630,7 +1630,7 @@ fn item_function(w: &mut fmt::Formatter, it: &clean::Item, {name}{generics}{decl}{where_clause}", vis = VisSpace(it.visibility), fn_style = FnStyleSpace(f.fn_style), - name = it.name.get_ref().as_slice(), + name = it.name.as_ref().unwrap().as_slice(), generics = f.generics, where_clause = WhereClause(&f.generics), decl = f.decl)); @@ -1651,7 +1651,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, // Output the trait definition try!(write!(w, "
{}trait {}{}{}{} ",
                   VisSpace(it.visibility),
-                  it.name.get_ref().as_slice(),
+                  it.name.as_ref().unwrap().as_slice(),
                   t.generics,
                   bounds,
                   WhereClause(&t.generics)));
@@ -1700,7 +1700,7 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item,
                   -> fmt::Result {
         try!(write!(w, "

{}", shortty(m.item()), - *m.item().name.get_ref(), + *m.item().name.as_ref().unwrap(), ConciseStability(&m.item().stability))); try!(render_method(w, m.item())); try!(write!(w, "

")); @@ -1753,11 +1753,11 @@ fn item_trait(w: &mut fmt::Formatter, cx: &Context, it: &clean::Item, path = if ast_util::is_local(it.def_id) { cx.current.connect("/") } else { - let path = cache.external_paths.get(&it.def_id); + let path = &cache.external_paths[it.def_id]; path.slice_to(path.len() - 1).connect("/") }, ty = shortty(it).to_static_str(), - name = *it.name.get_ref())); + name = *it.name.as_ref().unwrap())); Ok(()) } @@ -1772,7 +1772,7 @@ fn render_method(w: &mut fmt::Formatter, meth: &clean::Item) -> fmt::Result { _ => "", }, ty = shortty(it), - name = it.name.get_ref().as_slice(), + name = it.name.as_ref().unwrap().as_slice(), generics = *g, decl = Method(selfty, d), where_clause = WhereClause(g)) @@ -1816,7 +1816,7 @@ fn item_struct(w: &mut fmt::Formatter, it: &clean::Item, try!(write!(w, "\ {stab}{name}", stab = ConciseStability(&field.stability), - name = field.name.get_ref().as_slice())); + name = field.name.as_ref().unwrap().as_slice())); try!(document(w, field)); try!(write!(w, "")); } @@ -1832,7 +1832,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item, e: &clean::Enum) -> fmt::Result { try!(write!(w, "
{}enum {}{}{}",
                   VisSpace(it.visibility),
-                  it.name.get_ref().as_slice(),
+                  it.name.as_ref().unwrap().as_slice(),
                   e.generics,
                   WhereClause(&e.generics)));
     if e.variants.len() == 0 && !e.variants_stripped {
@@ -1885,7 +1885,7 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
         for variant in e.variants.iter() {
             try!(write!(w, "{stab}{name}",
                           stab = ConciseStability(&variant.stability),
-                          name = variant.name.get_ref().as_slice()));
+                          name = variant.name.as_ref().unwrap().as_slice()));
             try!(document(w, variant));
             match variant.inner {
                 clean::VariantItem(ref var) => {
@@ -1906,8 +1906,8 @@ fn item_enum(w: &mut fmt::Formatter, it: &clean::Item,
                                 try!(write!(w, "\
                                                   {f}",
-                                              v = variant.name.get_ref().as_slice(),
-                                              f = field.name.get_ref().as_slice()));
+                                              v = variant.name.as_ref().unwrap().as_slice(),
+                                              f = field.name.as_ref().unwrap().as_slice()));
                                 try!(document(w, field));
                                 try!(write!(w, ""));
                             }
@@ -1936,7 +1936,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
     try!(write!(w, "{}{}{}",
                   VisSpace(it.visibility),
                   if structhead {"struct "} else {""},
-                  it.name.get_ref().as_slice()));
+                  it.name.as_ref().unwrap().as_slice()));
     match g {
         Some(g) => try!(write!(w, "{}{}", *g, WhereClause(g))),
         None => {}
@@ -1953,7 +1953,7 @@ fn render_struct(w: &mut fmt::Formatter, it: &clean::Item,
                     clean::StructFieldItem(clean::TypedStructField(ref ty)) => {
                         try!(write!(w, "    {}{}: {},\n{}",
                                       VisSpace(field.visibility),
-                                      field.name.get_ref().as_slice(),
+                                      field.name.as_ref().unwrap().as_slice(),
                                       *ty,
                                       tab));
                     }
@@ -2042,7 +2042,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result {
     fn doctraititem(w: &mut fmt::Formatter, item: &clean::Item, dox: bool)
                     -> fmt::Result {
         try!(write!(w, "

{}", - *item.name.get_ref(), + *item.name.as_ref().unwrap(), ConciseStability(&item.stability))); try!(render_method(w, item)); try!(write!(w, "

\n")); @@ -2096,7 +2096,7 @@ fn render_impl(w: &mut fmt::Formatter, i: &Impl) -> fmt::Result { fn item_typedef(w: &mut fmt::Formatter, it: &clean::Item, t: &clean::Typedef) -> fmt::Result { try!(write!(w, "
type {}{} = {};
", - it.name.get_ref().as_slice(), + it.name.as_ref().unwrap().as_slice(), t.generics, t.type_)); @@ -2231,5 +2231,5 @@ fn get_basic_keywords() -> &'static str { } fn make_item_keywords(it: &clean::Item) -> String { - format!("{}, {}", get_basic_keywords(), it.name.get_ref()) + format!("{}, {}", get_basic_keywords(), it.name.as_ref().unwrap()) } diff --git a/src/librustrt/args.rs b/src/librustrt/args.rs index 9b1dd7a825494..3138c9be99247 100644 --- a/src/librustrt/args.rs +++ b/src/librustrt/args.rs @@ -125,8 +125,8 @@ mod imp { let saved_value = take(); let expected = vec![ - Vec::from_slice(b"happy"), - Vec::from_slice(b"today?"), + b"happy".to_vec(), + b"today?".to_vec(), ]; put(expected.clone()); diff --git a/src/librustrt/c_str.rs b/src/librustrt/c_str.rs index a5ac70286fe81..a4129fe35067a 100644 --- a/src/librustrt/c_str.rs +++ b/src/librustrt/c_str.rs @@ -204,30 +204,6 @@ impl CString { self.buf as *mut _ } - /// Calls a closure with a reference to the underlying `*libc::c_char`. - #[deprecated="use `.as_ptr()`"] - pub fn with_ref(&self, f: |*const libc::c_char| -> T) -> T { - f(self.buf) - } - - /// Calls a closure with a mutable reference to the underlying `*libc::c_char`. - #[deprecated="use `.as_mut_ptr()`"] - pub fn with_mut_ref(&mut self, f: |*mut libc::c_char| -> T) -> T { - f(self.buf as *mut libc::c_char) - } - - /// Returns true if the CString is a null. - #[deprecated="a CString cannot be null"] - pub fn is_null(&self) -> bool { - self.buf.is_null() - } - - /// Returns true if the CString is not null. - #[deprecated="a CString cannot be null"] - pub fn is_not_null(&self) -> bool { - self.buf.is_not_null() - } - /// Returns whether or not the `CString` owns the buffer. pub fn owns_buffer(&self) -> bool { self.owns_buffer_ diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index eda38e96cbb1a..73b4773fb3ff9 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -406,14 +406,6 @@ impl<'a> Encoder<'a> { } m.unwrap() } - - /// Encode the specified struct into a json str - /// - /// Note: this function is deprecated. Consider using `json::encode` instead. - #[deprecated = "Replaced by `json::encode`"] - pub fn str_encode, io::IoError>>(object: &T) -> string::String { - encode(object) - } } impl<'a> ::Encoder for Encoder<'a> { diff --git a/src/libstd/ascii.rs b/src/libstd/ascii.rs index 1c80627d3282b..07be15486fdbc 100644 --- a/src/libstd/ascii.rs +++ b/src/libstd/ascii.rs @@ -25,13 +25,6 @@ use string::{mod, String}; use to_string::IntoStr; use vec::Vec; -#[deprecated="this trait has been renamed to `AsciiExt`"] -pub use self::AsciiExt as StrAsciiExt; - -#[deprecated="this trait has been renamed to `OwnedAsciiExt`"] -pub use self::OwnedAsciiExt as OwnedStrAsciiExt; - - /// Datatype to hold one ascii character. It wraps a `u8`, with the highest bit always zero. #[deriving(Clone, PartialEq, PartialOrd, Ord, Eq, Hash)] pub struct Ascii { chr: u8 } @@ -49,26 +42,12 @@ impl Ascii { self.chr as char } - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `to_lowercase`"] - pub fn to_lower(self) -> Ascii { - self.to_lowercase() - } - /// Convert to lowercase. #[inline] pub fn to_lowercase(self) -> Ascii { Ascii{chr: ASCII_LOWER_MAP[self.chr as uint]} } - /// Deprecated: use `to_uppercase` - #[inline] - #[deprecated="renamed to `to_uppercase`"] - pub fn to_upper(self) -> Ascii { - self.to_uppercase() - } - /// Convert to uppercase. #[inline] pub fn to_uppercase(self) -> Ascii { @@ -83,13 +62,6 @@ impl Ascii { // the following methods are like ctype, and the implementation is inspired by musl - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `is_alphabetic`"] - pub fn is_alpha(&self) -> bool { - self.is_alphabetic() - } - /// Check if the character is a letter (a-z, A-Z) #[inline] pub fn is_alphabetic(&self) -> bool { @@ -102,13 +74,6 @@ impl Ascii { self.chr >= 0x30 && self.chr <= 0x39 } - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `is_alphanumeric`"] - pub fn is_alnum(&self) -> bool { - self.is_alphanumeric() - } - /// Check if the character is a letter or number #[inline] pub fn is_alphanumeric(&self) -> bool { @@ -139,26 +104,12 @@ impl Ascii { (self.chr - 0x20) < 0x5F } - /// Deprecated: use `to_lowercase` - #[inline] - #[deprecated="renamed to `is_lowercase`"] - pub fn is_lower(&self) -> bool { - self.is_lowercase() - } - /// Checks if the character is lowercase #[inline] pub fn is_lowercase(&self) -> bool { (self.chr - b'a') < 26 } - #[inline] - #[allow(missing_doc)] - #[deprecated="renamed to `is_uppercase`"] - pub fn is_upper(&self) -> bool { - self.is_uppercase() - } - /// Checks if the character is uppercase #[inline] pub fn is_uppercase(&self) -> bool { @@ -581,7 +532,6 @@ mod tests { use prelude::*; use super::*; use char::from_u32; - use vec::Vec; use str::StrSlice; macro_rules! v2ascii ( @@ -590,7 +540,7 @@ mod tests { ) macro_rules! vec2ascii ( - ($($e:expr),*) => (Vec::from_slice([$(Ascii{chr:$e}),*])); + ($($e:expr),*) => ([$(Ascii{chr:$e}),*].to_vec()); ) #[test] diff --git a/src/libstd/collections/hashmap/map.rs b/src/libstd/collections/hashmap/map.rs index bdd9d8d9d1f59..ac0d117e02a11 100644 --- a/src/libstd/collections/hashmap/map.rs +++ b/src/libstd/collections/hashmap/map.rs @@ -22,7 +22,7 @@ use iter; use mem::replace; use mem; use num; -use ops::{Deref, DerefMut}; +use ops::Deref; use option::{Some, None, Option}; use result::{Ok, Err}; use ops::Index; @@ -425,25 +425,6 @@ impl SearchResult { } } -/// A newtyped mutable reference to the hashmap that allows e.g. Deref to be -/// implemented without making changes to the visible interface of HashMap. -/// Used internally because it's accepted by the search functions above. -struct MapMutRef<'a, K: 'a, V: 'a, H: 'a> { - map_ref: &'a mut HashMap -} - -impl<'a, K, V, H> Deref> for MapMutRef<'a, K, V, H> { - fn deref(&self) -> &RawTable { - &self.map_ref.table - } -} - -impl<'a, K, V, H> DerefMut> for MapMutRef<'a, K, V, H> { - fn deref_mut(&mut self) -> &mut RawTable { - &mut self.map_ref.table - } -} - impl, V, S, H: Hasher> HashMap { fn make_hash>(&self, x: &X) -> SafeHash { table::make_hash(&self.hasher, x) @@ -847,253 +828,6 @@ impl, V, S, H: Hasher> HashMap { } } - /// Inserts an element which has already been hashed, returning a reference - /// to that element inside the hashtable. This is more efficient that using - /// `insert`, since the key will not be rehashed. - fn insert_hashed(&mut self, hash: SafeHash, k: K, v: V) -> &mut V { - let potential_new_size = self.table.size() + 1; - self.make_some_room(potential_new_size); - self.insert_hashed_nocheck(hash, k, v) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1i), - /// Occupied(entry) => entry.into_mut(), - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Return the value corresponding to the key in the map, or insert - /// and return the value if it doesn't exist. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// let mut map = HashMap::new(); - /// - /// // Insert 1i with key "a" - /// assert_eq!(*map.find_or_insert("a", 1i), 1); - /// - /// // Find the existing key - /// assert_eq!(*map.find_or_insert("a", -2), 1); - /// ``` - #[deprecated = "use entry instead"] - #[allow(deprecated)] - pub fn find_or_insert(&mut self, k: K, v: V) -> &mut V { - self.find_with_or_insert_with(k, v, |_k, _v, _a| (), |_k, a| a) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1i), - /// Occupied(entry) => entry.into_mut(), - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Return the value corresponding to the key in the map, or create, - /// insert, and return a new value if it doesn't exist. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// let mut map = HashMap::new(); - /// - /// // Insert 10 with key 2 - /// assert_eq!(*map.find_or_insert_with(2i, |&key| 5 * key as uint), 10u); - /// - /// // Find the existing key - /// assert_eq!(*map.find_or_insert_with(2, |&key| key as uint), 10); - /// ``` - #[deprecated = "use entry instead"] - #[allow(deprecated)] - pub fn find_or_insert_with<'a>(&'a mut self, k: K, f: |&K| -> V) - -> &'a mut V { - self.find_with_or_insert_with(k, (), |_k, _v, _a| (), |k, _a| f(k)) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1u), - /// Occupied(mut entry) => { - /// *entry.get_mut() += 1; - /// entry.into_mut() - /// } - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Insert a key-value pair into the map if the key is not already present. - /// Otherwise, modify the existing value for the key. - /// Returns the new or modified value for the key. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// let mut map = HashMap::new(); - /// - /// // Insert 2 with key "a" - /// assert_eq!(*map.insert_or_update_with("a", 2u, |_key, val| *val = 3), 2); - /// - /// // Update and return the existing value - /// assert_eq!(*map.insert_or_update_with("a", 9, |_key, val| *val = 7), 7); - /// assert_eq!(map["a"], 7); - /// ``` - #[deprecated = "use entry instead"] - pub fn insert_or_update_with<'a>( - &'a mut self, - k: K, - v: V, - f: |&K, &mut V|) - -> &'a mut V { - let potential_new_size = self.table.size() + 1; - self.make_some_room(potential_new_size); - - let hash = self.make_hash(&k); - self.insert_or_replace_with(hash, k, v, |kref, vref, _v| f(kref, vref)) - } - - /// Deprecated: use `entry` as follows instead: - /// - /// ``` - /// use std::collections::HashMap; - /// use std::collections::hashmap::{Occupied, Vacant}; - /// - /// let mut map = HashMap::new(); - /// - /// let result = match map.entry("a") { - /// Vacant(entry) => entry.set(1u), - /// Occupied(mut entry) => { - /// *entry.get_mut() += 1; - /// entry.into_mut() - /// } - /// }; - /// assert_eq!(*result, 1); - /// ``` - /// - /// Modify and return the value corresponding to the key in the map, or - /// insert and return a new value if it doesn't exist. - /// - /// This method allows for all insertion behaviours of a hashmap; - /// see methods like - /// [`insert`](../trait.MutableMap.html#tymethod.insert), - /// [`find_or_insert`](#method.find_or_insert) and - /// [`insert_or_update_with`](#method.insert_or_update_with) - /// for less general and more friendly variations of this. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// use std::collections::HashMap; - /// - /// // map some strings to vectors of strings - /// let mut map = HashMap::new(); - /// map.insert("a key", vec!["value"]); - /// map.insert("z key", vec!["value"]); - /// - /// let new = vec!["a key", "b key", "z key"]; - /// - /// for k in new.into_iter() { - /// map.find_with_or_insert_with( - /// k, "new value", - /// // if the key does exist either prepend or append this - /// // new value based on the first letter of the key. - /// |key, already, new| { - /// if key.as_slice().starts_with("z") { - /// already.insert(0, new); - /// } else { - /// already.push(new); - /// } - /// }, - /// // if the key doesn't exist in the map yet, add it in - /// // the obvious way. - /// |_k, v| vec![v]); - /// } - /// - /// assert_eq!(map.len(), 3); - /// assert_eq!(map["a key"], vec!["value", "new value"]); - /// assert_eq!(map["b key"], vec!["new value"]); - /// assert_eq!(map["z key"], vec!["new value", "value"]); - /// ``` - #[deprecated = "use entry instead"] - pub fn find_with_or_insert_with<'a, A>(&'a mut self, - k: K, - a: A, - found: |&K, &mut V, A|, - not_found: |&K, A| -> V) - -> &'a mut V - { - let hash = self.make_hash(&k); - let this = MapMutRef { map_ref: self }; - - match search_hashed(this, &hash, &k) { - FoundExisting(bucket) => { - let (_, v_ref) = bucket.into_mut_refs(); - found(&k, v_ref, a); - v_ref - } - TableRef(this) => { - let v = not_found(&k, a); - this.map_ref.insert_hashed(hash, k, v) - } - } - } - - /// Retrieves a value for the given key. - /// See [`find`](../trait.Map.html#tymethod.find) for a non-failing alternative. - /// - /// # Failure - /// - /// Fails if the key is not present. - /// - /// # Example - /// - /// ``` - /// #![allow(deprecated)] - /// - /// use std::collections::HashMap; - /// - /// let mut map = HashMap::new(); - /// map.insert("a", 1i); - /// assert_eq!(map.get(&"a"), &1); - /// ``` - #[deprecated = "prefer indexing instead, e.g., map[key]"] - pub fn get<'a>(&'a self, k: &K) -> &'a V { - match self.find(k) { - Some(v) => v, - None => fail!("no entry found for key") - } - } - /// Retrieves a mutable value for the given key. /// See [`find_mut`](../trait.MutableMap.html#tymethod.find_mut) for a non-failing alternative. /// @@ -1274,12 +1008,6 @@ impl, V, S, H: Hasher> HashMap { Entries { inner: self.table.iter() } } - /// Deprecated: use `iter_mut`. - #[deprecated = "use iter_mut"] - pub fn mut_iter(&mut self) -> MutEntries { - self.iter_mut() - } - /// An iterator visiting all key-value pairs in arbitrary order, /// with mutable references to the values. /// Iterator element type is `(&'a K, &'a mut V)`. @@ -1307,12 +1035,6 @@ impl, V, S, H: Hasher> HashMap { MutEntries { inner: self.table.iter_mut() } } - /// Deprecated: use `into_iter`. - #[deprecated = "use into_iter"] - pub fn move_iter(self) -> MoveEntries { - self.into_iter() - } - /// Creates a consuming iterator, that is, one that moves each key-value /// pair out of the map in arbitrary order. The map cannot be used after /// calling this. @@ -1468,9 +1190,8 @@ impl, V, S, H: Hasher + Default> Default for HashMap impl, V, S, H: Hasher> Index for HashMap { #[inline] - #[allow(deprecated)] fn index<'a>(&'a self, index: &K) -> &'a V { - self.get(index) + self.find(index).expect("no entry found for key") } } @@ -1929,29 +1650,6 @@ mod test_map { assert_eq!(*m.find(&1).unwrap(), 2); } - #[test] - #[allow(deprecated)] // insert_or_update_with - fn test_update_with() { - let mut m = HashMap::with_capacity(4); - assert!(m.insert(1i, 2i)); - - for i in range(1i, 1000) { - assert_eq!( - i + 2, - *m.insert_or_update_with(i + 1, i + 2, |_k, _v| { - fail!("Key not yet present"); - }) - ); - assert_eq!( - i + 1, - *m.insert_or_update_with(i, i + 3, |k, v| { - assert_eq!(*k, i); - assert_eq!(*v, i + 1); - }) - ); - } - } - #[test] fn test_conflict_remove() { let mut m = HashMap::with_capacity(4); diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index b8fb187548c65..53e60d553be5f 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -85,13 +85,6 @@ impl UdpSocket { } } - #[allow(missing_doc)] - #[deprecated = "renamed to `recv_from`"] - pub fn recvfrom(&mut self, buf: &mut [u8]) - -> IoResult<(uint, SocketAddr)> { - self.recv_from(buf) - } - /// Sends data on the socket to the given address. Returns nothing on /// success. pub fn send_to(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> { @@ -101,12 +94,6 @@ impl UdpSocket { }).map_err(IoError::from_rtio_error) } - #[allow(missing_doc)] - #[deprecated = "renamed to `send_to`"] - pub fn sendto(&mut self, buf: &[u8], dst: SocketAddr) -> IoResult<()> { - self.send_to(buf, dst) - } - /// Creates a `UdpStream`, which allows use of the `Reader` and `Writer` /// traits to receive and send data from the same address. This transfers /// ownership of the socket to the stream. @@ -176,12 +163,6 @@ impl UdpSocket { }.map_err(IoError::from_rtio_error) } - /// Sets the broadcast flag on or off - #[deprecated="renamed to `set_broadcast`"] - pub fn set_broadast(&mut self, broadcast: bool) -> IoResult<()> { - self.set_broadcast(broadcast) - } - /// Sets the read/write timeout for this socket. /// /// For more information, see `TcpStream::set_timeout` diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 82c8d8071b34b..c47cd02599485 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -134,7 +134,6 @@ extern crate rustrt; #[cfg(test)] pub use realstd::kinds; #[cfg(test)] pub use realstd::ops; #[cfg(test)] pub use realstd::cmp; -#[cfg(test)] pub use realstd::ty; #[cfg(test)] pub use realstd::boxed; @@ -159,13 +158,10 @@ pub use core::tuple; // FIXME #15320: primitive documentation needs top-level modules, this // should be `std::tuple::unit`. pub use core::unit; -#[cfg(not(test))] pub use core::ty; pub use core::result; pub use core::option; pub use alloc::boxed; -#[deprecated = "use boxed instead"] -pub use boxed as owned; pub use alloc::rc; diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index b2a9f1b7b20d3..92db94c5e9a5a 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -333,29 +333,6 @@ pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String { r } -impl num::ToStrRadix for f32 { - /// Converts a float to a string in a given radix - /// - /// # Arguments - /// - /// * num - The float value - /// * radix - The base to use - /// - /// # Failure - /// - /// Fails if called on a special value like `inf`, `-inf` or `NaN` due to - /// possible misinterpretation of the result at higher bases. If those values - /// are expected, use `to_str_radix_special()` instead. - #[inline] - fn to_str_radix(&self, rdx: uint) -> String { - let (r, special) = strconv::float_to_str_common( - *self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false); - if special { fail!("number has a special value, \ - try to_str_radix_special() if those are expected") } - r - } -} - /// Convert a string in base 16 to a float. /// Accepts an optional binary exponent. /// diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index 6fe9fcad2aad7..3635c3192db32 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -341,29 +341,6 @@ pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String { r } -impl num::ToStrRadix for f64 { - /// Converts a float to a string in a given radix - /// - /// # Arguments - /// - /// * num - The float value - /// * radix - The base to use - /// - /// # Failure - /// - /// Fails if called on a special value like `inf`, `-inf` or `NAN` due to - /// possible misinterpretation of the result at higher bases. If those values - /// are expected, use `to_str_radix_special()` instead. - #[inline] - fn to_str_radix(&self, rdx: uint) -> String { - let (r, special) = strconv::float_to_str_common( - *self, rdx, true, strconv::SignNeg, strconv::DigAll, strconv::ExpNone, false); - if special { fail!("number has a special value, \ - try to_str_radix_special() if those are expected") } - r - } -} - /// Convert a string in base 16 to a float. /// Accepts an optional binary exponent. /// diff --git a/src/libstd/num/i16.rs b/src/libstd/num/i16.rs index 9e4cc06f0a200..d7732b474dba8 100644 --- a/src/libstd/num/i16.rs +++ b/src/libstd/num/i16.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i16")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i16::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/i32.rs b/src/libstd/num/i32.rs index 54259fcad55cb..778f1c6748c26 100644 --- a/src/libstd/num/i32.rs +++ b/src/libstd/num/i32.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i32")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i32::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/i64.rs b/src/libstd/num/i64.rs index b5fe6825ca4b4..ae3d57eeac65d 100644 --- a/src/libstd/num/i64.rs +++ b/src/libstd/num/i64.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i64")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i64::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/i8.rs b/src/libstd/num/i8.rs index 7aa9a41e34038..8a3f379893c24 100644 --- a/src/libstd/num/i8.rs +++ b/src/libstd/num/i8.rs @@ -14,10 +14,9 @@ #![doc(primitive = "i8")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::i8::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/int.rs b/src/libstd/num/int.rs index 74ee61634c695..51af04b32d4fb 100644 --- a/src/libstd/num/int.rs +++ b/src/libstd/num/int.rs @@ -14,10 +14,9 @@ #![doc(primitive = "int")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::int::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/int_macros.rs b/src/libstd/num/int_macros.rs index 62e609bb2e18b..ca45b40e687a1 100644 --- a/src/libstd/num/int_macros.rs +++ b/src/libstd/num/int_macros.rs @@ -51,52 +51,12 @@ impl FromStrRadix for $T { } } -// String conversion functions and impl num -> str - -/// Convert to a string as a byte slice in a given base. -/// -/// Use in place of x.to_string() when you do not need to store the string permanently -/// -/// # Examples -/// -/// ``` -/// #![allow(deprecated)] -/// -/// std::int::to_str_bytes(123, 10, |v| { -/// assert!(v == "123".as_bytes()); -/// }); -/// ``` -#[inline] -#[deprecated = "just use .to_string(), or a BufWriter with write! if you mustn't allocate"] -pub fn to_str_bytes(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U { - use io::{Writer, Seek}; - // The radix can be as low as 2, so we need at least 64 characters for a - // base 2 number, and then we need another for a possible '-' character. - let mut buf = [0u8, ..65]; - let amt = { - let mut wr = ::io::BufWriter::new(buf); - (write!(&mut wr, "{}", ::fmt::radix(n, radix as u8))).unwrap(); - wr.tell().unwrap() as uint - }; - f(buf[..amt]) -} - -#[deprecated = "use fmt::radix"] -impl ToStrRadix for $T { - /// Convert to a string in a given base. - #[inline] - fn to_str_radix(&self, radix: uint) -> String { - format!("{}", ::fmt::radix(*self, radix as u8)) - } -} - #[cfg(test)] mod tests { use prelude::*; use super::*; use i32; - use num::ToStrRadix; use str::StrSlice; #[test] @@ -142,16 +102,6 @@ mod tests { assert!(parse_bytes("-9".as_bytes(), 2u).is_none()); } - #[test] - fn test_to_string() { - assert_eq!((0 as $T).to_str_radix(10u), "0".to_string()); - assert_eq!((1 as $T).to_str_radix(10u), "1".to_string()); - assert_eq!((-1 as $T).to_str_radix(10u), "-1".to_string()); - assert_eq!((127 as $T).to_str_radix(16u), "7f".to_string()); - assert_eq!((100 as $T).to_str_radix(10u), "100".to_string()); - - } - #[test] fn test_int_to_str_overflow() { let mut i8_val: i8 = 127_i8; diff --git a/src/libstd/num/mod.rs b/src/libstd/num/mod.rs index 27ee1e3ce3bb3..564b6a25f7faf 100644 --- a/src/libstd/num/mod.rs +++ b/src/libstd/num/mod.rs @@ -17,7 +17,6 @@ #![allow(missing_doc)] use option::Option; -use string::String; #[cfg(test)] use fmt::Show; @@ -111,12 +110,6 @@ pub trait FloatMath: Float { fn atanh(self) -> Self; } -/// A generic trait for converting a value to a string with a radix (base) -#[deprecated = "use fmt::radix"] -pub trait ToStrRadix { - fn to_str_radix(&self, radix: uint) -> String; -} - /// A generic trait for converting a string with a radix (base) to a value #[experimental = "might need to return Result"] pub trait FromStrRadix { diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 48ee7664c16ac..af66e6ca93490 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -20,7 +20,7 @@ use num::{Float, FPNaN, FPInfinite, ToPrimitive}; use num; use ops::{Add, Sub, Mul, Div, Rem, Neg}; use option::{None, Option, Some}; -use slice::{ImmutableSlice, MutableSlice}; +use slice::{ImmutableSlice, MutableSlice, CloneableVector}; use std::cmp::{PartialOrd, PartialEq}; use str::StrSlice; use string::String; @@ -168,8 +168,7 @@ static NAN_BUF: [u8, ..3] = [b'N', b'a', b'N']; * # Failure * - Fails if `radix` < 2 or `radix` > 36. */ -#[deprecated = "format!() and friends should be favored instead"] -pub fn int_to_str_bytes_common(num: T, radix: uint, sign: SignFormat, f: |u8|) { +fn int_to_str_bytes_common(num: T, radix: uint, sign: SignFormat, f: |u8|) { assert!(2 <= radix && radix <= 36); let _0: T = Zero::zero(); @@ -257,7 +256,6 @@ pub fn int_to_str_bytes_common(num: T, radix: uint, sign: SignFormat, f: * - Fails if `radix` > 25 and `exp_format` is `ExpBin` due to conflict * between digit and exponent sign `'p'`. */ -#[allow(deprecated)] pub fn float_to_str_bytes_common+Neg+Rem+Mul>( num: T, radix: uint, negative_zero: bool, @@ -278,17 +276,17 @@ pub fn float_to_str_bytes_common { return (Vec::from_slice("NaN".as_bytes()), true); } + FPNaN => { return (b"NaN".to_vec(), true); } FPInfinite if num > _0 => { return match sign { - SignAll => (Vec::from_slice("+inf".as_bytes()), true), - _ => (Vec::from_slice("inf".as_bytes()), true) + SignAll => (b"+inf".to_vec(), true), + _ => (b"inf".to_vec(), true) }; } FPInfinite if num < _0 => { return match sign { - SignNone => (Vec::from_slice("inf".as_bytes()), true), - _ => (Vec::from_slice("-inf".as_bytes()), true), + SignNone => (b"inf".to_vec(), true), + _ => (b"-inf".to_vec(), true), }; } _ => {} @@ -413,18 +411,18 @@ pub fn float_to_str_bytes_common start_fractional_digits && *buf.get(i) == b'0' { + while i > start_fractional_digits && buf[i] == b'0' { i -= 1; } // Only attempt to truncate digits if buf has fractional digits if i >= start_fractional_digits { // If buf ends with '.', cut that too. - if *buf.get(i) == b'.' { i -= 1 } + if buf[i] == b'.' { i -= 1 } // only resize buf if we actually remove digits if i < buf_max_i { - buf = Vec::from_slice(buf.slice(0, i + 1)); + buf = buf.slice(0, i + 1).to_vec(); } } } // If exact and trailing '.', just cut that else { let max_i = buf.len() - 1; - if *buf.get(max_i) == b'.' { - buf = Vec::from_slice(buf.slice(0, max_i)); + if buf[max_i] == b'.' { + buf = buf.slice(0, max_i).to_vec(); } } diff --git a/src/libstd/num/u16.rs b/src/libstd/num/u16.rs index c141ecc9cba4e..bb619b5b2f595 100644 --- a/src/libstd/num/u16.rs +++ b/src/libstd/num/u16.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u16")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u16::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/u32.rs b/src/libstd/num/u32.rs index 8a8e2729a5325..754103ba5dab2 100644 --- a/src/libstd/num/u32.rs +++ b/src/libstd/num/u32.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u32")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u32::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/u64.rs b/src/libstd/num/u64.rs index 1b4f8bc433f15..da497d2cbe470 100644 --- a/src/libstd/num/u64.rs +++ b/src/libstd/num/u64.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u64")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u64::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/u8.rs b/src/libstd/num/u8.rs index 28f2242923560..bdfcdb2c5a5bc 100644 --- a/src/libstd/num/u8.rs +++ b/src/libstd/num/u8.rs @@ -14,10 +14,9 @@ #![doc(primitive = "u8")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::u8::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/uint.rs b/src/libstd/num/uint.rs index da32807445392..5090219d3de65 100644 --- a/src/libstd/num/uint.rs +++ b/src/libstd/num/uint.rs @@ -14,10 +14,9 @@ #![doc(primitive = "uint")] use from_str::FromStr; -use num::{ToStrRadix, FromStrRadix}; +use num::FromStrRadix; use num::strconv; use option::Option; -use string::String; pub use core::uint::{BITS, BYTES, MIN, MAX}; diff --git a/src/libstd/num/uint_macros.rs b/src/libstd/num/uint_macros.rs index a033308af1616..f9bc9eb539a13 100644 --- a/src/libstd/num/uint_macros.rs +++ b/src/libstd/num/uint_macros.rs @@ -82,35 +82,14 @@ pub fn to_str_bytes(n: $T, radix: uint, f: |v: &[u8]| -> U) -> U { f(buf[..amt]) } -#[deprecated = "use fmt::radix"] -impl ToStrRadix for $T { - /// Convert to a string in a given base. - #[inline] - fn to_str_radix(&self, radix: uint) -> String { - format!("{}", ::fmt::radix(*self, radix as u8)) - } -} - #[cfg(test)] mod tests { use prelude::*; use super::*; - use num::ToStrRadix; use str::StrSlice; use u16; - #[test] - pub fn test_to_string() { - assert_eq!((0 as $T).to_str_radix(10u), "0".to_string()); - assert_eq!((1 as $T).to_str_radix(10u), "1".to_string()); - assert_eq!((2 as $T).to_str_radix(10u), "2".to_string()); - assert_eq!((11 as $T).to_str_radix(10u), "11".to_string()); - assert_eq!((11 as $T).to_str_radix(16u), "b".to_string()); - assert_eq!((255 as $T).to_str_radix(16u), "ff".to_string()); - assert_eq!((0xff as $T).to_str_radix(10u), "255".to_string()); - } - #[test] pub fn test_from_str() { assert_eq!(from_str::<$T>("0"), Some(0u as $T)); @@ -199,18 +178,6 @@ mod tests { assert_eq!(from_str::("0"), Some(u64_val)); assert!(from_str::("-1").is_none()); } - - #[test] - #[should_fail] - pub fn to_str_radix1() { - 100u.to_str_radix(1u); - } - - #[test] - #[should_fail] - pub fn to_str_radix37() { - 100u.to_str_radix(37u); - } } )) diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 8cfa1ebd59847..38e1e952f77e2 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -26,9 +26,6 @@ pub use core_sync::{RWLock, RWLockReadGuard, RWLockWriteGuard}; pub use core_sync::{Semaphore, SemaphoreGuard}; pub use core_sync::one::{Once, ONCE_INIT}; -#[deprecated = "use atomic instead"] -pub use core_sync::atomic as atomics; - pub use self::future::Future; pub use self::task_pool::TaskPool; diff --git a/src/libstd/task.rs b/src/libstd/task.rs index 04d3bb8b3a7ea..1d1e6ae4febfd 100644 --- a/src/libstd/task.rs +++ b/src/libstd/task.rs @@ -225,26 +225,6 @@ impl TaskBuilder { } } - /// Add a wrapper to the body of the spawned task. - /// - /// Before the task is spawned it is passed through a 'body generator' - /// function that may perform local setup operations as well as wrap - /// the task body in remote setup operations. With this the behavior - /// of tasks can be extended in simple ways. - /// - /// This function augments the current body generator with a new body - /// generator by applying the task body which results from the - /// existing body generator to the new body generator. - #[deprecated = "this function will be removed soon"] - pub fn with_wrapper(mut self, wrapper: proc(v: proc():Send):Send -> proc():Send) - -> TaskBuilder { - self.gen_body = match self.gen_body.take() { - Some(prev) => Some(proc(body) { wrapper(prev(body)) }), - None => Some(wrapper) - }; - self - } - // Where spawning actually happens (whether yielding a future or not) fn spawn_internal(self, f: proc():Send, on_exit: Option>):Send>) { @@ -353,18 +333,6 @@ pub fn try_future(f: proc():Send -> T) -> Future(blk: |Option<&str>| -> U) -> U { - use rt::task::Task; - - let task = Local::borrow(None::); - match task.name { - Some(ref name) => blk(Some(name.as_slice())), - None => blk(None) - } -} - /// Read the name of the current task. #[stable] pub fn name() -> Option { @@ -446,20 +414,6 @@ mod test { rx.recv(); } - #[test] - #[allow(deprecated)] - fn test_with_wrapper() { - let (tx, rx) = channel(); - TaskBuilder::new().with_wrapper(proc(body) { - let result: proc():Send = proc() { - body(); - tx.send(()); - }; - result - }).spawn(proc() { }); - rx.recv(); - } - #[test] fn test_try_future() { let result = TaskBuilder::new().try_future(proc() {}); diff --git a/src/libsync/comm/duplex.rs b/src/libsync/comm/duplex.rs deleted file mode 100644 index 1dc1f4b87f27c..0000000000000 --- a/src/libsync/comm/duplex.rs +++ /dev/null @@ -1,78 +0,0 @@ -// Copyright 2012-2013 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -/*! - -Higher level communication abstractions. - -*/ - -#![allow(missing_doc)] -#![allow(deprecated)] -#![deprecated = "This type is replaced by having a pair of channels. This type \ - is not fully composable with other channels in terms of \ - or possible semantics on a duplex stream. It will be removed \ - soon"] - -use core::prelude::*; - -use comm; -use comm::{Sender, Receiver, channel}; - -/// An extension of `pipes::stream` that allows both sending and receiving. -pub struct DuplexStream { - tx: Sender, - rx: Receiver, -} - -/// Creates a bidirectional stream. -pub fn duplex() -> (DuplexStream, DuplexStream) { - let (tx1, rx1) = channel(); - let (tx2, rx2) = channel(); - (DuplexStream { tx: tx1, rx: rx2 }, - DuplexStream { tx: tx2, rx: rx1 }) -} - -// Allow these methods to be used without import: -impl DuplexStream { - pub fn send(&self, x: S) { - self.tx.send(x) - } - pub fn send_opt(&self, x: S) -> Result<(), S> { - self.tx.send_opt(x) - } - pub fn recv(&self) -> R { - self.rx.recv() - } - pub fn try_recv(&self) -> Result { - self.rx.try_recv() - } - pub fn recv_opt(&self) -> Result { - self.rx.recv_opt() - } -} - -#[allow(deprecated)] -#[cfg(test)] -mod test { - use std::prelude::*; - use comm::duplex; - - #[test] - pub fn duplex_stream_1() { - let (left, right) = duplex(); - - left.send("abc".to_string()); - right.send(123i); - - assert!(left.recv() == 123); - assert!(right.recv() == "abc".to_string()); - } -} diff --git a/src/libsync/comm/mod.rs b/src/libsync/comm/mod.rs index 4e66dd69a607b..ddfd1088a41a8 100644 --- a/src/libsync/comm/mod.rs +++ b/src/libsync/comm/mod.rs @@ -333,7 +333,6 @@ use rustrt::local::Local; use rustrt::task::{Task, BlockedTask}; pub use comm::select::{Select, Handle}; -pub use comm::duplex::{DuplexStream, duplex}; macro_rules! test ( { fn $name:ident() $b:block $(#[$a:meta])*} => ( @@ -354,14 +353,13 @@ macro_rules! test ( $(#[$a])* #[test] fn native() { use native; let (tx, rx) = channel(); - native::task::spawn(proc() { tx.send(f()) }); + spawn(proc() { tx.send(f()) }); rx.recv(); } } ) ) -mod duplex; mod oneshot; mod select; mod shared; @@ -1064,7 +1062,6 @@ impl Drop for Receiver { mod test { use std::prelude::*; - use native; use std::os; use super::*; @@ -1224,7 +1221,7 @@ mod test { tx3.send(()); }); rx1.recv(); - native::task::spawn(proc() { + spawn(proc() { for _ in range(0i, 40) { tx2.send(1); } @@ -1238,7 +1235,7 @@ mod test { fn recv_from_outside_runtime() { let (tx, rx) = channel::(); let (dtx, drx) = channel(); - native::task::spawn(proc() { + spawn(proc() { for _ in range(0i, 40) { assert_eq!(rx.recv(), 1); } @@ -1256,12 +1253,12 @@ mod test { let (tx2, rx2) = channel::(); let (tx3, rx3) = channel::<()>(); let tx4 = tx3.clone(); - native::task::spawn(proc() { + spawn(proc() { assert_eq!(rx1.recv(), 1); tx2.send(2); tx4.send(()); }); - native::task::spawn(proc() { + spawn(proc() { tx1.send(1); assert_eq!(rx2.recv(), 2); tx3.send(()); diff --git a/src/libsync/mpmc_bounded_queue.rs b/src/libsync/mpmc_bounded_queue.rs index fa29bb6088ae1..b3b504f49ca3a 100644 --- a/src/libsync/mpmc_bounded_queue.rs +++ b/src/libsync/mpmc_bounded_queue.rs @@ -167,7 +167,6 @@ impl Clone for Queue { mod tests { use std::prelude::*; use super::Queue; - use native; #[test] fn test() { @@ -180,7 +179,7 @@ mod tests { for _ in range(0, nthreads) { let q = q.clone(); let tx = tx.clone(); - native::task::spawn(proc() { + spawn(proc() { let q = q; for i in range(0, nmsgs) { assert!(q.push(i)); @@ -194,7 +193,7 @@ mod tests { let (tx, rx) = channel(); completion_rxs.push(rx); let q = q.clone(); - native::task::spawn(proc() { + spawn(proc() { let q = q; let mut i = 0u; loop { diff --git a/src/libsync/mpsc_queue.rs b/src/libsync/mpsc_queue.rs index ad2539fc26008..ac2acf3d7d4d2 100644 --- a/src/libsync/mpsc_queue.rs +++ b/src/libsync/mpsc_queue.rs @@ -161,7 +161,6 @@ mod tests { use alloc::arc::Arc; - use native; use super::{Queue, Data, Empty, Inconsistent}; #[test] @@ -186,7 +185,7 @@ mod tests { for _ in range(0, nthreads) { let tx = tx.clone(); let q = q.clone(); - native::task::spawn(proc() { + spawn(proc() { for i in range(0, nmsgs) { q.push(i); } diff --git a/src/libsync/mutex.rs b/src/libsync/mutex.rs index 796c62354c311..7d191eab2d157 100644 --- a/src/libsync/mutex.rs +++ b/src/libsync/mutex.rs @@ -525,7 +525,6 @@ impl Drop for Mutex { mod test { use std::prelude::*; use super::{Mutex, StaticMutex, MUTEX_INIT}; - use native; #[test] fn smoke() { @@ -563,7 +562,7 @@ mod test { let (tx, rx) = channel(); for _ in range(0, K) { let tx2 = tx.clone(); - native::task::spawn(proc() { inc(); tx2.send(()); }); + spawn(proc() { inc(); tx2.send(()); }); let tx2 = tx.clone(); spawn(proc() { inc(); tx2.send(()); }); } diff --git a/src/libsync/spsc_queue.rs b/src/libsync/spsc_queue.rs index cb4d33049d84f..9cd64d46bad85 100644 --- a/src/libsync/spsc_queue.rs +++ b/src/libsync/spsc_queue.rs @@ -296,8 +296,6 @@ impl Drop for Queue { mod test { use std::prelude::*; - use native; - use super::{queue}; #[test] @@ -364,7 +362,7 @@ mod test { let (consumer, mut producer) = queue(bound); let (tx, rx) = channel(); - native::task::spawn(proc() { + spawn(proc() { // Move the consumer to a local mutable slot let mut consumer = consumer; for _ in range(0u, 100000) { diff --git a/src/libsyntax/ast_map/mod.rs b/src/libsyntax/ast_map/mod.rs index fb5373cee0040..60e4db405d766 100644 --- a/src/libsyntax/ast_map/mod.rs +++ b/src/libsyntax/ast_map/mod.rs @@ -699,8 +699,12 @@ struct NodeCollector<'ast> { impl<'ast> NodeCollector<'ast> { fn insert_entry(&mut self, id: NodeId, entry: MapEntry<'ast>) { - self.map.grow_set(id as uint, &NotPresent, entry); debug!("ast_map: {} => {}", id, entry); + let len = self.map.len(); + if id as uint >= len { + self.map.grow(id as uint - len + 1, NotPresent); + } + *self.map.get_mut(id as uint) = entry; } fn insert(&mut self, id: NodeId, node: Node<'ast>) { diff --git a/src/libsyntax/ast_util.rs b/src/libsyntax/ast_util.rs index 726aceb5819b6..5626f0a8ad962 100644 --- a/src/libsyntax/ast_util.rs +++ b/src/libsyntax/ast_util.rs @@ -202,7 +202,7 @@ pub fn impl_pretty_name(trait_ref: &Option, ty: &Ty) -> Ident { let mut pretty = pprust::ty_to_string(ty); match *trait_ref { Some(ref trait_ref) => { - pretty.push_char('.'); + pretty.push('.'); pretty.push_str(pprust::path_to_string(&trait_ref.path).as_slice()); } None => {} diff --git a/src/libsyntax/codemap.rs b/src/libsyntax/codemap.rs index 5d96cc359c2ff..4df334a3f2c70 100644 --- a/src/libsyntax/codemap.rs +++ b/src/libsyntax/codemap.rs @@ -283,9 +283,9 @@ impl FileMap { /// filemap.start_pos + newline_offset_relative_to_the_start_of_filemap. pub fn next_line(&self, pos: BytePos) { // the new charpos must be > the last one (or it's the first one). - let mut lines = self.lines.borrow_mut();; + let mut lines = self.lines.borrow_mut(); let line_len = lines.len(); - assert!(line_len == 0 || (*lines.get(line_len - 1) < pos)) + assert!(line_len == 0 || ((*lines)[line_len - 1] < pos)) lines.push(pos); } @@ -293,7 +293,7 @@ impl FileMap { /// pub fn get_line(&self, line: int) -> String { let lines = self.lines.borrow(); - let begin: BytePos = *lines.get(line as uint) - self.start_pos; + let begin: BytePos = (*lines)[line as uint] - self.start_pos; let begin = begin.to_uint(); let slice = self.src.as_slice().slice_from(begin); match slice.find('\n') { @@ -351,7 +351,7 @@ impl CodeMap { // overflowing into the next filemap in case the last byte of span is also the last // byte of filemap, which leads to incorrect results from CodeMap.span_to_*. if src.len() > 0 && !src.as_slice().ends_with("\n") { - src.push_char('\n'); + src.push('\n'); } let filemap = Rc::new(FileMap { @@ -446,7 +446,7 @@ impl CodeMap { pub fn lookup_byte_offset(&self, bpos: BytePos) -> FileMapAndBytePos { let idx = self.lookup_filemap_idx(bpos); - let fm = self.files.borrow().get(idx).clone(); + let fm = (*self.files.borrow())[idx].clone(); let offset = bpos - fm.start_pos; FileMapAndBytePos {fm: fm, pos: offset} } @@ -455,7 +455,7 @@ impl CodeMap { pub fn bytepos_to_file_charpos(&self, bpos: BytePos) -> CharPos { let idx = self.lookup_filemap_idx(bpos); let files = self.files.borrow(); - let map = files.get(idx); + let map = &(*files)[idx]; // The number of extra bytes due to multibyte chars in the FileMap let mut total_extra_bytes = 0; @@ -480,34 +480,37 @@ impl CodeMap { fn lookup_filemap_idx(&self, pos: BytePos) -> uint { let files = self.files.borrow(); - let files = files; + let files = &*files; let len = files.len(); let mut a = 0u; let mut b = len; while b - a > 1u { let m = (a + b) / 2u; - if files.get(m).start_pos > pos { + if files[m].start_pos > pos { b = m; } else { a = m; } } - // There can be filemaps with length 0. These have the same start_pos as the previous - // filemap, but are not the filemaps we want (because they are length 0, they cannot - // contain what we are looking for). So, rewind until we find a useful filemap. + // There can be filemaps with length 0. These have the same start_pos as + // the previous filemap, but are not the filemaps we want (because they + // are length 0, they cannot contain what we are looking for). So, + // rewind until we find a useful filemap. loop { - let lines = files.get(a).lines.borrow(); + let lines = files[a].lines.borrow(); let lines = lines; if lines.len() > 0 { break; } if a == 0 { - fail!("position {} does not resolve to a source location", pos.to_uint()); + fail!("position {} does not resolve to a source location", + pos.to_uint()); } a -= 1; } if a >= len { - fail!("position {} does not resolve to a source location", pos.to_uint()) + fail!("position {} does not resolve to a source location", + pos.to_uint()) } return a; @@ -517,14 +520,14 @@ impl CodeMap { let idx = self.lookup_filemap_idx(pos); let files = self.files.borrow(); - let f = files.get(idx).clone(); + let f = (*files)[idx].clone(); let mut a = 0u; { let lines = f.lines.borrow(); let mut b = lines.len(); while b - a > 1u { let m = (a + b) / 2u; - if *lines.get(m) > pos { b = m; } else { a = m; } + if (*lines)[m] > pos { b = m; } else { a = m; } } } FileMapAndLine {fm: f, line: a} @@ -534,7 +537,7 @@ impl CodeMap { let FileMapAndLine {fm: f, line: a} = self.lookup_line(pos); let line = a + 1u; // Line numbers start at 1 let chpos = self.bytepos_to_file_charpos(pos); - let linebpos = *f.lines.borrow().get(a); + let linebpos = (*f.lines.borrow())[a]; let linechpos = self.bytepos_to_file_charpos(linebpos); debug!("byte pos {} is on the line at byte pos {}", pos, linebpos); @@ -704,7 +707,7 @@ mod test { assert_eq!(file_lines.file.name, "blork.rs".to_string()); assert_eq!(file_lines.lines.len(), 1); - assert_eq!(*file_lines.lines.get(0), 1u); + assert_eq!(file_lines.lines[0], 1u); } #[test] diff --git a/src/libsyntax/crateid.rs b/src/libsyntax/crateid.rs deleted file mode 100644 index 67605360a48cb..0000000000000 --- a/src/libsyntax/crateid.rs +++ /dev/null @@ -1,216 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -use std::fmt; - -/// CrateIds identify crates and include the crate name and optionally a path -/// and version. In the full form, they look like relative URLs. Example: -/// `github.com/rust-lang/rust#std:1.0` would be a package ID with a path of -/// `github.com/rust-lang/rust` and a crate name of `std` with a version of -/// `1.0`. If no crate name is given after the hash, the name is inferred to -/// be the last component of the path. If no version is given, it is inferred -/// to be `0.0`. - -use std::from_str::FromStr; - -#[deriving(Clone, PartialEq)] -pub struct CrateId { - /// A path which represents the codes origin. By convention this is the - /// URL, without `http://` or `https://` prefix, to the crate's repository - pub path: String, - /// The name of the crate. - pub name: String, - /// The version of the crate. - pub version: Option, -} - -impl fmt::Show for CrateId { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - try!(write!(f, "{}", self.path)); - let version = match self.version { - None => "0.0", - Some(ref version) => version.as_slice(), - }; - if self.path == self.name || - self.path - .as_slice() - .ends_with(format!("/{}", self.name).as_slice()) { - write!(f, "#{}", version) - } else { - write!(f, "#{}:{}", self.name, version) - } - } -} - -impl FromStr for CrateId { - fn from_str(s: &str) -> Option { - let pieces: Vec<&str> = s.splitn(1, '#').collect(); - let path = pieces.get(0).to_string(); - - if path.as_slice().starts_with("/") || path.as_slice().ends_with("/") || - path.as_slice().starts_with(".") || path.is_empty() { - return None; - } - - let path_pieces: Vec<&str> = path.as_slice() - .rsplitn(1, '/') - .collect(); - let inferred_name = *path_pieces.get(0); - - let (name, version) = if pieces.len() == 1 { - (inferred_name.to_string(), None) - } else { - let hash_pieces: Vec<&str> = pieces.get(1) - .splitn(1, ':') - .collect(); - let (hash_name, hash_version) = if hash_pieces.len() == 1 { - ("", *hash_pieces.get(0)) - } else { - (*hash_pieces.get(0), *hash_pieces.get(1)) - }; - - let name = if !hash_name.is_empty() { - hash_name.to_string() - } else { - inferred_name.to_string() - }; - - let version = if !hash_version.is_empty() { - if hash_version == "0.0" { - None - } else { - Some(hash_version.to_string()) - } - } else { - None - }; - - (name, version) - }; - - Some(CrateId { - path: path.to_string(), - name: name, - version: version, - }) - } -} - -impl CrateId { - pub fn version_or_default<'a>(&'a self) -> &'a str { - match self.version { - None => "0.0", - Some(ref version) => version.as_slice(), - } - } - - pub fn short_name_with_version(&self) -> String { - format!("{}-{}", self.name, self.version_or_default()) - } - - pub fn matches(&self, other: &CrateId) -> bool { - // FIXME: why does this not match on `path`? - if self.name != other.name { return false } - match (&self.version, &other.version) { - (&Some(ref v1), &Some(ref v2)) => v1 == v2, - _ => true, - } - } -} - -#[test] -fn bare_name() { - let crateid: CrateId = from_str("foo").expect("valid crateid"); - assert_eq!(crateid.name, "foo".to_string()); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, "foo".to_string()); -} - -#[test] -fn bare_name_single_char() { - let crateid: CrateId = from_str("f").expect("valid crateid"); - assert_eq!(crateid.name, "f".to_string()); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, "f".to_string()); -} - -#[test] -fn empty_crateid() { - let crateid: Option = from_str(""); - assert!(crateid.is_none()); -} - -#[test] -fn simple_path() { - let crateid: CrateId = from_str("example.com/foo/bar").expect("valid crateid"); - assert_eq!(crateid.name, "bar".to_string()); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, "example.com/foo/bar".to_string()); -} - -#[test] -fn simple_version() { - let crateid: CrateId = from_str("foo#1.0").expect("valid crateid"); - assert_eq!(crateid.name, "foo".to_string()); - assert_eq!(crateid.version, Some("1.0".to_string())); - assert_eq!(crateid.path, "foo".to_string()); -} - -#[test] -fn absolute_path() { - let crateid: Option = from_str("/foo/bar"); - assert!(crateid.is_none()); -} - -#[test] -fn path_ends_with_slash() { - let crateid: Option = from_str("foo/bar/"); - assert!(crateid.is_none()); -} - -#[test] -fn path_and_version() { - let crateid: CrateId = from_str("example.com/foo/bar#1.0").expect("valid crateid"); - assert_eq!(crateid.name, "bar".to_string()); - assert_eq!(crateid.version, Some("1.0".to_string())); - assert_eq!(crateid.path, "example.com/foo/bar".to_string()); -} - -#[test] -fn single_chars() { - let crateid: CrateId = from_str("a/b#1").expect("valid crateid"); - assert_eq!(crateid.name, "b".to_string()); - assert_eq!(crateid.version, Some("1".to_string())); - assert_eq!(crateid.path, "a/b".to_string()); -} - -#[test] -fn missing_version() { - let crateid: CrateId = from_str("foo#").expect("valid crateid"); - assert_eq!(crateid.name, "foo".to_string()); - assert_eq!(crateid.version, None); - assert_eq!(crateid.path, "foo".to_string()); -} - -#[test] -fn path_and_name() { - let crateid: CrateId = from_str("foo/rust-bar#bar:1.0").expect("valid crateid"); - assert_eq!(crateid.name, "bar".to_string()); - assert_eq!(crateid.version, Some("1.0".to_string())); - assert_eq!(crateid.path, "foo/rust-bar".to_string()); -} - -#[test] -fn empty_name() { - let crateid: CrateId = from_str("foo/bar#:1.0").expect("valid crateid"); - assert_eq!(crateid.name, "bar".to_string()); - assert_eq!(crateid.version, Some("1.0".to_string())); - assert_eq!(crateid.path, "foo/bar".to_string()); -} diff --git a/src/libsyntax/diagnostic.rs b/src/libsyntax/diagnostic.rs index 6d063aef5a990..d23849a6a1281 100644 --- a/src/libsyntax/diagnostic.rs +++ b/src/libsyntax/diagnostic.rs @@ -433,7 +433,7 @@ fn highlight_lines(err: &mut EmitterWriter, if lines.lines.len() == 1u { let lo = cm.lookup_char_pos(sp.lo); let mut digits = 0u; - let mut num = (*lines.lines.get(0) + 1u) / 10u; + let mut num = (lines.lines[0] + 1u) / 10u; // how many digits must be indent past? while num > 0u { num /= 10u; digits += 1u; } @@ -445,9 +445,9 @@ fn highlight_lines(err: &mut EmitterWriter, // part of the 'filename:line ' part of the previous line. let skip = fm.name.len() + digits + 3u; for _ in range(0, skip) { - s.push_char(' '); + s.push(' '); } - let orig = fm.get_line(*lines.lines.get(0) as int); + let orig = fm.get_line(lines.lines[0] as int); for pos in range(0u, left-skip) { let cur_char = orig.as_bytes()[pos] as char; // Whenever a tab occurs on the previous line, we insert one on @@ -455,8 +455,8 @@ fn highlight_lines(err: &mut EmitterWriter, // That way the squiggly line will usually appear in the correct // position. match cur_char { - '\t' => s.push_char('\t'), - _ => s.push_char(' '), + '\t' => s.push('\t'), + _ => s.push(' '), }; } try!(write!(&mut err.dst, "{}", s)); @@ -466,7 +466,7 @@ fn highlight_lines(err: &mut EmitterWriter, // the ^ already takes up one space let num_squigglies = hi.col.to_uint()-lo.col.to_uint()-1u; for _ in range(0, num_squigglies) { - s.push_char('~'); + s.push('~'); } } try!(print_maybe_styled(err, @@ -510,10 +510,10 @@ fn custom_highlight_lines(w: &mut EmitterWriter, let skip = last_line_start.len() + hi.col.to_uint() - 1; let mut s = String::new(); for _ in range(0, skip) { - s.push_char(' '); + s.push(' '); } - s.push_char('^'); - s.push_char('\n'); + s.push('^'); + s.push('\n'); print_maybe_styled(w, s.as_slice(), term::attr::ForegroundColor(lvl.color())) diff --git a/src/libsyntax/ext/base.rs b/src/libsyntax/ext/base.rs index a137f6e78b8b6..b09fb19b48976 100644 --- a/src/libsyntax/ext/base.rs +++ b/src/libsyntax/ext/base.rs @@ -495,7 +495,7 @@ impl<'a> ExtCtxt<'a> { pub fn new_parser_from_tts(&self, tts: &[ast::TokenTree]) -> parser::Parser<'a> { - parse::tts_to_parser(self.parse_sess, Vec::from_slice(tts), self.cfg()) + parse::tts_to_parser(self.parse_sess, tts.to_vec(), self.cfg()) } pub fn codemap(&self) -> &'a CodeMap { &self.parse_sess.span_diagnostic.cm } diff --git a/src/libsyntax/ext/build.rs b/src/libsyntax/ext/build.rs index 98ac6fe6a6c80..437efbf96f858 100644 --- a/src/libsyntax/ext/build.rs +++ b/src/libsyntax/ext/build.rs @@ -618,7 +618,7 @@ impl<'a> AstBuilder for ExtCtxt<'a> { ident: ast::Ident, mut args: Vec> ) -> P { let id = Spanned { node: ident, span: span }; - args.unshift(expr); + args.insert(0, expr); self.expr(span, ast::ExprMethodCall(id, Vec::new(), args)) } fn expr_block(&self, b: P) -> P { diff --git a/src/libsyntax/ext/concat.rs b/src/libsyntax/ext/concat.rs index cd3e247a80697..af7cd4157ecbc 100644 --- a/src/libsyntax/ext/concat.rs +++ b/src/libsyntax/ext/concat.rs @@ -35,7 +35,7 @@ pub fn expand_syntax_ext(cx: &mut base::ExtCtxt, accumulator.push_str(s.get()); } ast::LitChar(c) => { - accumulator.push_char(c); + accumulator.push(c); } ast::LitInt(i, ast::UnsignedIntLit(_)) | ast::LitInt(i, ast::SignedIntLit(_, ast::Plus)) | diff --git a/src/libsyntax/ext/deriving/clone.rs b/src/libsyntax/ext/deriving/clone.rs index 64607ffd5d4c9..9748b53134577 100644 --- a/src/libsyntax/ext/deriving/clone.rs +++ b/src/libsyntax/ext/deriving/clone.rs @@ -80,7 +80,7 @@ fn cs_clone( } } - if all_fields.len() >= 1 && all_fields.get(0).name.is_none() { + if all_fields.len() >= 1 && all_fields[0].name.is_none() { // enum-like let subcalls = all_fields.iter().map(subcall).collect(); cx.expr_call_ident(trait_span, ctor_ident, subcalls) diff --git a/src/libsyntax/ext/deriving/generic/mod.rs b/src/libsyntax/ext/deriving/generic/mod.rs index 10c045b811ae3..2310a4460e268 100644 --- a/src/libsyntax/ext/deriving/generic/mod.rs +++ b/src/libsyntax/ext/deriving/generic/mod.rs @@ -447,10 +447,12 @@ impl<'a> TraitDef<'a> { attr::mark_used(&attr); let opt_trait_ref = Some(trait_ref); let ident = ast_util::impl_pretty_name(&opt_trait_ref, &*self_type); + let mut a = vec![attr]; + a.extend(self.attributes.iter().map(|a| a.clone())); cx.item( self.span, ident, - (vec!(attr)).append(self.attributes.as_slice()), + a, ast::ItemImpl(trait_generics, opt_trait_ref, self_type, @@ -943,8 +945,8 @@ impl<'a> MethodDef<'a> { // of them (using `field_index` tracked above). // That is the heart of the transposition. let others = self_pats_idents.iter().map(|fields| { - let &(_, _opt_ident, ref other_getter_expr) = - fields.get(field_index); + let (_, _opt_ident, ref other_getter_expr) = + fields[field_index]; // All Self args have same variant, so // opt_idents are the same. (Assert diff --git a/src/libsyntax/ext/deriving/show.rs b/src/libsyntax/ext/deriving/show.rs index 16ce264fe712d..322a84eaa2be0 100644 --- a/src/libsyntax/ext/deriving/show.rs +++ b/src/libsyntax/ext/deriving/show.rs @@ -80,7 +80,7 @@ fn show_substructure(cx: &mut ExtCtxt, span: Span, EnumMatching(_, _, ref fields) if fields.len() == 0 => {} Struct(ref fields) | EnumMatching(_, _, ref fields) => { - if fields.get(0).name.is_none() { + if fields[0].name.is_none() { // tuple struct/"normal" variant format_string.push_str("("); diff --git a/src/libsyntax/ext/expand.rs b/src/libsyntax/ext/expand.rs index c792d4b99eefb..39b710e0d5725 100644 --- a/src/libsyntax/ext/expand.rs +++ b/src/libsyntax/ext/expand.rs @@ -165,7 +165,7 @@ pub fn expand_expr(e: P, fld: &mut MacroExpander) -> P { let mut arms = Vec::with_capacity(else_if_arms.len() + 2); arms.push(pat_arm); - arms.push_all_move(else_if_arms); + arms.extend(else_if_arms.into_iter()); arms.push(else_arm); let match_expr = fld.cx.expr(span, ast::ExprMatch(expr, arms, ast::MatchIfLetDesugar)); @@ -257,7 +257,7 @@ fn expand_mac_invoc(mac: ast::Mac, span: codemap::Span, // let compilation continue return None; } - let extname = pth.segments.get(0).identifier; + let extname = pth.segments[0].identifier; let extnamestr = token::get_ident(extname); match fld.cx.syntax_env.find(&extname.name) { None => { @@ -505,7 +505,7 @@ pub fn expand_item_mac(it: P, fld: &mut MacroExpander) node: MacInvocTT(ref pth, ref tts, _), .. }) => { - (pth.segments.get(0).identifier, pth.span, (*tts).clone()) + (pth.segments[0].identifier, pth.span, (*tts).clone()) } _ => fld.cx.span_bug(it.span, "invalid item macro invocation") }; @@ -695,7 +695,8 @@ fn expand_non_macro_stmt(Spanned {node, span: stmt_span}: Stmt, fld: &mut MacroE rename_fld.fold_pat(expanded_pat) }; // add them to the existing pending renames: - fld.cx.syntax_env.info().pending_renames.push_all_move(new_pending_renames); + fld.cx.syntax_env.info().pending_renames + .extend(new_pending_renames.into_iter()); Local { id: id, ty: expanded_ty, @@ -744,7 +745,7 @@ fn expand_arm(arm: ast::Arm, fld: &mut MacroExpander) -> ast::Arm { } // all of the pats must have the same set of bindings, so use the // first one to extract them and generate new names: - let idents = pattern_bindings(&**expanded_pats.get(0)); + let idents = pattern_bindings(&*expanded_pats[0]); let new_renames = idents.into_iter().map(|id| (id, fresh_name(&id))).collect(); // apply the renaming, but only to the PatIdents: let mut rename_pats_fld = PatIdentRenamer{renames:&new_renames}; @@ -860,7 +861,7 @@ fn expand_pat(p: P, fld: &mut MacroExpander) -> P { fld.cx.span_err(pth.span, "expected macro name without module separators"); return DummyResult::raw_pat(span); } - let extname = pth.segments.get(0).identifier; + let extname = pth.segments[0].identifier; let extnamestr = token::get_ident(extname); let marked_after = match fld.cx.syntax_env.find(&extname.name) { None => { @@ -1022,7 +1023,7 @@ fn expand_method(m: P, fld: &mut MacroExpander) -> SmallVector *shouldmatch.iter().max().unwrap())); @@ -1630,16 +1631,15 @@ mod test { let string = token::get_ident(final_varref_ident); println!("varref's first segment's string: \"{}\"", string.get()); println!("binding #{}: {}, resolves to {}", - binding_idx, *bindings.get(binding_idx), binding_name); + binding_idx, bindings[binding_idx], binding_name); mtwt::with_sctable(|x| mtwt::display_sctable(x)); }; if shouldmatch.contains(&idx) { // it should be a path of length 1, and it should // be free-identifier=? or bound-identifier=? to the given binding assert_eq!(varref.segments.len(),1); - let varref_name = mtwt::resolve(varref.segments.get(0).identifier); - let varref_marks = mtwt::marksof(varref.segments - .get(0) + let varref_name = mtwt::resolve(varref.segments[0].identifier); + let varref_marks = mtwt::marksof(varref.segments[0] .identifier .ctxt, invalid_name); @@ -1654,7 +1654,7 @@ mod test { assert_eq!(varref_marks,binding_marks.clone()); } } else { - let varref_name = mtwt::resolve(varref.segments.get(0).identifier); + let varref_name = mtwt::resolve(varref.segments[0].identifier); let fail = (varref.segments.len() == 1) && (varref_name == binding_name); // temp debugging: @@ -1696,19 +1696,19 @@ foo_module!() // the xx binding should bind all of the xx varrefs: for (idx,v) in varrefs.iter().filter(|p| { p.segments.len() == 1 - && "xx" == token::get_ident(p.segments.get(0).identifier).get() + && "xx" == token::get_ident(p.segments[0].identifier).get() }).enumerate() { - if mtwt::resolve(v.segments.get(0).identifier) != resolved_binding { + if mtwt::resolve(v.segments[0].identifier) != resolved_binding { println!("uh oh, xx binding didn't match xx varref:"); println!("this is xx varref \\# {}", idx); println!("binding: {}", cxbind); println!("resolves to: {}", resolved_binding); - println!("varref: {}", v.segments.get(0).identifier); + println!("varref: {}", v.segments[0].identifier); println!("resolves to: {}", - mtwt::resolve(v.segments.get(0).identifier)); + mtwt::resolve(v.segments[0].identifier)); mtwt::with_sctable(|x| mtwt::display_sctable(x)); } - assert_eq!(mtwt::resolve(v.segments.get(0).identifier), + assert_eq!(mtwt::resolve(v.segments[0].identifier), resolved_binding); }; } diff --git a/src/libsyntax/ext/format.rs b/src/libsyntax/ext/format.rs index 07f0ca85f3560..87cd61c9b2237 100644 --- a/src/libsyntax/ext/format.rs +++ b/src/libsyntax/ext/format.rs @@ -241,13 +241,13 @@ impl<'a, 'b> Context<'a, 'b> { return; } { - let arg_type = match self.arg_types.get(arg) { - &None => None, - &Some(ref x) => Some(x) + let arg_type = match self.arg_types[arg] { + None => None, + Some(ref x) => Some(x) }; - self.verify_same(self.args.get(arg).span, &ty, arg_type); + self.verify_same(self.args[arg].span, &ty, arg_type); } - if self.arg_types.get(arg).is_none() { + if self.arg_types[arg].is_none() { *self.arg_types.get_mut(arg) = Some(ty); } } @@ -544,7 +544,7 @@ impl<'a, 'b> Context<'a, 'b> { // of each variable because we don't want to move out of the arguments // passed to this function. for (i, e) in self.args.into_iter().enumerate() { - let arg_ty = match self.arg_types.get(i).as_ref() { + let arg_ty = match self.arg_types[i].as_ref() { Some(ty) => ty, None => continue // error already generated }; @@ -568,7 +568,7 @@ impl<'a, 'b> Context<'a, 'b> { let lname = self.ecx.ident_of(format!("__arg{}", *name).as_slice()); pats.push(self.ecx.pat_ident(e.span, lname)); - *names.get_mut(*self.name_positions.get(name)) = + *names.get_mut(self.name_positions[*name]) = Some(Context::format_arg(self.ecx, e.span, arg_ty, self.ecx.expr_ident(e.span, lname))); heads.push(self.ecx.expr_addr_of(e.span, e)); @@ -787,7 +787,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, None => break } } - match parser.errors.shift() { + match parser.errors.remove(0) { Some(error) => { cx.ecx.span_err(cx.fmtsp, format!("invalid format string: {}", @@ -804,7 +804,7 @@ pub fn expand_preparsed_format_args(ecx: &mut ExtCtxt, sp: Span, // Make sure that all arguments were used and all arguments have types. for (i, ty) in cx.arg_types.iter().enumerate() { if ty.is_none() { - cx.ecx.span_err(cx.args.get(i).span, "argument never used"); + cx.ecx.span_err(cx.args[i].span, "argument never used"); } } for (name, e) in cx.names.iter() { diff --git a/src/libsyntax/ext/mtwt.rs b/src/libsyntax/ext/mtwt.rs index 523299abce141..b4f8b9f822849 100644 --- a/src/libsyntax/ext/mtwt.rs +++ b/src/libsyntax/ext/mtwt.rs @@ -188,7 +188,7 @@ fn resolve_internal(id: Ident, } let resolved = { - let result = *table.table.borrow().get(id.ctxt as uint); + let result = (*table.table.borrow())[id.ctxt as uint]; match result { EmptyCtxt => id.name, // ignore marks here: @@ -232,7 +232,7 @@ fn marksof_internal(ctxt: SyntaxContext, let mut result = Vec::new(); let mut loopvar = ctxt; loop { - let table_entry = *table.table.borrow().get(loopvar as uint); + let table_entry = (*table.table.borrow())[loopvar as uint]; match table_entry { EmptyCtxt => { return result; @@ -259,7 +259,7 @@ fn marksof_internal(ctxt: SyntaxContext, /// FAILS when outside is not a mark. pub fn outer_mark(ctxt: SyntaxContext) -> Mrk { with_sctable(|sctable| { - match *sctable.table.borrow().get(ctxt as uint) { + match (*sctable.table.borrow())[ctxt as uint] { Mark(mrk, _) => mrk, _ => fail!("can't retrieve outer mark when outside is not a mark") } @@ -330,7 +330,7 @@ mod tests { let mut result = Vec::new(); loop { let table = table.table.borrow(); - match *table.get(sc as uint) { + match (*table)[sc as uint] { EmptyCtxt => {return result;}, Mark(mrk,tail) => { result.push(M(mrk)); @@ -355,9 +355,9 @@ mod tests { assert_eq!(unfold_test_sc(test_sc.clone(),EMPTY_CTXT,&mut t),4); { let table = t.table.borrow(); - assert!(*table.get(2) == Mark(9,0)); - assert!(*table.get(3) == Rename(id(101,0),Name(14),2)); - assert!(*table.get(4) == Mark(3,3)); + assert!((*table)[2] == Mark(9,0)); + assert!((*table)[3] == Rename(id(101,0),Name(14),2)); + assert!((*table)[4] == Mark(3,3)); } assert_eq!(refold_test_sc(4,&t),test_sc); } @@ -376,8 +376,8 @@ mod tests { assert_eq!(unfold_marks(vec!(3,7),EMPTY_CTXT,&mut t),3); { let table = t.table.borrow(); - assert!(*table.get(2) == Mark(7,0)); - assert!(*table.get(3) == Mark(3,2)); + assert!((*table)[2] == Mark(7,0)); + assert!((*table)[3] == Mark(3,2)); } } diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index e8949c4aa4fe8..84775c12d641f 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -657,18 +657,20 @@ fn mk_tt(cx: &ExtCtxt, sp: Span, tt: &ast::TokenTree) -> Vec> { ast::TTNonterminal(sp, ident) => { - // tt.push_all_move($ident.to_tokens(ext_cx)) + // tt.extend($ident.to_tokens(ext_cx).into_iter()) let e_to_toks = cx.expr_method_call(sp, cx.expr_ident(sp, ident), id_ext("to_tokens"), vec!(cx.expr_ident(sp, id_ext("ext_cx")))); + let e_to_toks = + cx.expr_method_call(sp, e_to_toks, id_ext("into_iter"), vec![]); let e_push = cx.expr_method_call(sp, cx.expr_ident(sp, id_ext("tt")), - id_ext("push_all_move"), + id_ext("extend"), vec!(e_to_toks)); vec!(cx.stmt_expr(e_push)) @@ -680,7 +682,7 @@ fn mk_tts(cx: &ExtCtxt, sp: Span, tts: &[ast::TokenTree]) -> Vec> { let mut ss = Vec::new(); for tt in tts.iter() { - ss.push_all_move(mk_tt(cx, sp, tt)); + ss.extend(mk_tt(cx, sp, tt).into_iter()); } ss } @@ -742,7 +744,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.push_all_move(mk_tts(cx, sp, tts.as_slice())); + vector.extend(mk_tts(cx, sp, tts.as_slice()).into_iter()); let block = cx.expr_block( cx.block_all(sp, Vec::new(), diff --git a/src/libsyntax/ext/tt/macro_parser.rs b/src/libsyntax/ext/tt/macro_parser.rs index 88376108fecbc..78fcd729aae10 100644 --- a/src/libsyntax/ext/tt/macro_parser.rs +++ b/src/libsyntax/ext/tt/macro_parser.rs @@ -286,7 +286,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.get(idx)).clone(); + let sub = (ei.matches[idx]).clone(); new_pos.matches .get_mut(idx) .push(Rc::new(MatchedSeq(sub, mk_sp(ei.sp_lo, @@ -321,7 +321,7 @@ pub fn parse(sess: &ParseSess, eof_eis.push(ei); } } else { - match ei.elts.get(idx).node.clone() { + match ei.elts[idx].node.clone() { /* need to descend into sequence */ MatchSeq(ref matchers, ref sep, zero_ok, match_idx_lo, match_idx_hi) => { @@ -388,7 +388,7 @@ pub fn parse(sess: &ParseSess, if (bb_eis.len() > 0u && next_eis.len() > 0u) || bb_eis.len() > 1u { let nts = bb_eis.iter().map(|ei| { - match ei.elts.get(ei.idx).node { + match ei.elts[ei.idx].node { MatchNonterminal(bind, name, _) => { (format!("{} ('{}')", token::get_ident(name), @@ -413,7 +413,7 @@ pub fn parse(sess: &ParseSess, let mut rust_parser = Parser::new(sess, cfg.clone(), box rdr.clone()); let mut ei = bb_eis.pop().unwrap(); - match ei.elts.get(ei.idx).node { + match ei.elts[ei.idx].node { MatchNonterminal(_, name, idx) => { let name_string = token::get_ident(name); ei.matches.get_mut(idx).push(Rc::new(MatchedNonterminal( diff --git a/src/libsyntax/ext/tt/macro_rules.rs b/src/libsyntax/ext/tt/macro_rules.rs index 7a7dbc54c9ef9..91db3a9d8df50 100644 --- a/src/libsyntax/ext/tt/macro_rules.rs +++ b/src/libsyntax/ext/tt/macro_rules.rs @@ -255,12 +255,12 @@ pub fn add_new_extension<'cx>(cx: &'cx mut ExtCtxt, argument_gram); // Extract the arguments: - let lhses = match **argument_map.get(&lhs_nm) { + let lhses = match *argument_map[lhs_nm] { MatchedSeq(ref s, _) => /* FIXME (#2543) */ (*s).clone(), _ => cx.span_bug(sp, "wrong-structured lhs") }; - let rhses = match **argument_map.get(&rhs_nm) { + let rhses = match *argument_map[rhs_nm] { MatchedSeq(ref s, _) => /* FIXME (#2543) */ (*s).clone(), _ => cx.span_bug(sp, "wrong-structured rhs") }; diff --git a/src/libsyntax/ext/tt/transcribe.rs b/src/libsyntax/ext/tt/transcribe.rs index 1b9f6f16542f2..35ec37d842af1 100644 --- a/src/libsyntax/ext/tt/transcribe.rs +++ b/src/libsyntax/ext/tt/transcribe.rs @@ -79,7 +79,7 @@ fn lookup_cur_matched_by_matched(r: &TtReader, start: Rc) -> Rc ads.get(*idx).clone() + MatchedSeq(ref ads, _) => ads[*idx].clone() } }) } @@ -194,7 +194,7 @@ pub fn tt_next_token(r: &mut TtReader) -> TokenAndSpan { let t = { let frame = r.stack.last().unwrap(); // FIXME(pcwalton): Bad copy. - (*frame.forest.get(frame.idx)).clone() + (*frame.forest)[frame.idx].clone() }; match t { TTDelim(tts) => { diff --git a/src/libsyntax/fold.rs b/src/libsyntax/fold.rs index 2eb3b398da815..5e29167bf1a29 100644 --- a/src/libsyntax/fold.rs +++ b/src/libsyntax/fold.rs @@ -22,9 +22,10 @@ use ast::*; use ast; use ast_util; use codemap::{respan, Span, Spanned}; +use owned_slice::OwnedSlice; use parse::token; use ptr::P; -use owned_slice::OwnedSlice; +use std::ptr; use util::small_vector::SmallVector; use std::rc::Rc; @@ -36,11 +37,10 @@ pub trait MoveMap { impl MoveMap for Vec { fn move_map(mut self, f: |T| -> T) -> Vec { - use std::{mem, ptr}; for p in self.iter_mut() { unsafe { // FIXME(#5016) this shouldn't need to zero to be safe. - mem::move_val_init(p, f(ptr::read_and_zero(p))); + ptr::write(p, f(ptr::read_and_zero(p))); } } self @@ -935,7 +935,7 @@ pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { match *impl_item { MethodImplItem(ref x) => { for method in folder.fold_method((*x).clone()) - .move_iter() { + .into_iter() { new_impl_items.push(MethodImplItem(method)) } } @@ -963,7 +963,7 @@ pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { RequiredMethod(m) => { SmallVector::one(RequiredMethod( folder.fold_type_method(m))) - .move_iter() + .into_iter() } ProvidedMethod(method) => { // the awkward collect/iter idiom here is because @@ -971,15 +971,15 @@ pub fn noop_fold_item_underscore(i: Item_, folder: &mut T) -> Item_ { // trait bound, they're not actually the same type, so // the method arms don't unify. let methods: SmallVector = - folder.fold_method(method).move_iter() + folder.fold_method(method).into_iter() .map(|m| ProvidedMethod(m)).collect(); - methods.move_iter() + methods.into_iter() } TypeTraitItem(at) => { SmallVector::one(TypeTraitItem(P( folder.fold_associated_type( (*at).clone())))) - .move_iter() + .into_iter() } }; r diff --git a/src/libsyntax/lib.rs b/src/libsyntax/lib.rs index 8c2652e5699ff..4881be8996a8b 100644 --- a/src/libsyntax/lib.rs +++ b/src/libsyntax/lib.rs @@ -26,7 +26,6 @@ #![allow(unknown_features)] #![feature(macro_rules, globs, default_type_params, phase, slicing_syntax)] #![feature(quote, struct_variant, unsafe_destructor, import_shadowing)] -#![allow(deprecated)] extern crate arena; extern crate fmt_macros; @@ -61,7 +60,6 @@ pub mod ast_util; pub mod attr; pub mod codemap; pub mod config; -pub mod crateid; pub mod diagnostic; pub mod feature_gate; pub mod fold; diff --git a/src/libsyntax/owned_slice.rs b/src/libsyntax/owned_slice.rs index 798a54c1062d4..e5c37e5041abf 100644 --- a/src/libsyntax/owned_slice.rs +++ b/src/libsyntax/owned_slice.rs @@ -122,7 +122,7 @@ impl Default for OwnedSlice { impl Clone for OwnedSlice { fn clone(&self) -> OwnedSlice { - OwnedSlice::from_vec(Vec::from_slice(self.as_slice())) + OwnedSlice::from_vec(self.as_slice().to_vec()) } } diff --git a/src/libsyntax/parse/lexer/comments.rs b/src/libsyntax/parse/lexer/comments.rs index c53638ed07d13..551d15048f109 100644 --- a/src/libsyntax/parse/lexer/comments.rs +++ b/src/libsyntax/parse/lexer/comments.rs @@ -64,21 +64,21 @@ pub fn strip_doc_comment_decoration(comment: &str) -> String { let mut j = lines.len(); // first line of all-stars should be omitted if lines.len() > 0 && - lines.get(0).as_slice().chars().all(|c| c == '*') { + lines[0].as_slice().chars().all(|c| c == '*') { i += 1; } - while i < j && lines.get(i).as_slice().trim().is_empty() { + while i < j && lines[i].as_slice().trim().is_empty() { i += 1; } // like the first, a last line of all stars should be omitted - if j > i && lines.get(j - 1) + if j > i && lines[j - 1] .as_slice() .chars() .skip(1) .all(|c| c == '*') { j -= 1; } - while j > i && lines.get(j - 1).as_slice().trim().is_empty() { + while j > i && lines[j - 1].as_slice().trim().is_empty() { j -= 1; } return lines.slice(i, j).iter().map(|x| (*x).clone()).collect(); @@ -252,7 +252,7 @@ fn read_block_comment(rdr: &mut StringReader, // doc-comments are not really comments, they are attributes if (rdr.curr_is('*') && !rdr.nextch_is('*')) || rdr.curr_is('!') { while !(rdr.curr_is('*') && rdr.nextch_is('/')) && !rdr.is_eof() { - curr_line.push_char(rdr.curr.unwrap()); + curr_line.push(rdr.curr.unwrap()); rdr.bump(); } if !rdr.is_eof() { @@ -279,17 +279,17 @@ fn read_block_comment(rdr: &mut StringReader, curr_line = String::new(); rdr.bump(); } else { - curr_line.push_char(rdr.curr.unwrap()); + curr_line.push(rdr.curr.unwrap()); if rdr.curr_is('/') && rdr.nextch_is('*') { rdr.bump(); rdr.bump(); - curr_line.push_char('*'); + curr_line.push('*'); level += 1; } else { if rdr.curr_is('*') && rdr.nextch_is('/') { rdr.bump(); rdr.bump(); - curr_line.push_char('/'); + curr_line.push('/'); level -= 1; } else { rdr.bump(); } } diff --git a/src/libsyntax/parse/lexer/mod.rs b/src/libsyntax/parse/lexer/mod.rs index 38c985af37082..55d071b8d6005 100644 --- a/src/libsyntax/parse/lexer/mod.rs +++ b/src/libsyntax/parse/lexer/mod.rs @@ -180,7 +180,7 @@ impl<'a> StringReader<'a> { fn fatal_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) -> ! { let mut m = m.to_string(); m.push_str(": "); - char::escape_default(c, |c| m.push_char(c)); + char::escape_default(c, |c| m.push(c)); self.fatal_span_(from_pos, to_pos, m.as_slice()); } @@ -189,7 +189,7 @@ impl<'a> StringReader<'a> { fn err_span_char(&self, from_pos: BytePos, to_pos: BytePos, m: &str, c: char) { let mut m = m.to_string(); m.push_str(": "); - char::escape_default(c, |c| m.push_char(c)); + char::escape_default(c, |c| m.push(c)); self.err_span_(from_pos, to_pos, m.as_slice()); } @@ -1227,7 +1227,7 @@ impl<'a> StringReader<'a> { fn read_to_eol(&mut self) -> String { let mut val = String::new(); while !self.curr_is('\n') && !self.is_eof() { - val.push_char(self.curr.unwrap()); + val.push(self.curr.unwrap()); self.bump(); } if self.curr_is('\n') { self.bump(); } diff --git a/src/libsyntax/parse/mod.rs b/src/libsyntax/parse/mod.rs index c4a8775a01282..f1baccfcd8020 100644 --- a/src/libsyntax/parse/mod.rs +++ b/src/libsyntax/parse/mod.rs @@ -455,7 +455,7 @@ pub fn str_lit(lit: &str) -> String { for _ in range(0, n - 1) { // we don't need to move past the first \ chars.next(); } - res.push_char(c); + res.push(c); } }, '\r' => { @@ -467,9 +467,9 @@ pub fn str_lit(lit: &str) -> String { fail!("lexer accepted bare CR"); } chars.next(); - res.push_char('\n'); + res.push('\n'); } - c => res.push_char(c), + c => res.push(c), } }, None => break @@ -497,9 +497,9 @@ pub fn raw_str_lit(lit: &str) -> String { fail!("lexer accepted bare CR"); } chars.next(); - res.push_char('\n'); + res.push('\n'); } else { - res.push_char(c); + res.push(c); } }, None => break diff --git a/src/libsyntax/parse/parser.rs b/src/libsyntax/parse/parser.rs index 7e77283cca778..3ac7c42f7eaab 100644 --- a/src/libsyntax/parse/parser.rs +++ b/src/libsyntax/parse/parser.rs @@ -281,12 +281,13 @@ macro_rules! maybe_whole ( ) -fn maybe_append(lhs: Vec , rhs: Option >) - -> Vec { +fn maybe_append(mut lhs: Vec, rhs: Option>) + -> Vec { match rhs { - None => lhs, - Some(ref attrs) => lhs.append(attrs.as_slice()) + Some(ref attrs) => lhs.extend(attrs.iter().map(|a| a.clone())), + None => {} } + lhs } @@ -452,7 +453,8 @@ impl<'a> Parser<'a> { } else if inedible.contains(&self.token) { // leave it in the input } else { - let expected = edible.iter().map(|x| (*x).clone()).collect::>().append(inedible); + let mut expected = edible.iter().map(|x| x.clone()).collect::>(); + expected.push_all(inedible); let expect = tokens_to_string(expected.as_slice()); let actual = self.this_token_to_string(); self.fatal( @@ -496,8 +498,8 @@ impl<'a> Parser<'a> { match e.node { ExprPath(..) => { // might be unit-struct construction; check for recoverableinput error. - let expected = edible.iter().map(|x| (*x).clone()).collect::>() - .append(inedible); + let mut expected = edible.iter().map(|x| x.clone()).collect::>(); + expected.push_all(inedible); self.check_for_erroneous_unit_struct_expecting( expected.as_slice()); } @@ -517,8 +519,8 @@ impl<'a> Parser<'a> { if self.last_token .as_ref() .map_or(false, |t| is_ident_or_path(&**t)) { - let expected = edible.iter().map(|x| (*x).clone()).collect::>() - .append(inedible.as_slice()); + let mut expected = edible.iter().map(|x| x.clone()).collect::>(); + expected.push_all(inedible.as_slice()); self.check_for_erroneous_unit_struct_expecting( expected.as_slice()); } @@ -1332,7 +1334,8 @@ impl<'a> Parser<'a> { debug!("parse_trait_methods(): parsing provided method"); let (inner_attrs, body) = p.parse_inner_attrs_and_block(); - let attrs = attrs.append(inner_attrs.as_slice()); + let mut attrs = attrs; + attrs.push_all(inner_attrs.as_slice()); ProvidedMethod(P(ast::Method { attrs: attrs, id: ast::DUMMY_NODE_ID, @@ -2116,7 +2119,7 @@ impl<'a> Parser<'a> { |p| p.parse_expr() ); let mut exprs = vec!(first_expr); - exprs.push_all_move(remaining_exprs); + exprs.extend(remaining_exprs.into_iter()); ex = ExprVec(exprs); } else { // Vector with one element. @@ -2334,7 +2337,7 @@ impl<'a> Parser<'a> { ); hi = self.last_span.hi; - es.unshift(e); + es.insert(0, e); let id = spanned(dot, hi, i); let nd = self.mk_method_call(id, tys, es); e = self.mk_expr(lo, hi, nd); @@ -2597,7 +2600,7 @@ impl<'a> Parser<'a> { self.parse_seq_to_before_end(&close_delim, seq_sep_none(), |p| p.parse_token_tree()); - result.push_all_move(trees); + result.extend(trees.into_iter()); // Parse the close delimiter. result.push(parse_any_tt_tok(self)); @@ -3377,12 +3380,10 @@ impl<'a> Parser<'a> { _ => { if !enum_path.global && enum_path.segments.len() == 1 && - enum_path.segments - .get(0) + enum_path.segments[0] .lifetimes .len() == 0 && - enum_path.segments - .get(0) + enum_path.segments[0] .types .len() == 0 { // it could still be either an enum @@ -3391,7 +3392,7 @@ impl<'a> Parser<'a> { pat = PatIdent(BindByValue(MutImmutable), codemap::Spanned{ span: enum_path.span, - node: enum_path.segments.get(0) + node: enum_path.segments[0] .identifier}, None); } else { @@ -4253,7 +4254,7 @@ impl<'a> Parser<'a> { sep, parse_arg_fn ); - fn_inputs.unshift(Arg::new_self(explicit_self_sp, mutbl_self, $self_id)); + fn_inputs.insert(0, Arg::new_self(explicit_self_sp, mutbl_self, $self_id)); fn_inputs } token::RPAREN => { @@ -4446,7 +4447,8 @@ impl<'a> Parser<'a> { self.parse_where_clause(&mut generics); let (inner_attrs, body) = self.parse_inner_attrs_and_block(); let body_span = body.span; - let new_attrs = attrs.append(inner_attrs.as_slice()); + let mut new_attrs = attrs; + new_attrs.push_all(inner_attrs.as_slice()); (ast::MethDecl(ident, generics, abi, @@ -4487,7 +4489,7 @@ impl<'a> Parser<'a> { let (inner_attrs, mut method_attrs) = self.parse_inner_attrs_and_next(); while !self.eat(&token::RBRACE) { - method_attrs.push_all_move(self.parse_outer_attributes()); + method_attrs.extend(self.parse_outer_attributes().into_iter()); let vis = self.parse_visibility(); if self.eat_keyword(keywords::Type) { impl_items.push(TypeImplItem(P(self.parse_typedef( @@ -4708,7 +4710,9 @@ impl<'a> Parser<'a> { while self.token != term { let mut attrs = self.parse_outer_attributes(); if first { - attrs = attrs_remaining.clone().append(attrs.as_slice()); + let mut tmp = attrs_remaining.clone(); + tmp.push_all(attrs.as_slice()); + attrs = tmp; first = false; } debug!("parse_mod_items: parse_item_or_view_item(attrs={})", @@ -4823,7 +4827,7 @@ impl<'a> Parser<'a> { "cannot declare a new module at this location"); let this_module = match self.mod_path_stack.last() { Some(name) => name.get().to_string(), - None => self.root_module_name.get_ref().clone(), + None => self.root_module_name.as_ref().unwrap().clone(), }; self.span_note(id_sp, format!("maybe move this module `{0}` \ @@ -5533,7 +5537,7 @@ impl<'a> Parser<'a> { } else { s.push_str("priv") } - s.push_char('`'); + s.push('`'); let last_span = self.last_span; self.span_fatal(last_span, s.as_slice()); } @@ -5674,7 +5678,7 @@ impl<'a> Parser<'a> { } _ => () } - let mut rename_to = *path.get(path.len() - 1u); + let mut rename_to = path[path.len() - 1u]; let path = ast::Path { span: mk_sp(lo, self.span.hi), global: false, @@ -5702,7 +5706,8 @@ impl<'a> Parser<'a> { mut extern_mod_allowed: bool, macros_allowed: bool) -> ParsedItemsAndViewItems { - let mut attrs = first_item_attrs.append(self.parse_outer_attributes().as_slice()); + let mut attrs = first_item_attrs; + attrs.push_all(self.parse_outer_attributes().as_slice()); // First, parse view items. let mut view_items : Vec = Vec::new(); let mut items = Vec::new(); @@ -5783,7 +5788,8 @@ impl<'a> Parser<'a> { fn parse_foreign_items(&mut self, first_item_attrs: Vec , macros_allowed: bool) -> ParsedItemsAndViewItems { - let mut attrs = first_item_attrs.append(self.parse_outer_attributes().as_slice()); + let mut attrs = first_item_attrs; + attrs.push_all(self.parse_outer_attributes().as_slice()); let mut foreign_items = Vec::new(); loop { match self.parse_foreign_item(attrs, macros_allowed) { diff --git a/src/libsyntax/print/pp.rs b/src/libsyntax/print/pp.rs index f1fdc71b9c6f5..65efd4f00425b 100644 --- a/src/libsyntax/print/pp.rs +++ b/src/libsyntax/print/pp.rs @@ -134,12 +134,12 @@ pub fn buf_str(toks: Vec, s.push_str(", "); } s.push_str(format!("{}={}", - szs.get(i), - tok_str(toks.get(i).clone())).as_slice()); + szs[i], + tok_str(toks[i].clone())).as_slice()); i += 1u; i %= n; } - s.push_char(']'); + s.push(']'); return s.into_string(); } @@ -299,7 +299,7 @@ pub struct Printer { impl Printer { pub fn last_token(&mut self) -> Token { - (*self.token.get(self.right)).clone() + self.token[self.right].clone() } // be very careful with this! pub fn replace_last_token(&mut self, t: Token) { @@ -311,8 +311,8 @@ impl Printer { Eof => { if !self.scan_stack_empty { self.check_stack(0); - let left = (*self.token.get(self.left)).clone(); - let left_size = *self.size.get(self.left); + let left = self.token[self.left].clone(); + let left_size = self.size[self.left]; try!(self.advance_left(left, left_size)); } self.indent(0); @@ -388,14 +388,14 @@ impl Printer { debug!("scan window is {}, longer than space on line ({})", self.right_total - self.left_total, self.space); if !self.scan_stack_empty { - if self.left == *self.scan_stack.get(self.bottom) { + if self.left == self.scan_stack[self.bottom] { debug!("setting {} to infinity and popping", self.left); let scanned = self.scan_pop_bottom(); *self.size.get_mut(scanned) = SIZE_INFINITY; } } - let left = (*self.token.get(self.left)).clone(); - let left_size = *self.size.get(self.left); + let left = self.token[self.left].clone(); + let left_size = self.size[self.left]; try!(self.advance_left(left, left_size)); if self.left != self.right { try!(self.check_stream()); @@ -416,7 +416,7 @@ impl Printer { } pub fn scan_pop(&mut self) -> uint { assert!((!self.scan_stack_empty)); - let x = *self.scan_stack.get(self.top); + let x = self.scan_stack[self.top]; if self.top == self.bottom { self.scan_stack_empty = true; } else { @@ -426,11 +426,11 @@ impl Printer { } pub fn scan_top(&mut self) -> uint { assert!((!self.scan_stack_empty)); - return *self.scan_stack.get(self.top); + return self.scan_stack[self.top]; } pub fn scan_pop_bottom(&mut self) -> uint { assert!((!self.scan_stack_empty)); - let x = *self.scan_stack.get(self.bottom); + let x = self.scan_stack[self.bottom]; if self.top == self.bottom { self.scan_stack_empty = true; } else { @@ -458,8 +458,8 @@ impl Printer { if self.left != self.right { self.left += 1u; self.left %= self.buf_len; - let left = (*self.token.get(self.left)).clone(); - let left_size = *self.size.get(self.left); + let left = self.token[self.left].clone(); + let left_size = self.size[self.left]; try!(self.advance_left(left, left_size)); } ret @@ -470,29 +470,28 @@ impl Printer { pub fn check_stack(&mut self, k: int) { if !self.scan_stack_empty { let x = self.scan_top(); - match self.token.get(x) { - &Begin(_) => { - if k > 0 { + match self.token[x] { + Begin(_) => { + if k > 0 { + let popped = self.scan_pop(); + *self.size.get_mut(popped) = self.size[x] + + self.right_total; + self.check_stack(k - 1); + } + } + End => { + // paper says + not =, but that makes no sense. let popped = self.scan_pop(); - *self.size.get_mut(popped) = *self.size.get(x) + - self.right_total; - self.check_stack(k - 1); + *self.size.get_mut(popped) = 1; + self.check_stack(k + 1); } - } - &End => { - // paper says + not =, but that makes no sense. - let popped = self.scan_pop(); - *self.size.get_mut(popped) = 1; - self.check_stack(k + 1); - } - _ => { - let popped = self.scan_pop(); - *self.size.get_mut(popped) = *self.size.get(x) + - self.right_total; - if k > 0 { - self.check_stack(k); + _ => { + let popped = self.scan_pop(); + *self.size.get_mut(popped) = self.size[x] + self.right_total; + if k > 0 { + self.check_stack(k); + } } - } } } } @@ -511,7 +510,7 @@ impl Printer { let print_stack = &mut self.print_stack; let n = print_stack.len(); if n != 0u { - *print_stack.get(n - 1u) + (*print_stack)[n - 1] } else { PrintStackElem { offset: 0, diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index d32828192e996..26cf79ff8f956 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -175,7 +175,7 @@ pub fn to_string(f: |&mut State| -> IoResult<()>) -> String { let obj: TraitObject = mem::transmute_copy(&s.s.out); let wr: Box = mem::transmute(obj.data); let result = - String::from_utf8(Vec::from_slice(wr.get_ref().as_slice())).unwrap(); + String::from_utf8(wr.get_ref().as_slice().to_vec()).unwrap(); mem::forget(wr); result.to_string() } @@ -1466,7 +1466,7 @@ impl<'a> State<'a> { } ast::ExprMethodCall(ident, ref tys, ref args) => { let base_args = args.slice_from(1); - try!(self.print_expr(&**args.get(0))); + try!(self.print_expr(&*args[0])); try!(word(&mut self.s, ".")); try!(self.print_ident(ident.node)); if tys.len() > 0u { @@ -2144,7 +2144,7 @@ impl<'a> State<'a> { for &explicit_self in opt_explicit_self.iter() { let m = match explicit_self { &ast::SelfStatic => ast::MutImmutable, - _ => match decl.inputs.get(0).pat.node { + _ => match decl.inputs[0].pat.node { ast::PatIdent(ast::BindByValue(m), _, _) => m, _ => ast::MutImmutable } @@ -2319,7 +2319,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, ints.as_slice(), |s, &idx| { if idx < generics.lifetimes.len() { - let lifetime = generics.lifetimes.get(idx); + let lifetime = &generics.lifetimes[idx]; s.print_lifetime_def(lifetime) } else { let idx = idx - generics.lifetimes.len(); @@ -2663,14 +2663,14 @@ impl<'a> State<'a> { ast::LitStr(ref st, style) => self.print_string(st.get(), style), ast::LitByte(byte) => { let mut res = String::from_str("b'"); - (byte as char).escape_default(|c| res.push_char(c)); - res.push_char('\''); + (byte as char).escape_default(|c| res.push(c)); + res.push('\''); word(&mut self.s, res.as_slice()) } ast::LitChar(ch) => { let mut res = String::from_str("'"); - ch.escape_default(|c| res.push_char(c)); - res.push_char('\''); + ch.escape_default(|c| res.push(c)); + res.push('\''); word(&mut self.s, res.as_slice()) } ast::LitInt(i, t) => { @@ -2717,7 +2717,7 @@ impl<'a> State<'a> { match self.literals { Some(ref lits) => { while self.cur_cmnt_and_lit.cur_lit < lits.len() { - let ltrl = (*(*lits).get(self.cur_cmnt_and_lit.cur_lit)).clone(); + let ltrl = (*lits)[self.cur_cmnt_and_lit.cur_lit].clone(); if ltrl.pos > pos { return None; } self.cur_cmnt_and_lit.cur_lit += 1u; if ltrl.pos == pos { return Some(ltrl); } @@ -2749,7 +2749,7 @@ impl<'a> State<'a> { comments::Mixed => { assert_eq!(cmnt.lines.len(), 1u); try!(zerobreak(&mut self.s)); - try!(word(&mut self.s, cmnt.lines.get(0).as_slice())); + try!(word(&mut self.s, cmnt.lines[0].as_slice())); zerobreak(&mut self.s) } comments::Isolated => { @@ -2767,7 +2767,7 @@ impl<'a> State<'a> { comments::Trailing => { try!(word(&mut self.s, " ")); if cmnt.lines.len() == 1u { - try!(word(&mut self.s, cmnt.lines.get(0).as_slice())); + try!(word(&mut self.s, cmnt.lines[0].as_slice())); hardbreak(&mut self.s) } else { try!(self.ibox(0u)); @@ -2813,7 +2813,7 @@ impl<'a> State<'a> { match self.comments { Some(ref cmnts) => { if self.cur_cmnt_and_lit.cur_cmnt < cmnts.len() { - Some((*cmnts.get(self.cur_cmnt_and_lit.cur_cmnt)).clone()) + Some(cmnts[self.cur_cmnt_and_lit.cur_cmnt].clone()) } else { None } diff --git a/src/libsyntax/ptr.rs b/src/libsyntax/ptr.rs index bd560abf3bda7..1b231ed861b89 100644 --- a/src/libsyntax/ptr.rs +++ b/src/libsyntax/ptr.rs @@ -37,6 +37,7 @@ use std::fmt; use std::fmt::Show; use std::hash::Hash; +use std::ptr; use serialize::{Encodable, Decodable, Encoder, Decoder}; /// An owned smart pointer. @@ -61,11 +62,10 @@ impl P { /// Transform the inner value, consuming `self` and producing a new `P`. pub fn map(mut self, f: |T| -> T) -> P { - use std::{mem, ptr}; unsafe { let p = &mut *self.ptr; // FIXME(#5016) this shouldn't need to zero to be safe. - mem::move_val_init(p, f(ptr::read_and_zero(p))); + ptr::write(p, f(ptr::read_and_zero(p))); } self } diff --git a/src/libsyntax/std_inject.rs b/src/libsyntax/std_inject.rs index 8a7e14643c1a7..0f86fb751dae4 100644 --- a/src/libsyntax/std_inject.rs +++ b/src/libsyntax/std_inject.rs @@ -100,7 +100,7 @@ impl<'a> fold::Folder for StandardLibraryInjector<'a> { // `extern crate` must be precede `use` items mem::swap(&mut vis, &mut krate.module.view_items); - krate.module.view_items.push_all_move(vis); + krate.module.view_items.extend(vis.into_iter()); // don't add #![no_std] here, that will block the prelude injection later. // Add it during the prelude injection instead. @@ -219,7 +219,7 @@ impl<'a> fold::Folder for PreludeInjector<'a> { vis: ast::Inherited, span: DUMMY_SP, }); - view_items.push_all_move(uses); + view_items.extend(uses.into_iter()); fold::noop_fold_mod(ast::Mod { inner: inner, diff --git a/src/libsyntax/util/interner.rs b/src/libsyntax/util/interner.rs index c22bdde74a47c..ed2455d0a3068 100644 --- a/src/libsyntax/util/interner.rs +++ b/src/libsyntax/util/interner.rs @@ -67,7 +67,7 @@ impl Interner { pub fn get(&self, idx: Name) -> T { let vect = self.vect.borrow(); - (*(*vect).get(idx.uint())).clone() + (*vect)[idx.uint()].clone() } pub fn len(&self) -> uint { @@ -182,13 +182,13 @@ impl StrInterner { let new_idx = Name(self.len() as u32); // leave out of map to avoid colliding let mut vect = self.vect.borrow_mut(); - let existing = (*vect.get(idx.uint())).clone(); + let existing = (*vect)[idx.uint()].clone(); vect.push(existing); new_idx } pub fn get(&self, idx: Name) -> RcStr { - (*self.vect.borrow().get(idx.uint())).clone() + (*self.vect.borrow())[idx.uint()].clone() } pub fn len(&self) -> uint { diff --git a/src/libsyntax/util/small_vector.rs b/src/libsyntax/util/small_vector.rs index a3f081e7be4de..60ba5f6615b92 100644 --- a/src/libsyntax/util/small_vector.rs +++ b/src/libsyntax/util/small_vector.rs @@ -98,7 +98,7 @@ impl SmallVector { pub fn get<'a>(&'a self, idx: uint) -> &'a T { match self.repr { One(ref v) if idx == 0 => v, - Many(ref vs) => vs.get(idx), + Many(ref vs) => &vs[idx], _ => fail!("out of bounds access") } } diff --git a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs index 049a91cfdeb42..12ab62267a363 100644 --- a/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs +++ b/src/test/auxiliary/anon-extern-mod-cross-crate-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="anonexternmod#0.1"] +#![crate_name="anonexternmod"] extern crate libc; diff --git a/src/test/auxiliary/cci_impl_lib.rs b/src/test/auxiliary/cci_impl_lib.rs index ec48862ff3997..40a9a52061fe5 100644 --- a/src/test/auxiliary/cci_impl_lib.rs +++ b/src/test/auxiliary/cci_impl_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="cci_impl_lib"] +#![crate_name="cci_impl_lib"] pub trait uint_helpers { fn to(&self, v: uint, f: |uint|); diff --git a/src/test/auxiliary/cci_iter_lib.rs b/src/test/auxiliary/cci_iter_lib.rs index 2619ac71d99f6..84ade3572f95c 100644 --- a/src/test/auxiliary/cci_iter_lib.rs +++ b/src/test/auxiliary/cci_iter_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="cci_iter_lib"] +#![crate_name="cci_iter_lib"] #[inline] pub fn iter(v: &[T], f: |&T|) { diff --git a/src/test/auxiliary/cci_no_inline_lib.rs b/src/test/auxiliary/cci_no_inline_lib.rs index e9f82ef94133e..67f55cca1e16b 100644 --- a/src/test/auxiliary/cci_no_inline_lib.rs +++ b/src/test/auxiliary/cci_no_inline_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="cci_no_inline_lib"] +#![crate_name="cci_no_inline_lib"] // same as cci_iter_lib, more-or-less, but not marked inline @@ -16,7 +16,7 @@ pub fn iter(v: Vec , f: |uint|) { let mut i = 0u; let n = v.len(); while i < n { - f(*v.get(i)); + f(v[i]); i += 1u; } } diff --git a/src/test/auxiliary/changing-crates-a1.rs b/src/test/auxiliary/changing-crates-a1.rs index 360ab79c5b4c4..18162c5f756b8 100644 --- a/src/test/auxiliary/changing-crates-a1.rs +++ b/src/test/auxiliary/changing-crates-a1.rs @@ -8,6 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "a"] +#![crate_name = "a"] pub fn foo() {} diff --git a/src/test/auxiliary/changing-crates-a2.rs b/src/test/auxiliary/changing-crates-a2.rs index 650b3ac7dcaa2..a54dcbbbfc245 100644 --- a/src/test/auxiliary/changing-crates-a2.rs +++ b/src/test/auxiliary/changing-crates-a2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "a"] +#![crate_name = "a"] pub fn foo() { println!("hello!"); } diff --git a/src/test/auxiliary/changing-crates-b.rs b/src/test/auxiliary/changing-crates-b.rs index 63bdb889fd00a..81f924e29daa7 100644 --- a/src/test/auxiliary/changing-crates-b.rs +++ b/src/test/auxiliary/changing-crates-b.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "b"] +#![crate_name = "b"] extern crate a; diff --git a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs index 5e2a04001b5d6..f3d5bf2d65eee 100644 --- a/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs +++ b/src/test/auxiliary/crate-method-reexport-grrrrrrr2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crate_method_reexport_grrrrrrr2"] +#![crate_name="crate_method_reexport_grrrrrrr2"] pub use name_pool::add; diff --git a/src/test/auxiliary/crateresolve3-1.rs b/src/test/auxiliary/crateresolve3-1.rs index 9d00b92182e7b..473528c681e7f 100644 --- a/src/test/auxiliary/crateresolve3-1.rs +++ b/src/test/auxiliary/crateresolve3-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve3#0.1"] +#![crate_name="crateresolve3#0.1"] #![crate_type = "lib"] diff --git a/src/test/auxiliary/crateresolve3-2.rs b/src/test/auxiliary/crateresolve3-2.rs index 117e585e9ad29..1e95fa6b63903 100644 --- a/src/test/auxiliary/crateresolve3-2.rs +++ b/src/test/auxiliary/crateresolve3-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve3#0.2"] +#![crate_name="crateresolve3#0.2"] #![crate_type = "lib"] diff --git a/src/test/auxiliary/crateresolve4a-1.rs b/src/test/auxiliary/crateresolve4a-1.rs index dfe1d92c5933b..68a69f6dc9073 100644 --- a/src/test/auxiliary/crateresolve4a-1.rs +++ b/src/test/auxiliary/crateresolve4a-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve4a#0.1"] +#![crate_name="crateresolve4a#0.1"] #![crate_type = "lib"] pub fn f() -> int { 10 } diff --git a/src/test/auxiliary/crateresolve4a-2.rs b/src/test/auxiliary/crateresolve4a-2.rs index 196751e99fa89..6e23fddbce7df 100644 --- a/src/test/auxiliary/crateresolve4a-2.rs +++ b/src/test/auxiliary/crateresolve4a-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve4a#0.2"] +#![crate_name="crateresolve4a#0.2"] #![crate_type = "lib"] pub fn g() -> int { 20 } diff --git a/src/test/auxiliary/crateresolve4b-1.rs b/src/test/auxiliary/crateresolve4b-1.rs index 54ee9c2d5a28d..843fd57ee40d7 100644 --- a/src/test/auxiliary/crateresolve4b-1.rs +++ b/src/test/auxiliary/crateresolve4b-1.rs @@ -10,7 +10,7 @@ // aux-build:crateresolve4a-1.rs // aux-build:crateresolve4a-2.rs -#![crate_id="crateresolve4b#0.1"] +#![crate_name="crateresolve4b#0.1"] #![crate_type = "lib"] extern crate "crateresolve4a#0.2" as crateresolve4a; diff --git a/src/test/auxiliary/crateresolve4b-2.rs b/src/test/auxiliary/crateresolve4b-2.rs index 9221ecc697b48..28c89c79316e2 100644 --- a/src/test/auxiliary/crateresolve4b-2.rs +++ b/src/test/auxiliary/crateresolve4b-2.rs @@ -10,7 +10,7 @@ // aux-build:crateresolve4a-1.rs // aux-build:crateresolve4a-2.rs -#![crate_id="crateresolve4b#0.2"] +#![crate_name="crateresolve4b#0.2"] #![crate_type = "lib"] extern crate "crateresolve4a#0.1" as crateresolve4a; diff --git a/src/test/auxiliary/crateresolve5-1.rs b/src/test/auxiliary/crateresolve5-1.rs index de48981ed3ede..223e4f50ae8ac 100644 --- a/src/test/auxiliary/crateresolve5-1.rs +++ b/src/test/auxiliary/crateresolve5-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve5#0.1"] +#![crate_name="crateresolve5#0.1"] #![crate_type = "lib"] diff --git a/src/test/auxiliary/crateresolve5-2.rs b/src/test/auxiliary/crateresolve5-2.rs index f8727605c3db9..38740886b37ea 100644 --- a/src/test/auxiliary/crateresolve5-2.rs +++ b/src/test/auxiliary/crateresolve5-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve5#0.2"] +#![crate_name="crateresolve5#0.2"] #![crate_type = "lib"] diff --git a/src/test/auxiliary/crateresolve8-1.rs b/src/test/auxiliary/crateresolve8-1.rs index 062d606a4c1c2..5262d662971a4 100644 --- a/src/test/auxiliary/crateresolve8-1.rs +++ b/src/test/auxiliary/crateresolve8-1.rs @@ -9,7 +9,7 @@ // except according to those terms. // default link meta for 'package_id' will be equal to filestem -#![crate_id="crateresolve8#0.1"] +#![crate_name="crateresolve8#0.1"] #![crate_type = "lib"] diff --git a/src/test/auxiliary/crateresolve_calories-1.rs b/src/test/auxiliary/crateresolve_calories-1.rs index a0d7ae7cd2fba..4dba722971e3c 100644 --- a/src/test/auxiliary/crateresolve_calories-1.rs +++ b/src/test/auxiliary/crateresolve_calories-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve_calories#0.1"] +#![crate_name="crateresolve_calories#0.1"] #![crate_type = "lib"] pub fn f() -> int { 100 } diff --git a/src/test/auxiliary/crateresolve_calories-2.rs b/src/test/auxiliary/crateresolve_calories-2.rs index bbad91625cc7a..c7e26c8f506d4 100644 --- a/src/test/auxiliary/crateresolve_calories-2.rs +++ b/src/test/auxiliary/crateresolve_calories-2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateresolve_calories#0.1"] +#![crate_name="crateresolve_calories#0.1"] #![crate_type = "lib"] pub fn f() -> int { 200 } diff --git a/src/test/auxiliary/foreign_lib.rs b/src/test/auxiliary/foreign_lib.rs index 500475091e0d3..a5d672e3c0cf9 100644 --- a/src/test/auxiliary/foreign_lib.rs +++ b/src/test/auxiliary/foreign_lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="foreign_lib"] +#![crate_name="foreign_lib"] pub mod rustrt { extern crate libc; diff --git a/src/test/auxiliary/inherited_stability.rs b/src/test/auxiliary/inherited_stability.rs index af3dd94fe1d77..4016a76206be4 100644 --- a/src/test/auxiliary/inherited_stability.rs +++ b/src/test/auxiliary/inherited_stability.rs @@ -7,7 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="inherited_stability#0.1"] +#![crate_name="inherited_stability"] #![crate_type = "lib"] #![experimental] diff --git a/src/test/auxiliary/inline_dtor.rs b/src/test/auxiliary/inline_dtor.rs index fa0d447a8edf7..dd1fdc2e4981f 100644 --- a/src/test/auxiliary/inline_dtor.rs +++ b/src/test/auxiliary/inline_dtor.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="inline_dtor#0.1"] +#![crate_name="inline_dtor"] pub struct Foo; diff --git a/src/test/auxiliary/iss.rs b/src/test/auxiliary/iss.rs index 3a9d76406e10a..37edcdf762898 100644 --- a/src/test/auxiliary/iss.rs +++ b/src/test/auxiliary/iss.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="issue6919_3#0.1"] +#![crate_name="issue6919_3"] // part of issue-6919.rs diff --git a/src/test/auxiliary/issue-2380.rs b/src/test/auxiliary/issue-2380.rs index 1cba738c56406..af6bb050ef5a0 100644 --- a/src/test/auxiliary/issue-2380.rs +++ b/src/test/auxiliary/issue-2380.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="a"] +#![crate_name="a"] #![crate_type = "lib"] diff --git a/src/test/auxiliary/issue-2414-a.rs b/src/test/auxiliary/issue-2414-a.rs index 08eaec2ed3552..fe1ef549d06ac 100644 --- a/src/test/auxiliary/issue-2414-a.rs +++ b/src/test/auxiliary/issue-2414-a.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="a#0.1"] +#![crate_name="a"] #![crate_type = "lib"] type t1 = uint; diff --git a/src/test/auxiliary/issue-2414-b.rs b/src/test/auxiliary/issue-2414-b.rs index 51fd979f961c6..b1c95bcb4300f 100644 --- a/src/test/auxiliary/issue-2414-b.rs +++ b/src/test/auxiliary/issue-2414-b.rs @@ -9,7 +9,7 @@ // except according to those terms. -#![crate_id="b#0.1"] +#![crate_name="b"] #![crate_type = "lib"] extern crate a; diff --git a/src/test/auxiliary/issue-2526.rs b/src/test/auxiliary/issue-2526.rs index c2e1dd69a900c..e3ce4e8f6565a 100644 --- a/src/test/auxiliary/issue-2526.rs +++ b/src/test/auxiliary/issue-2526.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="issue_2526#0.2"] +#![crate_name="issue_2526"] #![crate_type = "lib"] #![feature(unsafe_destructor)] diff --git a/src/test/auxiliary/issue-2631-a.rs b/src/test/auxiliary/issue-2631-a.rs index 3bedbd9089ce2..e340331dbfd11 100644 --- a/src/test/auxiliary/issue-2631-a.rs +++ b/src/test/auxiliary/issue-2631-a.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="req"] +#![crate_name="req"] #![crate_type = "lib"] use std::cell::RefCell; @@ -19,7 +19,5 @@ pub type header_map = HashMap>>>>; // the unused ty param is necessary so this gets monomorphized pub fn request(req: &header_map) { - let _x = (**((**req.get(&"METHOD".to_string())).clone()).borrow() - .clone() - .get(0)).clone(); + let _x = req["METHOD".to_string()].clone().borrow().clone()[0].clone(); } diff --git a/src/test/auxiliary/issue-3012-1.rs b/src/test/auxiliary/issue-3012-1.rs index dbb863da90a56..25eb67e042300 100644 --- a/src/test/auxiliary/issue-3012-1.rs +++ b/src/test/auxiliary/issue-3012-1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="socketlib"] +#![crate_name="socketlib"] #![crate_type = "lib"] pub mod socket { diff --git a/src/test/auxiliary/issue-4208-cc.rs b/src/test/auxiliary/issue-4208-cc.rs index cc75ca6f3af91..a7c1633784d81 100644 --- a/src/test/auxiliary/issue-4208-cc.rs +++ b/src/test/auxiliary/issue-4208-cc.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="numeric#0.1"] +#![crate_name="numeric"] #![crate_type = "lib"] pub trait Trig { diff --git a/src/test/auxiliary/issue_2242_a.rs b/src/test/auxiliary/issue_2242_a.rs index 4fae888c6ad63..33b6d116c8a2d 100644 --- a/src/test/auxiliary/issue_2242_a.rs +++ b/src/test/auxiliary/issue_2242_a.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="a#0.1"] +#![crate_name="a#0.1"] #![crate_type = "lib"] trait to_strz { diff --git a/src/test/auxiliary/issue_2242_c.rs b/src/test/auxiliary/issue_2242_c.rs index 97d2556873510..31d119b20beaa 100644 --- a/src/test/auxiliary/issue_2242_c.rs +++ b/src/test/auxiliary/issue_2242_c.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="c#0.1"] +#![crate_name="c#0.1"] #![crate_type = "lib"] extern crate a; diff --git a/src/test/auxiliary/issue_3979_traits.rs b/src/test/auxiliary/issue_3979_traits.rs index ef7e4d0fc0985..91faace7a3f4d 100644 --- a/src/test/auxiliary/issue_3979_traits.rs +++ b/src/test/auxiliary/issue_3979_traits.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="issue_3979_traits#0.1"] +#![crate_name="issue_3979_traits"] #![crate_type = "lib"] diff --git a/src/test/auxiliary/lint_output_format.rs b/src/test/auxiliary/lint_output_format.rs index 00500da655f7f..181b651ef521c 100755 --- a/src/test/auxiliary/lint_output_format.rs +++ b/src/test/auxiliary/lint_output_format.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="lint_output_format#0.1"] +#![crate_name="lint_output_format"] #![crate_type = "lib"] #[deprecated] diff --git a/src/test/auxiliary/lint_stability.rs b/src/test/auxiliary/lint_stability.rs index bae86f04b23b6..06031eb6c6ccf 100644 --- a/src/test/auxiliary/lint_stability.rs +++ b/src/test/auxiliary/lint_stability.rs @@ -7,7 +7,7 @@ // , at your // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="lint_stability#0.1"] +#![crate_name="lint_stability"] #![crate_type = "lib"] #![feature(macro_rules)] diff --git a/src/test/auxiliary/macro_crate_test.rs b/src/test/auxiliary/macro_crate_test.rs index befd33fca4eeb..1c26ac26d7cf3 100644 --- a/src/test/auxiliary/macro_crate_test.rs +++ b/src/test/auxiliary/macro_crate_test.rs @@ -51,7 +51,7 @@ fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree]) -> Box { // Parse an expression and emit it unchanged. let mut parser = parse::new_parser_from_tts(cx.parse_sess(), - cx.cfg(), Vec::from_slice(tts)); + cx.cfg(), tts.to_vec()); let expr = parser.parse_expr(); MacExpr::new(quote_expr!(&mut *cx, $expr)) } diff --git a/src/test/auxiliary/static-function-pointer-aux.rs b/src/test/auxiliary/static-function-pointer-aux.rs index c08f725ff0a28..27befee6f07f5 100644 --- a/src/test/auxiliary/static-function-pointer-aux.rs +++ b/src/test/auxiliary/static-function-pointer-aux.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="static-function-pointer-aux"] +#![crate_name="static-function-pointer-aux"] pub fn f(x: int) -> int { -x } diff --git a/src/test/auxiliary/static-methods-crate.rs b/src/test/auxiliary/static-methods-crate.rs index afb35112fb846..eef2fdbfea9d9 100644 --- a/src/test/auxiliary/static-methods-crate.rs +++ b/src/test/auxiliary/static-methods-crate.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="static_methods_crate#0.1"] +#![crate_name="static_methods_crate"] #![crate_type = "lib"] use std::int; diff --git a/src/test/auxiliary/struct_variant_xc_aux.rs b/src/test/auxiliary/struct_variant_xc_aux.rs index 88b6b36322228..4ef8701030f47 100644 --- a/src/test/auxiliary/struct_variant_xc_aux.rs +++ b/src/test/auxiliary/struct_variant_xc_aux.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="struct_variant_xc_aux#0.1"] +#![crate_name="struct_variant_xc_aux"] #![crate_type = "lib"] #![feature(struct_variant)] diff --git a/src/test/auxiliary/svh-a-base.rs b/src/test/auxiliary/svh-a-base.rs index b83e96fc47d7a..c035f1203f8e3 100644 --- a/src/test/auxiliary/svh-a-base.rs +++ b/src/test/auxiliary/svh-a-base.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-change-lit.rs b/src/test/auxiliary/svh-a-change-lit.rs index 81c2c39bd5208..614487c981713 100644 --- a/src/test/auxiliary/svh-a-change-lit.rs +++ b/src/test/auxiliary/svh-a-change-lit.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-change-significant-cfg.rs b/src/test/auxiliary/svh-a-change-significant-cfg.rs index 33dd3868566c7..99506309a592e 100644 --- a/src/test/auxiliary/svh-a-change-significant-cfg.rs +++ b/src/test/auxiliary/svh-a-change-significant-cfg.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-change-trait-bound.rs b/src/test/auxiliary/svh-a-change-trait-bound.rs index 04c320d401699..8ec4eaebbe8df 100644 --- a/src/test/auxiliary/svh-a-change-trait-bound.rs +++ b/src/test/auxiliary/svh-a-change-trait-bound.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-change-type-arg.rs b/src/test/auxiliary/svh-a-change-type-arg.rs index 33f2bf862edaa..ad120e12f86fb 100644 --- a/src/test/auxiliary/svh-a-change-type-arg.rs +++ b/src/test/auxiliary/svh-a-change-type-arg.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-change-type-ret.rs b/src/test/auxiliary/svh-a-change-type-ret.rs index 3eea77fdb95c4..c68c13c0991f2 100644 --- a/src/test/auxiliary/svh-a-change-type-ret.rs +++ b/src/test/auxiliary/svh-a-change-type-ret.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-change-type-static.rs b/src/test/auxiliary/svh-a-change-type-static.rs index ff8b8d6db4cfc..6c13e84a7febe 100644 --- a/src/test/auxiliary/svh-a-change-type-static.rs +++ b/src/test/auxiliary/svh-a-change-type-static.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-comment.rs b/src/test/auxiliary/svh-a-comment.rs index 208f39ffedc41..3d0973cb7ba13 100644 --- a/src/test/auxiliary/svh-a-comment.rs +++ b/src/test/auxiliary/svh-a-comment.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-doc.rs b/src/test/auxiliary/svh-a-doc.rs index 667a3b28ceadc..1ad9e5e1c0e3a 100644 --- a/src/test/auxiliary/svh-a-doc.rs +++ b/src/test/auxiliary/svh-a-doc.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-macro.rs b/src/test/auxiliary/svh-a-macro.rs index f4279b44b4e0e..6bd36b5a9b1c4 100644 --- a/src/test/auxiliary/svh-a-macro.rs +++ b/src/test/auxiliary/svh-a-macro.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-no-change.rs b/src/test/auxiliary/svh-a-no-change.rs index b83e96fc47d7a..c035f1203f8e3 100644 --- a/src/test/auxiliary/svh-a-no-change.rs +++ b/src/test/auxiliary/svh-a-no-change.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-redundant-cfg.rs b/src/test/auxiliary/svh-a-redundant-cfg.rs index 203dadd633e72..d67c8f4c18179 100644 --- a/src/test/auxiliary/svh-a-redundant-cfg.rs +++ b/src/test/auxiliary/svh-a-redundant-cfg.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-a-whitespace.rs b/src/test/auxiliary/svh-a-whitespace.rs index 9b332a294d632..73798f3787558 100644 --- a/src/test/auxiliary/svh-a-whitespace.rs +++ b/src/test/auxiliary/svh-a-whitespace.rs @@ -15,7 +15,7 @@ #![feature(macro_rules)] -#![crate_id = "a"] +#![crate_name = "a"] macro_rules! three { () => { 3 } diff --git a/src/test/auxiliary/svh-b.rs b/src/test/auxiliary/svh-b.rs index 713fed591c82e..b8946fdc99553 100644 --- a/src/test/auxiliary/svh-b.rs +++ b/src/test/auxiliary/svh-b.rs @@ -16,7 +16,7 @@ //! the change could affect the downstream crate content or not //! (#14132). -#![crate_id = "b"] +#![crate_name = "b"] extern crate a; diff --git a/src/test/auxiliary/svh-uta-base.rs b/src/test/auxiliary/svh-uta-base.rs index 5b4617c05ead1..67fdac5df0330 100644 --- a/src/test/auxiliary/svh-uta-base.rs +++ b/src/test/auxiliary/svh-uta-base.rs @@ -15,7 +15,7 @@ //! //! This is the upstream crate. -#![crate_id = "uta"] +#![crate_name = "uta"] mod traits { pub trait TraitA { fn val(&self) -> int { 2 } } diff --git a/src/test/auxiliary/svh-uta-change-use-trait.rs b/src/test/auxiliary/svh-uta-change-use-trait.rs index 1a2fb3cee1eae..dfcf02c0ff500 100644 --- a/src/test/auxiliary/svh-uta-change-use-trait.rs +++ b/src/test/auxiliary/svh-uta-change-use-trait.rs @@ -15,7 +15,7 @@ //! //! This is the upstream crate. -#![crate_id = "uta"] +#![crate_name = "uta"] mod traits { pub trait TraitA { fn val(&self) -> int { 2 } } diff --git a/src/test/auxiliary/svh-utb.rs b/src/test/auxiliary/svh-utb.rs index ccc0bac5150ec..eb3da985242be 100644 --- a/src/test/auxiliary/svh-utb.rs +++ b/src/test/auxiliary/svh-utb.rs @@ -15,7 +15,7 @@ //! //! This is the downstream crate. -#![crate_id = "utb"] +#![crate_name = "utb"] extern crate uta; diff --git a/src/test/auxiliary/trait_default_method_xc_aux.rs b/src/test/auxiliary/trait_default_method_xc_aux.rs index 159ecdcb42a62..7424c21be3da0 100644 --- a/src/test/auxiliary/trait_default_method_xc_aux.rs +++ b/src/test/auxiliary/trait_default_method_xc_aux.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="trait_default_method_xc_aux"] +#![crate_name="trait_default_method_xc_aux"] pub struct Something { pub x: int } diff --git a/src/test/bench/core-std.rs b/src/test/bench/core-std.rs index 9af3c0c6c8c1a..404e2e31b0577 100644 --- a/src/test/bench/core-std.rs +++ b/src/test/bench/core-std.rs @@ -68,7 +68,7 @@ fn shift_push() { let mut v2 = Vec::new(); while v1.len() > 0 { - v2.push(v1.shift().unwrap()); + v2.push(v1.remove(0).unwrap()); } } @@ -93,9 +93,11 @@ fn vec_plus() { while i < 1500 { let rv = Vec::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { - v.push_all_move(rv); + v.extend(rv.into_iter()); } else { - v = rv.clone().append(v.as_slice()); + let mut rv = rv.clone(); + rv.push_all(v.as_slice()); + v = rv; } i += 1; } @@ -109,10 +111,14 @@ fn vec_append() { while i < 1500 { let rv = Vec::from_elem(r.gen_range(0u, i + 1), i); if r.gen() { - v = v.clone().append(rv.as_slice()); + let mut t = v.clone(); + t.push_all(rv.as_slice()); + v = t; } else { - v = rv.clone().append(v.as_slice()); + let mut t = rv.clone(); + t.push_all(v.as_slice()); + v = t; } i += 1; } diff --git a/src/test/bench/core-uint-to-str.rs b/src/test/bench/core-uint-to-str.rs index 1f527e89eb23f..98113cb834767 100644 --- a/src/test/bench/core-uint-to-str.rs +++ b/src/test/bench/core-uint-to-str.rs @@ -21,7 +21,7 @@ fn main() { args.into_iter().collect() }; - let n = from_str::(args.get(1).as_slice()).unwrap(); + let n = from_str::(args[1].as_slice()).unwrap(); for i in range(0u, n) { let x = i.to_string(); diff --git a/src/test/bench/msgsend-ring-mutex-arcs.rs b/src/test/bench/msgsend-ring-mutex-arcs.rs index d1a2dcf6d5588..1a9ffd6828486 100644 --- a/src/test/bench/msgsend-ring-mutex-arcs.rs +++ b/src/test/bench/msgsend-ring-mutex-arcs.rs @@ -72,8 +72,8 @@ fn main() { args.clone().into_iter().collect() }; - let num_tasks = from_str::(args.get(1).as_slice()).unwrap(); - let msg_per_task = from_str::(args.get(2).as_slice()).unwrap(); + let num_tasks = from_str::(args[1].as_slice()).unwrap(); + let msg_per_task = from_str::(args[2].as_slice()).unwrap(); let (mut num_chan, num_port) = init(); diff --git a/src/test/bench/msgsend-ring-rw-arcs.rs b/src/test/bench/msgsend-ring-rw-arcs.rs index c07656a5e4b6d..5e192a1479346 100644 --- a/src/test/bench/msgsend-ring-rw-arcs.rs +++ b/src/test/bench/msgsend-ring-rw-arcs.rs @@ -72,8 +72,8 @@ fn main() { args.clone().into_iter().collect() }; - let num_tasks = from_str::(args.get(1).as_slice()).unwrap(); - let msg_per_task = from_str::(args.get(2).as_slice()).unwrap(); + let num_tasks = from_str::(args[1].as_slice()).unwrap(); + let msg_per_task = from_str::(args[2].as_slice()).unwrap(); let (mut num_chan, num_port) = init(); diff --git a/src/test/bench/shootout-ackermann.rs b/src/test/bench/shootout-ackermann.rs index 90d2c85785837..e7a50382c9469 100644 --- a/src/test/bench/shootout-ackermann.rs +++ b/src/test/bench/shootout-ackermann.rs @@ -31,6 +31,6 @@ fn main() { } else { args.into_iter().collect() }; - let n = from_str::(args.get(1).as_slice()).unwrap(); + let n = from_str::(args[1].as_slice()).unwrap(); println!("Ack(3,{}): {}\n", n, ack(3, n)); } diff --git a/src/test/bench/shootout-fibo.rs b/src/test/bench/shootout-fibo.rs index 1f42cc6e00c5d..10c0d0a8044cb 100644 --- a/src/test/bench/shootout-fibo.rs +++ b/src/test/bench/shootout-fibo.rs @@ -27,6 +27,6 @@ fn main() { } else { args.into_iter().collect() }; - let n = from_str::(args.get(1).as_slice()).unwrap(); + let n = from_str::(args[1].as_slice()).unwrap(); println!("{}\n", fib(n)); } diff --git a/src/test/bench/shootout-k-nucleotide-pipes.rs b/src/test/bench/shootout-k-nucleotide-pipes.rs index 1754df9bf44a1..5d77e27f948a1 100644 --- a/src/test/bench/shootout-k-nucleotide-pipes.rs +++ b/src/test/bench/shootout-k-nucleotide-pipes.rs @@ -83,7 +83,7 @@ fn find(mm: &HashMap , uint>, key: String) -> uint { // given a map, increment the counter for a key fn update_freq(mm: &mut HashMap , uint>, key: &[u8]) { - let key = Vec::from_slice(key); + let key = key.to_vec(); let newval = match mm.pop(&key) { Some(v) => v + 1, None => 1 @@ -103,7 +103,7 @@ fn windows_with_carry(bb: &[u8], nn: uint, it: |window: &[u8]|) -> Vec { ii += 1u; } - return Vec::from_slice(bb[len - (nn - 1u)..len]); + return bb[len - (nn - 1u)..len].to_vec(); } fn make_sequence_processor(sz: uint, @@ -117,15 +117,14 @@ fn make_sequence_processor(sz: uint, loop { - line = from_parent.recv(); - if line == Vec::new() { break; } + line = from_parent.recv(); + if line == Vec::new() { break; } - carry = windows_with_carry(carry.append(line.as_slice()).as_slice(), - sz, - |window| { - update_freq(&mut freqs, window); - total += 1u; - }); + carry.push_all(line.as_slice()); + carry = windows_with_carry(carry.as_slice(), sz, |window| { + update_freq(&mut freqs, window); + total += 1u; + }); } let buffer = match sz { @@ -149,7 +148,7 @@ fn main() { let rdr = if os::getenv("RUST_BENCH").is_some() { let foo = include_bin!("shootout-k-nucleotide.data"); - box MemReader::new(Vec::from_slice(foo)) as Box + box MemReader::new(foo.to_vec()) as Box } else { box stdio::stdin() as Box }; @@ -203,8 +202,8 @@ fn main() { let line_bytes = line.as_bytes(); for (ii, _sz) in sizes.iter().enumerate() { - let lb = Vec::from_slice(line_bytes); - to_child.get(ii).send(lb); + let lb = line_bytes.to_vec(); + to_child[ii].send(lb); } } @@ -215,11 +214,11 @@ fn main() { // finish... for (ii, _sz) in sizes.iter().enumerate() { - to_child.get(ii).send(Vec::new()); + to_child[ii].send(Vec::new()); } // now fetch and print result messages for (ii, _sz) in sizes.iter().enumerate() { - println!("{}", from_child.get(ii).recv()); + println!("{}", from_child[ii].recv()); } } diff --git a/src/test/bench/shootout-nbody.rs b/src/test/bench/shootout-nbody.rs index 3c8e83895647b..8486fa5b034d6 100644 --- a/src/test/bench/shootout-nbody.rs +++ b/src/test/bench/shootout-nbody.rs @@ -102,7 +102,7 @@ fn advance(bodies: &mut [Planet, ..N_BODIES], dt: f64, steps: int) { for _ in range(0, steps) { let mut b_slice = bodies.as_mut_slice(); loop { - let bi = match b_slice.mut_shift_ref() { + let bi = match shift_mut_ref(&mut b_slice) { Some(bi) => bi, None => break }; @@ -183,3 +183,21 @@ fn main() { println!("{:.9f}", energy(&bodies)); } + +/// Pop a mutable reference off the head of a slice, mutating the slice to no +/// longer contain the mutable reference. This is a safe operation because the +/// two mutable borrows are entirely disjoint. +fn shift_mut_ref<'a, T>(r: &mut &'a mut [T]) -> Option<&'a mut T> { + use std::mem; + use std::raw::Repr; + + if r.len() == 0 { return None } + unsafe { + let mut raw = r.repr(); + let ret = raw.data as *mut T; + raw.data = raw.data.offset(1); + raw.len -= 1; + *r = mem::transmute(raw); + Some(unsafe { &mut *ret }) + } +} diff --git a/src/test/bench/shootout-pfib.rs b/src/test/bench/shootout-pfib.rs index 516bd99ab550a..91b9e058e8fea 100644 --- a/src/test/bench/shootout-pfib.rs +++ b/src/test/bench/shootout-pfib.rs @@ -102,7 +102,7 @@ fn main() { if opts.stress { stress(2); } else { - let max = uint::parse_bytes(args.get(1).as_bytes(), 10u).unwrap() as + let max = uint::parse_bytes(args[1].as_bytes(), 10u).unwrap() as int; let num_trials = 10; diff --git a/src/test/bench/std-smallintmap.rs b/src/test/bench/std-smallintmap.rs index c495e597ca6d0..2086980b016fc 100644 --- a/src/test/bench/std-smallintmap.rs +++ b/src/test/bench/std-smallintmap.rs @@ -25,7 +25,7 @@ fn append_sequential(min: uint, max: uint, map: &mut SmallIntMap) { fn check_sequential(min: uint, max: uint, map: &SmallIntMap) { for i in range(min, max) { - assert_eq!(*map.get(&i), i + 22u); + assert_eq!(map[i], i + 22u); } } @@ -38,8 +38,8 @@ fn main() { } else { args.into_iter().collect() }; - let max = from_str::(args.get(1).as_slice()).unwrap(); - let rep = from_str::(args.get(2).as_slice()).unwrap(); + let max = from_str::(args[1].as_slice()).unwrap(); + let rep = from_str::(args[2].as_slice()).unwrap(); let mut checkf = 0.0; let mut appendf = 0.0; diff --git a/src/test/bench/sudoku.rs b/src/test/bench/sudoku.rs index 728f6bd043a26..01c412c6d3195 100644 --- a/src/test/bench/sudoku.rs +++ b/src/test/bench/sudoku.rs @@ -55,8 +55,8 @@ impl Sudoku { pub fn equal(&self, other: &Sudoku) -> bool { for row in range(0u8, 9u8) { for col in range(0u8, 9u8) { - if *self.grid.get(row as uint).get(col as uint) != - *other.grid.get(row as uint).get(col as uint) { + if self.grid[row as uint][col as uint] != + other.grid[row as uint][col as uint] { return false; } } @@ -77,10 +77,10 @@ impl Sudoku { .collect(); if comps.len() == 3u { - let row = from_str::(*comps.get(0)).unwrap() as u8; - let col = from_str::(*comps.get(1)).unwrap() as u8; + let row = from_str::(comps[0]).unwrap() as u8; + let col = from_str::(comps[1]).unwrap() as u8; *g.get_mut(row as uint).get_mut(col as uint) = - from_str::(*comps.get(2)).unwrap() as u8; + from_str::(comps[2]).unwrap() as u8; } else { fail!("Invalid sudoku file"); @@ -91,11 +91,9 @@ impl Sudoku { pub fn write(&self, writer: &mut io::Writer) { for row in range(0u8, 9u8) { - write!(writer, "{}", *self.grid.get(row as uint).get(0)); + write!(writer, "{}", self.grid[row as uint][0]); for col in range(1u8, 9u8) { - write!(writer, " {}", *self.grid - .get(row as uint) - .get(col as uint)); + write!(writer, " {}", self.grid[row as uint][col as uint]); } write!(writer, "\n"); } @@ -106,7 +104,7 @@ impl Sudoku { let mut work: Vec<(u8, u8)> = Vec::new(); /* queue of uncolored fields */ for row in range(0u8, 9u8) { for col in range(0u8, 9u8) { - let color = *self.grid.get(row as uint).get(col as uint); + let color = self.grid[row as uint][col as uint]; if color == 0u8 { work.push((row, col)); } @@ -116,9 +114,9 @@ impl Sudoku { let mut ptr = 0u; let end = work.len(); while ptr < end { - let (row, col) = *work.get(ptr); + let (row, col) = work[ptr]; // is there another color to try? - let the_color = *self.grid.get(row as uint).get(col as uint) + + let the_color = self.grid[row as uint][col as uint] + (1 as u8); if self.next_color(row, col, the_color) { // yes: advance work list @@ -151,12 +149,10 @@ impl Sudoku { // find colors available in neighbourhood of (row, col) fn drop_colors(&mut self, avail: &mut Colors, row: u8, col: u8) { for idx in range(0u8, 9u8) { - avail.remove(*self.grid - .get(idx as uint) - .get(col as uint)); /* check same column fields */ - avail.remove(*self.grid - .get(row as uint) - .get(idx as uint)); /* check same row fields */ + /* check same column fields */ + avail.remove(self.grid[idx as uint][col as uint]); + /* check same row fields */ + avail.remove(self.grid[row as uint][idx as uint]); } // check same block fields @@ -164,9 +160,7 @@ impl Sudoku { let col0 = (col / 3u8) * 3u8; for alt_row in range(row0, row0 + 3u8) { for alt_col in range(col0, col0 + 3u8) { - avail.remove(*self.grid - .get(alt_row as uint) - .get(alt_col as uint)); + avail.remove(self.grid[alt_row as uint][alt_col as uint]); } } } diff --git a/src/test/bench/task-perf-alloc-unwind.rs b/src/test/bench/task-perf-alloc-unwind.rs index a86b797544a30..bdeee5fb6e0bf 100644 --- a/src/test/bench/task-perf-alloc-unwind.rs +++ b/src/test/bench/task-perf-alloc-unwind.rs @@ -78,21 +78,22 @@ fn recurse_or_fail(depth: int, st: Option) { let depth = depth - 1; let st = match st { - None => { - State { - unique: box Nil, - vec: vec!(box Nil), - res: r(box Nil) + None => { + State { + unique: box Nil, + vec: vec!(box Nil), + res: r(box Nil) + } } - } - Some(st) => { - State { - unique: box Cons((), box *st.unique), - vec: st.vec.clone().append( - &[box Cons((), st.vec.last().unwrap().clone())]), - res: r(box Cons((), st.res._l.clone())) + Some(st) => { + let mut v = st.vec.clone(); + v.push_all(&[box Cons((), st.vec.last().unwrap().clone())]); + State { + unique: box Cons((), box *st.unique), + vec: v, + res: r(box Cons((), st.res._l.clone())), + } } - } }; recurse_or_fail(depth, Some(st)); diff --git a/src/test/bench/task-perf-jargon-metal-smoke.rs b/src/test/bench/task-perf-jargon-metal-smoke.rs index 17e1ad423f9cc..9ebdbf0682d79 100644 --- a/src/test/bench/task-perf-jargon-metal-smoke.rs +++ b/src/test/bench/task-perf-jargon-metal-smoke.rs @@ -49,7 +49,7 @@ fn main() { }; let (tx, rx) = channel(); - child_generation(from_str::(args.get(1).as_slice()).unwrap(), tx); + child_generation(from_str::(args[1].as_slice()).unwrap(), tx); if rx.recv_opt().is_err() { fail!("it happened when we slumbered"); } diff --git a/src/test/bench/task-perf-spawnalot.rs b/src/test/bench/task-perf-spawnalot.rs index a871ac989f3fa..533005b1fb38c 100644 --- a/src/test/bench/task-perf-spawnalot.rs +++ b/src/test/bench/task-perf-spawnalot.rs @@ -31,7 +31,7 @@ fn main() { } else { args.into_iter().collect() }; - let n = from_str::(args.get(1).as_slice()).unwrap(); + let n = from_str::(args[1].as_slice()).unwrap(); let mut i = 0u; while i < n { task::spawn(proc() f(n) ); i += 1u; } } diff --git a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-bad-len.rs b/src/test/compile-fail-fulldeps/syntax-extension-fourcc-bad-len.rs deleted file mode 100644 index 3ad17618fc0b3..0000000000000 --- a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-bad-len.rs +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate fourcc; - -fn main() { - let val = fourcc!("foo"); //~ ERROR string literal with len != 4 in fourcc! - let val2 = fourcc!("fooba"); //~ ERROR string literal with len != 4 in fourcc! -} diff --git a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-invalid-endian.rs b/src/test/compile-fail-fulldeps/syntax-extension-fourcc-invalid-endian.rs deleted file mode 100644 index 4d425d9a2056a..0000000000000 --- a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-invalid-endian.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate fourcc; - -fn main() { - let val = fourcc!("foo ", bork); //~ ERROR invalid endian directive in fourcc! -} diff --git a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-ascii-str.rs b/src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-ascii-str.rs deleted file mode 100644 index 1a6d747c1e836..0000000000000 --- a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-ascii-str.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate fourcc; - -fn main() { - let v = fourcc!("fooλ"); //~ ERROR fourcc! literal character out of range 0-255 -} diff --git a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-literal.rs b/src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-literal.rs deleted file mode 100644 index 885d8dd1ec326..0000000000000 --- a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-non-literal.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate fourcc; - -fn main() { - let val = fourcc!(foo); //~ ERROR non-literal in fourcc! -} diff --git a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-unsupported-literal.rs b/src/test/compile-fail-fulldeps/syntax-extension-fourcc-unsupported-literal.rs deleted file mode 100644 index da1c007071568..0000000000000 --- a/src/test/compile-fail-fulldeps/syntax-extension-fourcc-unsupported-literal.rs +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate fourcc; - -fn main() { - let val = fourcc!(45f32); //~ ERROR unsupported literal in fourcc! -} diff --git a/src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-lits.rs b/src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-lits.rs deleted file mode 100644 index 191042f5f5639..0000000000000 --- a/src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-lits.rs +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate hexfloat; - -fn main() { - hexfloat!("foo"); - //~^ ERROR invalid hex float literal in hexfloat!: Expected '0' - hexfloat!("0"); - //~^ERROR invalid hex float literal in hexfloat!: Expected 'x' - hexfloat!("0x"); - //~^ERROR invalid hex float literal in hexfloat!: Expected '.' - hexfloat!("0x."); - //~^ERROR invalid hex float literal in hexfloat!: Expected digits before or after decimal point - hexfloat!("0x0.0"); - //~^ERROR invalid hex float literal in hexfloat!: Expected 'p' - hexfloat!("0x0.0p"); - //~^ERROR invalid hex float literal in hexfloat!: Expected exponent digits - hexfloat!("0x0.0p0f"); - //~^ERROR invalid hex float literal in hexfloat!: Expected end of string -} diff --git a/src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-types.rs b/src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-types.rs deleted file mode 100644 index f0ace43ec9e8d..0000000000000 --- a/src/test/compile-fail-fulldeps/syntax-extension-hexfloat-bad-types.rs +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate hexfloat; - -fn main() { - hexfloat!(foo); - //~^ ERROR non-literal in hexfloat! - hexfloat!(0); - //~^ ERROR unsupported literal in hexfloat! - hexfloat!("0x0.p0", invalid); - //~^ ERROR invalid floating point type in hexfloat! -} diff --git a/src/test/compile-fail/borrowck-assign-comp-idx.rs b/src/test/compile-fail/borrowck-assign-comp-idx.rs index 143ebdaa77399..5bc2edba30134 100644 --- a/src/test/compile-fail/borrowck-assign-comp-idx.rs +++ b/src/test/compile-fail/borrowck-assign-comp-idx.rs @@ -17,7 +17,7 @@ fn a() { let mut p = vec!(1); // Create an immutable pointer into p's contents: - let q: &int = p.get(0); + let q: &int = &p[0]; *p.get_mut(0) = 5; //~ ERROR cannot borrow diff --git a/src/test/compile-fail/borrowck-loan-vec-content.rs b/src/test/compile-fail/borrowck-loan-vec-content.rs index 393b528869a94..31b5c44df6663 100644 --- a/src/test/compile-fail/borrowck-loan-vec-content.rs +++ b/src/test/compile-fail/borrowck-loan-vec-content.rs @@ -18,13 +18,13 @@ fn takes_imm_elt(_v: &int, f: ||) { fn has_mut_vec_and_does_not_try_to_change_it() { let mut v = vec!(1, 2, 3); - takes_imm_elt(v.get(0), || {}) + takes_imm_elt(&v[0], || {}) } fn has_mut_vec_but_tries_to_change_it() { let mut v = vec!(1, 2, 3); takes_imm_elt( - v.get(0), + &v[0], || { //~ ERROR cannot borrow `v` as mutable *v.get_mut(1) = 4; }) diff --git a/src/test/compile-fail/borrowck-overloaded-index-2.rs b/src/test/compile-fail/borrowck-overloaded-index-2.rs index 6d2eae8bc1e12..d9d7a43d46c41 100644 --- a/src/test/compile-fail/borrowck-overloaded-index-2.rs +++ b/src/test/compile-fail/borrowck-overloaded-index-2.rs @@ -14,7 +14,7 @@ struct MyVec { impl Index for MyVec { fn index(&self, &i: &uint) -> &T { - self.data.get(i) + &self.data[i] } } diff --git a/src/test/compile-fail/deprecated-url.rs b/src/test/compile-fail/deprecated-url.rs deleted file mode 100644 index 9f1c1fdd7c79e..0000000000000 --- a/src/test/compile-fail/deprecated-url.rs +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-tidy-linelength - -#![deny(deprecated)] - -extern crate url; - -fn main() { - let _ = url::Url::parse("http://example.com"); - //~^ ERROR use of deprecated item: This is being removed. Use rust-url instead. http://servo.github.io/rust-url/ -} diff --git a/src/test/compile-fail/lub-if.rs b/src/test/compile-fail/lub-if.rs index 5440219e55eb9..6dcf1fdee8302 100644 --- a/src/test/compile-fail/lub-if.rs +++ b/src/test/compile-fail/lub-if.rs @@ -16,14 +16,14 @@ pub fn opt_str0<'a>(maybestr: &'a Option) -> &'a str { if maybestr.is_none() { "(none)" } else { - let s: &'a str = maybestr.get_ref().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap().as_slice(); s } } pub fn opt_str1<'a>(maybestr: &'a Option) -> &'a str { if maybestr.is_some() { - let s: &'a str = maybestr.get_ref().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap().as_slice(); s } else { "(none)" @@ -34,14 +34,14 @@ pub fn opt_str2<'a>(maybestr: &'a Option) -> &'static str { if maybestr.is_none() { "(none)" } else { - let s: &'a str = maybestr.get_ref().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap().as_slice(); s //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to conflicting } } pub fn opt_str3<'a>(maybestr: &'a Option) -> &'static str { if maybestr.is_some() { - let s: &'a str = maybestr.get_ref().as_slice(); + let s: &'a str = maybestr.as_ref().unwrap().as_slice(); s //~ ERROR cannot infer an appropriate lifetime for automatic coercion due to conflicting } else { "(none)" diff --git a/src/test/compile-fail/moves-based-on-type-access-to-field.rs b/src/test/compile-fail/moves-based-on-type-access-to-field.rs index 8572393699719..c9efce0d68478 100644 --- a/src/test/compile-fail/moves-based-on-type-access-to-field.rs +++ b/src/test/compile-fail/moves-based-on-type-access-to-field.rs @@ -18,7 +18,7 @@ fn touch(_a: &A) {} fn f20() { let x = vec!("hi".to_string()); consume(x.into_iter().next().unwrap()); - touch(x.get(0)); //~ ERROR use of moved value: `x` + touch(&x[0]); //~ ERROR use of moved value: `x` } fn main() {} diff --git a/src/test/compile-fail/moves-based-on-type-exprs.rs b/src/test/compile-fail/moves-based-on-type-exprs.rs index 330fd9f1ff0a2..1d6dc504ab43b 100644 --- a/src/test/compile-fail/moves-based-on-type-exprs.rs +++ b/src/test/compile-fail/moves-based-on-type-exprs.rs @@ -30,7 +30,7 @@ fn f20() { fn f21() { let x = vec!(1i, 2, 3); - let _y = (*x.get(0), 3i); + let _y = (x[0], 3i); touch(&x); } @@ -96,8 +96,8 @@ fn f110() { fn f120() { let mut x = vec!("hi".to_string(), "ho".to_string()); x.as_mut_slice().swap(0, 1); - touch(x.get(0)); - touch(x.get(1)); + touch(&x[0]); + touch(&x[1]); } fn main() {} diff --git a/src/test/compile-fail/no-capture-arc.rs b/src/test/compile-fail/no-capture-arc.rs index ec218768a98ee..a07317176e410 100644 --- a/src/test/compile-fail/no-capture-arc.rs +++ b/src/test/compile-fail/no-capture-arc.rs @@ -18,10 +18,10 @@ fn main() { let arc_v = Arc::new(v); task::spawn(proc() { - assert_eq!(*arc_v.get(3), 4); + assert_eq!((*arc_v)[3], 4); }); - assert_eq!(*arc_v.get(2), 3); + assert_eq!((*arc_v)[2], 3); println!("{}", *arc_v); } diff --git a/src/test/compile-fail/no-reuse-move-arc.rs b/src/test/compile-fail/no-reuse-move-arc.rs index b8009031883c6..9f33f35838e27 100644 --- a/src/test/compile-fail/no-reuse-move-arc.rs +++ b/src/test/compile-fail/no-reuse-move-arc.rs @@ -16,10 +16,10 @@ fn main() { let arc_v = Arc::new(v); task::spawn(proc() { - assert_eq!(*arc_v.get(3), 4); + assert_eq!((*arc_v)[3], 4); }); - assert_eq!(*arc_v.get(2), 3); //~ ERROR use of moved value: `arc_v` + assert_eq!((*arc_v)[2], 3); //~ ERROR use of moved value: `arc_v` println!("{}", *arc_v); //~ ERROR use of moved value: `arc_v` } diff --git a/src/test/compile-fail/ufcs-explicit-self-bad.rs b/src/test/compile-fail/ufcs-explicit-self-bad.rs index e5bad7e31b81e..b639af617574c 100644 --- a/src/test/compile-fail/ufcs-explicit-self-bad.rs +++ b/src/test/compile-fail/ufcs-explicit-self-bad.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::owned::Box; - struct Foo { f: int, } diff --git a/src/test/compile-fail/unresolved-extern-mod-suggestion.rs b/src/test/compile-fail/unresolved-extern-mod-suggestion.rs index 62066eb29d0bf..33d3deb8733d5 100644 --- a/src/test/compile-fail/unresolved-extern-mod-suggestion.rs +++ b/src/test/compile-fail/unresolved-extern-mod-suggestion.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -extern crate url; -use url; //~ ERROR unresolved import (maybe you meant `url::*`?) +extern crate core; +use core; //~ ERROR unresolved import (maybe you meant `core::*`?) fn main() {} diff --git a/src/test/compile-fail/writing-to-immutable-vec.rs b/src/test/compile-fail/writing-to-immutable-vec.rs index ab00a8a01e0a6..13eb6f860ba43 100644 --- a/src/test/compile-fail/writing-to-immutable-vec.rs +++ b/src/test/compile-fail/writing-to-immutable-vec.rs @@ -11,5 +11,5 @@ fn main() { let v: Vec = vec!(1, 2, 3); - *v.get(1) = 4; //~ ERROR cannot assign + v[1] = 4; //~ ERROR cannot assign } diff --git a/src/test/run-fail/bug-2470-bounds-check-overflow.rs b/src/test/run-fail/bug-2470-bounds-check-overflow.rs index 0e116bcede549..9123342f09a5c 100644 --- a/src/test/run-fail/bug-2470-bounds-check-overflow.rs +++ b/src/test/run-fail/bug-2470-bounds-check-overflow.rs @@ -31,5 +31,5 @@ fn main() { idx * mem::size_of::()); // This should fail. - println!("ov1 0x{:x}", *x.get(idx)); + println!("ov1 0x{:x}", x[idx]); } diff --git a/src/test/run-fail/glob-use-std.rs b/src/test/run-fail/glob-use-std.rs index bee60cd120584..bf04789bbc773 100644 --- a/src/test/run-fail/glob-use-std.rs +++ b/src/test/run-fail/glob-use-std.rs @@ -20,7 +20,5 @@ use std::*; fn main() { - String::from_byte(b'a'); // avoid an unused import message - fail!("fail works") } diff --git a/src/test/run-fail/issue-3029.rs b/src/test/run-fail/issue-3029.rs index 80e275019ce24..539d2adc7d45c 100644 --- a/src/test/run-fail/issue-3029.rs +++ b/src/test/run-fail/issue-3029.rs @@ -18,5 +18,5 @@ fn main() { let mut x = Vec::new(); let y = vec!(3i); fail!("so long"); - x.push_all_move(y); + x.extend(y.into_iter()); } diff --git a/src/test/run-fail/vec-overrun.rs b/src/test/run-fail/vec-overrun.rs index 40ffe15fe867a..281523a807ef8 100644 --- a/src/test/run-fail/vec-overrun.rs +++ b/src/test/run-fail/vec-overrun.rs @@ -14,8 +14,8 @@ fn main() { let v: Vec = vec!(10); let x: uint = 0; - assert_eq!(*v.get(x), 10); + assert_eq!(v[x], 10); // Bounds-check failure. - assert_eq!(*v.get(x + 2), 20); + assert_eq!(v[x + 2], 20); } diff --git a/src/test/run-make/bootstrap-from-c-with-native/lib.rs b/src/test/run-make/bootstrap-from-c-with-native/lib.rs index d211167626d77..99dd473344a2b 100644 --- a/src/test/run-make/bootstrap-from-c-with-native/lib.rs +++ b/src/test/run-make/bootstrap-from-c-with-native/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="boot#0.1"] +#![crate_name="boot"] #![crate_type="dylib"] extern crate native; diff --git a/src/test/run-make/dep-info-custom/lib.rs b/src/test/run-make/dep-info-custom/lib.rs index 4255b1d934d9c..14baa8ca55a39 100644 --- a/src/test/run-make/dep-info-custom/lib.rs +++ b/src/test/run-make/dep-info-custom/lib.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="foo#0.1"] +#![crate_name="foo"] pub mod foo; pub mod bar; diff --git a/src/test/run-make/libs-through-symlinks/foo.rs b/src/test/run-make/libs-through-symlinks/foo.rs index 6864076d18e27..dd818cf87986d 100644 --- a/src/test/run-make/libs-through-symlinks/foo.rs +++ b/src/test/run-make/libs-through-symlinks/foo.rs @@ -9,4 +9,4 @@ // except according to those terms. #![crate_type = "rlib"] -#![crate_id = "foo"] +#![crate_name = "foo"] diff --git a/src/test/run-make/lto-syntax-extension/main.rs b/src/test/run-make/lto-syntax-extension/main.rs index ec4fbca48f8de..0f6bd10b15d3f 100644 --- a/src/test/run-make/lto-syntax-extension/main.rs +++ b/src/test/run-make/lto-syntax-extension/main.rs @@ -11,8 +11,9 @@ #![feature(phase)] extern crate lib; -#[phase(plugin)] extern crate fourcc; +extern crate regex; +#[phase(plugin)] extern crate regex_macros; fn main() { - fourcc!("1234"); + regex!("1234"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateA1.rs b/src/test/run-make/many-crates-but-no-match/crateA1.rs index 0c88cf4745a00..dbfe920c85ba3 100644 --- a/src/test/run-make/many-crates-but-no-match/crateA1.rs +++ b/src/test/run-make/many-crates-but-no-match/crateA1.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateA"] +#![crate_name="crateA"] // Base crate pub fn func() {} diff --git a/src/test/run-make/many-crates-but-no-match/crateA2.rs b/src/test/run-make/many-crates-but-no-match/crateA2.rs index e3fb50e13d0eb..857c36aee6025 100644 --- a/src/test/run-make/many-crates-but-no-match/crateA2.rs +++ b/src/test/run-make/many-crates-but-no-match/crateA2.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateA"] +#![crate_name="crateA"] // Base crate pub fn func() { println!("hello"); } diff --git a/src/test/run-make/many-crates-but-no-match/crateA3.rs b/src/test/run-make/many-crates-but-no-match/crateA3.rs index ad9d458be242d..8b8dac5e862a1 100644 --- a/src/test/run-make/many-crates-but-no-match/crateA3.rs +++ b/src/test/run-make/many-crates-but-no-match/crateA3.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="crateA"] +#![crate_name="crateA"] // Base crate pub fn foo() { println!("world!"); } diff --git a/src/test/run-make/rustdoc-hidden-line/foo.rs b/src/test/run-make/rustdoc-hidden-line/foo.rs index 26546cef0f061..c402da7987d5a 100644 --- a/src/test/run-make/rustdoc-hidden-line/foo.rs +++ b/src/test/run-make/rustdoc-hidden-line/foo.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id="foo#0.1"] +#![crate_name="foo"] /// The '# ' lines should be removed from the output, but the #[deriving] should be /// retained. diff --git a/src/test/run-make/rustdoc-json/foo.rs b/src/test/run-make/rustdoc-json/foo.rs index dda66f051bc8e..d57a7164cdbce 100644 --- a/src/test/run-make/rustdoc-json/foo.rs +++ b/src/test/run-make/rustdoc-json/foo.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "foo#0.1"] +#![crate_name = "foo"] //! Very docs diff --git a/src/test/run-make/rustdoc-smoke/foo.rs b/src/test/run-make/rustdoc-smoke/foo.rs index b783dd39a061a..499bcaff4d184 100644 --- a/src/test/run-make/rustdoc-smoke/foo.rs +++ b/src/test/run-make/rustdoc-smoke/foo.rs @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#![crate_id = "foo#0.1"] +#![crate_name = "foo"] //! Very docs diff --git a/src/test/run-make/unicode-input/multiple_files.rs b/src/test/run-make/unicode-input/multiple_files.rs index 7c6d97dd5a317..2aa4264225c96 100644 --- a/src/test/run-make/unicode-input/multiple_files.rs +++ b/src/test/run-make/unicode-input/multiple_files.rs @@ -34,8 +34,8 @@ fn random_char() -> char { fn main() { let args = os::args(); - let rustc = args.get(1).as_slice(); - let tmpdir = Path::new(args.get(2).as_slice()); + let rustc = args[1].as_slice(); + let tmpdir = Path::new(args[2].as_slice()); let main_file = tmpdir.join("unicode_input_multiple_files_main.rs"); { diff --git a/src/test/run-make/unicode-input/span_length.rs b/src/test/run-make/unicode-input/span_length.rs index e213e26654842..7b096d7d583a5 100644 --- a/src/test/run-make/unicode-input/span_length.rs +++ b/src/test/run-make/unicode-input/span_length.rs @@ -33,8 +33,8 @@ fn random_char() -> char { fn main() { let args = os::args(); - let rustc = args.get(1).as_slice(); - let tmpdir = Path::new(args.get(2).as_slice()); + let rustc = args[1].as_slice(); + let tmpdir = Path::new(args[2].as_slice()); let main_file = tmpdir.join("span_main.rs"); for _ in range(0u, 100) { diff --git a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs b/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs deleted file mode 100644 index b16975fe6eea7..0000000000000 --- a/src/test/run-pass-fulldeps/syntax-extension-fourcc.rs +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] - -#[phase(plugin)] -extern crate fourcc; - -static static_val: u32 = fourcc!("foo "); -static static_val_be: u32 = fourcc!("foo ", big); -static static_val_le: u32 = fourcc!("foo ", little); -static static_val_target: u32 = fourcc!("foo ", target); - -fn main() { - let val = fourcc!("foo ", big); - assert_eq!(val, 0x666f6f20u32); - assert_eq!(val, fourcc!("foo ")); - - let val = fourcc!("foo ", little); - assert_eq!(val, 0x206f6f66u32); - - let val = fourcc!("foo ", target); - let exp = if cfg!(target_endian = "big") { 0x666f6f20u32 } else { 0x206f6f66u32 }; - assert_eq!(val, exp); - - assert_eq!(static_val_be, 0x666f6f20u32); - assert_eq!(static_val, static_val_be); - assert_eq!(static_val_le, 0x206f6f66u32); - let exp = if cfg!(target_endian = "big") { 0x666f6f20u32 } else { 0x206f6f66u32 }; - assert_eq!(static_val_target, exp); - - assert_eq!(fourcc!("\xC0\xFF\xEE!"), 0xC0FFEE21); -} diff --git a/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs b/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs deleted file mode 100644 index 820606179bc1e..0000000000000 --- a/src/test/run-pass-fulldeps/syntax-extension-hexfloat.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright 2014 The Rust Project Developers. See the COPYRIGHT -// file at the top-level directory of this distribution and at -// http://rust-lang.org/COPYRIGHT. -// -// Licensed under the Apache License, Version 2.0 or the MIT license -// , at your -// option. This file may not be copied, modified, or distributed -// except according to those terms. - -// ignore-stage1 -// ignore-pretty - -#![feature(phase)] -#[phase(plugin)] -extern crate hexfloat; - -pub fn main() { - let a = hexfloat!("0x1.999999999999ap-4"); - assert_eq!(a, 0.1f64); - let b = hexfloat!("-0x1.fffp-4", f32); - assert_eq!(b, -0.12498474_f32); - let c = hexfloat!("0x.12345p5", f64); - let d = hexfloat!("0x0.12345p5", f64); - assert_eq!(c,d); - let f = hexfloat!("0x10.p4", f32); - let g = hexfloat!("0x10.0p4", f32); - assert_eq!(f,g); -} diff --git a/src/test/run-pass/assignability-trait.rs b/src/test/run-pass/assignability-trait.rs index 1ffee6aad7603..0d90636ec9140 100644 --- a/src/test/run-pass/assignability-trait.rs +++ b/src/test/run-pass/assignability-trait.rs @@ -41,7 +41,7 @@ fn length>(x: T) -> uint { pub fn main() { let x: Vec = vec!(0,1,2,3); // Call a method - x.iterate(|y| { assert!(*x.get(*y as uint) == *y); true }); + x.iterate(|y| { assert!(x[*y as uint] == *y); true }); // Call a parameterized function assert_eq!(length(x.clone()), x.len()); // Call a parameterized function, with type arguments that require diff --git a/src/test/run-pass/bare-fn-implements-fn-mut.rs b/src/test/run-pass/bare-fn-implements-fn-mut.rs index 37c551734defb..4962e9d0f2259 100644 --- a/src/test/run-pass/bare-fn-implements-fn-mut.rs +++ b/src/test/run-pass/bare-fn-implements-fn-mut.rs @@ -25,8 +25,9 @@ fn call_g>(mut g: G, x: String, y: String) g(x, y) } -fn g(x: String, y: String) -> String { - x.append(y.as_slice()) +fn g(mut x: String, y: String) -> String { + x.push_str(y.as_slice()); + x } fn main() { diff --git a/src/test/run-pass/borrowck-mut-uniq.rs b/src/test/run-pass/borrowck-mut-uniq.rs index 867fdd531e95f..e644c49366d44 100644 --- a/src/test/run-pass/borrowck-mut-uniq.rs +++ b/src/test/run-pass/borrowck-mut-uniq.rs @@ -23,7 +23,7 @@ fn add_int(x: &mut Ints, v: int) { fn iter_ints(x: &Ints, f: |x: &int| -> bool) -> bool { let l = x.values.len(); - range(0u, l).all(|i| f(x.values.get(i))) + range(0u, l).all(|i| f(&x.values[i])) } pub fn main() { diff --git a/src/test/run-pass/call-closure-from-overloaded-op.rs b/src/test/run-pass/call-closure-from-overloaded-op.rs index bf2423167571d..432d022c69b77 100644 --- a/src/test/run-pass/call-closure-from-overloaded-op.rs +++ b/src/test/run-pass/call-closure-from-overloaded-op.rs @@ -14,5 +14,5 @@ fn foo() -> int { 22 } pub fn main() { let mut x: Vec int> = Vec::new(); x.push(foo); - assert_eq!((*x.get(0))(), 22); + assert_eq!((x[0])(), 22); } diff --git a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs index ad7d818bd3bb7..646eed5de7537 100644 --- a/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs +++ b/src/test/run-pass/coerce-reborrow-imm-vec-rcvr.rs @@ -10,11 +10,11 @@ fn bar(v: &mut [uint]) -> Vec { - Vec::from_slice(v) + v.to_vec() } fn bip(v: &[uint]) -> Vec { - Vec::from_slice(v) + v.to_vec() } pub fn main() { diff --git a/src/test/run-pass/drop-with-type-ascription-1.rs b/src/test/run-pass/drop-with-type-ascription-1.rs index c4ea169cb797a..8c0c0afa94ba7 100644 --- a/src/test/run-pass/drop-with-type-ascription-1.rs +++ b/src/test/run-pass/drop-with-type-ascription-1.rs @@ -11,7 +11,7 @@ fn main() { let foo = "hello".to_string(); let foo: Vec<&str> = foo.as_slice().words().collect(); - let invalid_string = foo.get(0); + let invalid_string = &foo[0]; assert_eq!(*invalid_string, "hello"); } diff --git a/src/test/run-pass/drop-with-type-ascription-2.rs b/src/test/run-pass/drop-with-type-ascription-2.rs index 634b1004e5308..f55f47bbc59de 100644 --- a/src/test/run-pass/drop-with-type-ascription-2.rs +++ b/src/test/run-pass/drop-with-type-ascription-2.rs @@ -10,8 +10,8 @@ fn main() { let args = vec!("foobie", "asdf::asdf"); - let arr: Vec<&str> = args.get(1).as_slice().split_str("::").collect(); - assert_eq!(*arr.get(0), "asdf"); - assert_eq!(*arr.get(0), "asdf"); + let arr: Vec<&str> = args[1].as_slice().split_str("::").collect(); + assert_eq!(arr[0], "asdf"); + assert_eq!(arr[0], "asdf"); } diff --git a/src/test/run-pass/expr-fn.rs b/src/test/run-pass/expr-fn.rs index fc2912c184fef..8172c16abf2a6 100644 --- a/src/test/run-pass/expr-fn.rs +++ b/src/test/run-pass/expr-fn.rs @@ -17,7 +17,7 @@ fn test_int() { fn test_vec() { fn f() -> Vec { vec!(10, 11) } let vect = f(); - assert_eq!(*vect.get(1), 11); + assert_eq!(vect[1], 11); } fn test_generic() { diff --git a/src/test/run-pass/expr-match-fail.rs b/src/test/run-pass/expr-match-fail.rs index 872701e33eef1..1f246581687b1 100644 --- a/src/test/run-pass/expr-match-fail.rs +++ b/src/test/run-pass/expr-match-fail.rs @@ -16,7 +16,7 @@ fn test_simple() { fn test_box() { let r = match true { true => { vec!(10i) } false => { fail!() } }; - assert_eq!(*r.get(0), 10i); + assert_eq!(r[0], 10i); } pub fn main() { test_simple(); test_box(); } diff --git a/src/test/run-pass/foreach-nested.rs b/src/test/run-pass/foreach-nested.rs index 357d1201a4cbb..af6ca3c93d5cf 100644 --- a/src/test/run-pass/foreach-nested.rs +++ b/src/test/run-pass/foreach-nested.rs @@ -17,8 +17,8 @@ pub fn main() { two(|i| { two(|j| { *a.get_mut(p as uint) = 10 * i + j; p += 1; }) }); - assert_eq!(*a.get(0), 0); - assert_eq!(*a.get(1), 1); - assert_eq!(*a.get(2), 10); - assert_eq!(*a.get(3), 11); + assert_eq!(a[0], 0); + assert_eq!(a[1], 1); + assert_eq!(a[2], 10); + assert_eq!(a[3], 11); } diff --git a/src/test/run-pass/hashmap-memory.rs b/src/test/run-pass/hashmap-memory.rs index 8ff89ae2cde26..87afd1601f6bd 100644 --- a/src/test/run-pass/hashmap-memory.rs +++ b/src/test/run-pass/hashmap-memory.rs @@ -52,7 +52,7 @@ mod map_reduce { } let (tx, rx) = channel(); println!("sending find_reducer"); - ctrl.send(find_reducer(Vec::from_slice(key.as_bytes()), tx)); + ctrl.send(find_reducer(key.as_bytes().to_vec(), tx)); println!("receiving"); let c = rx.recv(); println!("{}", c); diff --git a/src/test/run-pass/issue-13304.rs b/src/test/run-pass/issue-13304.rs index c868189197e0a..047ff74035b0f 100644 --- a/src/test/run-pass/issue-13304.rs +++ b/src/test/run-pass/issue-13304.rs @@ -29,7 +29,7 @@ fn parent() { let args = args.as_slice(); let mut p = io::process::Command::new(args[0].as_slice()) .arg("child").spawn().unwrap(); - p.stdin.get_mut_ref().write_str("test1\ntest2\ntest3").unwrap(); + p.stdin.as_mut().unwrap().write_str("test1\ntest2\ntest3").unwrap(); let out = p.wait_with_output().unwrap(); assert!(out.status.success()); let s = str::from_utf8(out.output.as_slice()).unwrap(); diff --git a/src/test/run-pass/issue-14021.rs b/src/test/run-pass/issue-14021.rs index f25a1fcdab6f2..a55cded87e51d 100644 --- a/src/test/run-pass/issue-14021.rs +++ b/src/test/run-pass/issue-14021.rs @@ -19,7 +19,7 @@ struct UnitLikeStruct; pub fn main() { let obj = UnitLikeStruct; - let json_str: String = json::Encoder::str_encode(&obj); + let json_str: String = json::encode(&obj); let json_object = json::from_str(json_str.as_slice()); let mut decoder = json::Decoder::new(json_object.unwrap()); diff --git a/src/test/run-pass/issue-14456.rs b/src/test/run-pass/issue-14456.rs index bee4baf68a03d..2339e3f63029a 100644 --- a/src/test/run-pass/issue-14456.rs +++ b/src/test/run-pass/issue-14456.rs @@ -16,7 +16,7 @@ use std::os; fn main() { let args = os::args(); - if args.len() > 1 && args.get(1).as_slice() == "child" { + if args.len() > 1 && args[1].as_slice() == "child" { return child() } @@ -32,7 +32,7 @@ fn child() { fn test() { let args = os::args(); - let mut p = Command::new(args.get(0).as_slice()).arg("child") + let mut p = Command::new(args[0].as_slice()).arg("child") .stdin(process::Ignored) .stdout(process::Ignored) .stderr(process::Ignored) diff --git a/src/test/run-pass/issue-14940.rs b/src/test/run-pass/issue-14940.rs index e0a63331e9717..acadc81df6306 100644 --- a/src/test/run-pass/issue-14940.rs +++ b/src/test/run-pass/issue-14940.rs @@ -17,7 +17,7 @@ fn main() { let mut out = stdio::stdout(); out.write(['a' as u8, ..128 * 1024]).unwrap(); } else { - let out = Command::new(args.get(0).as_slice()).arg("child").output(); + let out = Command::new(args[0].as_slice()).arg("child").output(); let out = out.unwrap(); assert!(out.status.success()); } diff --git a/src/test/run-pass/issue-15149.rs b/src/test/run-pass/issue-15149.rs index cc80232691d1d..1fb17d4d5fa85 100644 --- a/src/test/run-pass/issue-15149.rs +++ b/src/test/run-pass/issue-15149.rs @@ -15,8 +15,8 @@ use std::task::TaskBuilder; fn main() { // If we're the child, make sure we were invoked correctly let args = os::args(); - if args.len() > 1 && args.get(1).as_slice() == "child" { - return assert_eq!(args.get(0).as_slice(), "mytest"); + if args.len() > 1 && args[1].as_slice() == "child" { + return assert_eq!(args[0].as_slice(), "mytest"); } test(); diff --git a/src/test/run-pass/issue-15189.rs b/src/test/run-pass/issue-15189.rs index abf8b6dbbea49..16212b5f52995 100644 --- a/src/test/run-pass/issue-15189.rs +++ b/src/test/run-pass/issue-15189.rs @@ -12,7 +12,7 @@ #![feature(macro_rules)] -macro_rules! third(($e:expr)=>({let x = 2; *$e.get(x)})) +macro_rules! third(($e:expr)=>({let x = 2; $e[x]})) fn main() { let x = vec!(10u,11u,12u,13u); diff --git a/src/test/run-pass/issue-17216.rs b/src/test/run-pass/issue-17216.rs index 538b837d11731..e48d7b0756c2c 100644 --- a/src/test/run-pass/issue-17216.rs +++ b/src/test/run-pass/issue-17216.rs @@ -25,7 +25,7 @@ fn main() { let mut dropped = false; { let leak = Leak { dropped: &mut dropped }; - for ((), leaked) in Some(((),leak)).move_iter() {} + for ((), leaked) in Some(((),leak)).into_iter() {} } assert!(dropped); diff --git a/src/test/run-pass/issue-2383.rs b/src/test/run-pass/issue-2383.rs index 41cf3eaf7e31a..9a00868cc1259 100644 --- a/src/test/run-pass/issue-2383.rs +++ b/src/test/run-pass/issue-2383.rs @@ -15,5 +15,5 @@ use std::collections::Deque; pub fn main() { let mut q = RingBuf::new(); - q.push_back(10i); + q.push(10i); } diff --git a/src/test/run-pass/issue-2804-2.rs b/src/test/run-pass/issue-2804-2.rs index 32fefac52ebeb..952ea1e9d3de7 100644 --- a/src/test/run-pass/issue-2804-2.rs +++ b/src/test/run-pass/issue-2804-2.rs @@ -17,7 +17,7 @@ extern crate collections; use std::collections::HashMap; fn add_interfaces(managed_ip: String, device: HashMap) { - println!("{}, {}", managed_ip, device.get(&"interfaces".to_string())); + println!("{}, {}", managed_ip, device["interfaces".to_string()]); } pub fn main() {} diff --git a/src/test/run-pass/issue-2804.rs b/src/test/run-pass/issue-2804.rs index 7228f12c030a1..62104f2dc232e 100644 --- a/src/test/run-pass/issue-2804.rs +++ b/src/test/run-pass/issue-2804.rs @@ -57,9 +57,9 @@ fn add_interface(_store: int, managed_ip: String, data: json::Json) -> (String, fn add_interfaces(store: int, managed_ip: String, device: HashMap) -> Vec<(String, object)> { - match device.get(&"interfaces".to_string()) + match device["interfaces".to_string()] { - &json::List(ref interfaces) => + json::List(ref interfaces) => { interfaces.iter().map(|interface| { add_interface(store, managed_ip.clone(), (*interface).clone()) @@ -68,7 +68,7 @@ fn add_interfaces(store: int, managed_ip: String, device: HashMap { println!("Expected list for {} interfaces, found {}", managed_ip, - device.get(&"interfaces".to_string())); + device["interfaces".to_string()]); Vec::new() } } diff --git a/src/test/run-pass/issue-2904.rs b/src/test/run-pass/issue-2904.rs index 01bfdddd28570..1964001cebd8e 100644 --- a/src/test/run-pass/issue-2904.rs +++ b/src/test/run-pass/issue-2904.rs @@ -69,7 +69,7 @@ fn read_board_grid(mut input: rdr) row.push(square_from_char(*c as char)) } grid.push(row); - let width = grid.get(0).len(); + let width = grid[0].len(); for row in grid.iter() { assert!(row.len() == width) } grid } diff --git a/src/test/run-pass/issue-2989.rs b/src/test/run-pass/issue-2989.rs index c88f8b42d4242..d625f6bcf92fa 100644 --- a/src/test/run-pass/issue-2989.rs +++ b/src/test/run-pass/issue-2989.rs @@ -24,7 +24,7 @@ fn to_bools(bitv: Storage) -> Vec { Vec::from_fn(8, |i| { let w = i / 64; let b = i % 64; - let x = 1u64 & (*bitv.storage.get(w) >> b); + let x = 1u64 & (bitv.storage[w] >> b); x == 1u64 }) } @@ -36,7 +36,7 @@ pub fn main() { let bools2 = to_bools(Storage{storage: vec!(0b01100100)}); for i in range(0u, 8) { - println!("{} => {} vs {}", i, *bools.get(i), *bools2.get(i)); + println!("{} => {} vs {}", i, bools[i], bools2[i]); } assert_eq!(bools, bools2); diff --git a/src/test/run-pass/issue-3609.rs b/src/test/run-pass/issue-3609.rs index 61dd2ea2a05cc..2e0159af98452 100644 --- a/src/test/run-pass/issue-3609.rs +++ b/src/test/run-pass/issue-3609.rs @@ -23,7 +23,7 @@ fn foo(name: String, samples_chan: Sender) { let mut samples_chan = samples_chan; let callback: SamplesFn = proc(buffer) { for i in range(0u, buffer.len()) { - println!("{}: {}", i, *buffer.get(i)) + println!("{}: {}", i, buffer[i]) } }; samples_chan.send(GetSamples(name.clone(), callback)); diff --git a/src/test/run-pass/issue-5521.rs b/src/test/run-pass/issue-5521.rs index 8bf87e7f4839c..be75c7230427b 100644 --- a/src/test/run-pass/issue-5521.rs +++ b/src/test/run-pass/issue-5521.rs @@ -17,7 +17,7 @@ fn bar(a: foo::map) { if false { fail!(); } else { - let _b = a.get(&2); + let _b = &(*a)[2]; } } diff --git a/src/test/run-pass/issue-7660.rs b/src/test/run-pass/issue-7660.rs index 9a4b3bf0e54b0..8a953cea9048d 100644 --- a/src/test/run-pass/issue-7660.rs +++ b/src/test/run-pass/issue-7660.rs @@ -21,6 +21,6 @@ pub fn main() { let mut m: HashMap = HashMap::new(); m.insert(1, A(0, 0)); - let A(ref _a, ref _b) = *m.get(&1); - let (a, b) = match *m.get(&1) { A(ref _a, ref _b) => (_a, _b) }; + let A(ref _a, ref _b) = m[1]; + let (a, b) = match m[1] { A(ref _a, ref _b) => (_a, _b) }; } diff --git a/src/test/run-pass/issue-9259.rs b/src/test/run-pass/issue-9259.rs index 2818b8249692a..0fe520e59d622 100644 --- a/src/test/run-pass/issue-9259.rs +++ b/src/test/run-pass/issue-9259.rs @@ -19,5 +19,5 @@ pub fn main() { a: &["test".to_string()], b: Some(b), }; - assert_eq!(a.b.get_ref()[0].as_slice(), "foo"); + assert_eq!(a.b.as_ref().unwrap()[0].as_slice(), "foo"); } diff --git a/src/test/run-pass/match-vec-rvalue.rs b/src/test/run-pass/match-vec-rvalue.rs index 70c3b386a8ad3..0f058086adde4 100644 --- a/src/test/run-pass/match-vec-rvalue.rs +++ b/src/test/run-pass/match-vec-rvalue.rs @@ -15,9 +15,9 @@ pub fn main() { match vec!(1i, 2i, 3i) { x => { assert_eq!(x.len(), 3); - assert_eq!(*x.get(0), 1); - assert_eq!(*x.get(1), 2); - assert_eq!(*x.get(2), 3); + assert_eq!(x[0], 1); + assert_eq!(x[1], 2); + assert_eq!(x[2], 3); } } } diff --git a/src/test/run-pass/monad.rs b/src/test/run-pass/monad.rs index 783dc32426a65..4f9e573ccff26 100644 --- a/src/test/run-pass/monad.rs +++ b/src/test/run-pass/monad.rs @@ -18,7 +18,7 @@ impl vec_monad for Vec { fn bind(&self, f: |&A| -> Vec ) -> Vec { let mut r = Vec::new(); for elt in self.iter() { - r.push_all_move(f(elt)); + r.extend(f(elt).into_iter()); } r } diff --git a/src/test/run-pass/move-arg-2-unique.rs b/src/test/run-pass/move-arg-2-unique.rs index ac90f8f6ecf4e..29fd070fc19d2 100644 --- a/src/test/run-pass/move-arg-2-unique.rs +++ b/src/test/run-pass/move-arg-2-unique.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn test(foo: Box> ) { assert!((*foo.get(0) == 10)); } +fn test(foo: Box> ) { assert!(((*foo)[0] == 10)); } pub fn main() { let x = box vec!(10); diff --git a/src/test/run-pass/move-arg-2.rs b/src/test/run-pass/move-arg-2.rs index 840a3c2a6ee86..0f3d0baecbe51 100644 --- a/src/test/run-pass/move-arg-2.rs +++ b/src/test/run-pass/move-arg-2.rs @@ -9,7 +9,7 @@ // except according to those terms. -fn test(foo: Box>) { assert!((*foo.get(0) == 10)); } +fn test(foo: Box>) { assert!(((*foo)[0] == 10)); } pub fn main() { let x = box vec!(10); diff --git a/src/test/run-pass/newtype-polymorphic.rs b/src/test/run-pass/newtype-polymorphic.rs index 437f35d182bb3..a21bb489d16c5 100644 --- a/src/test/run-pass/newtype-polymorphic.rs +++ b/src/test/run-pass/newtype-polymorphic.rs @@ -26,8 +26,8 @@ pub fn main() { let mv = myvec(vec!(1i, 2, 3)); let mv_clone = mv.clone(); let mv_clone = myvec_deref(mv_clone); - assert_eq!(*mv_clone.get(1), 2); + assert_eq!(mv_clone[1], 2); assert_eq!(myvec_elt(mv.clone()), 1); let myvec(v) = mv; - assert_eq!(*v.get(2), 3); + assert_eq!(v[2], 3); } diff --git a/src/test/run-pass/nullable-pointer-iotareduction.rs b/src/test/run-pass/nullable-pointer-iotareduction.rs index 0c66b139e7c2e..9d7130ecb8c55 100644 --- a/src/test/run-pass/nullable-pointer-iotareduction.rs +++ b/src/test/run-pass/nullable-pointer-iotareduction.rs @@ -44,7 +44,7 @@ macro_rules! check_option { assert!(option::None::<$T>.is_none()); let e = $e; let s_ = option::Some::<$T>(e); - let $v = s_.get_ref(); + let $v = s_.as_ref().unwrap(); $chk }} } diff --git a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs index 9ca6598b47c9a..ab3d39e273371 100644 --- a/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs +++ b/src/test/run-pass/objects-owned-object-borrowed-method-headerless.rs @@ -35,6 +35,6 @@ pub fn main() { ); for i in range(0u, foos.len()) { - assert_eq!(i, foos.get(i).foo()); + assert_eq!(i, foos[i].foo()); } } diff --git a/src/test/run-pass/overloaded-deref.rs b/src/test/run-pass/overloaded-deref.rs index 96cf3102a4281..cdd56f64d273d 100644 --- a/src/test/run-pass/overloaded-deref.rs +++ b/src/test/run-pass/overloaded-deref.rs @@ -46,7 +46,7 @@ pub fn main() { let v = Rc::new(RefCell::new(vec!(1i, 2, 3))); *(*(*v).borrow_mut()).get_mut(0) = 3; *(*(*v).borrow_mut()).get_mut(1) += 3; - assert_eq!((*(*(*v).borrow()).get(0), - *(*(*v).borrow()).get(1), - *(*(*v).borrow()).get(2)), (3, 5, 3)); + assert_eq!(((*(*v).borrow())[0], + (*(*v).borrow())[1], + (*(*v).borrow())[2]), (3, 5, 3)); } diff --git a/src/test/run-pass/process-spawn-with-unicode-params.rs b/src/test/run-pass/process-spawn-with-unicode-params.rs index f04bc62bf7f39..9716d79f4c82a 100644 --- a/src/test/run-pass/process-spawn-with-unicode-params.rs +++ b/src/test/run-pass/process-spawn-with-unicode-params.rs @@ -53,12 +53,14 @@ fn main() { // make a separate directory for the child drop(fs::mkdir(&cwd, io::USER_RWX).is_ok()); assert!(fs::copy(&my_path, &child_path).is_ok()); + let mut my_env = my_env; + my_env.push(env); // run child let p = Command::new(&child_path) .arg(arg) .cwd(&cwd) - .env_set_all(my_env.append_one(env).as_slice()) + .env_set_all(my_env.as_slice()) .spawn().unwrap().wait_with_output().unwrap(); // display the output @@ -74,7 +76,7 @@ fn main() { assert!(my_cwd.ends_with_path(&Path::new(child_dir))); // check arguments - assert_eq!(my_args.get(1).as_slice(), arg); + assert_eq!(my_args[1].as_slice(), arg); // check environment variable assert!(my_env.contains(&env)); diff --git a/src/test/run-pass/pure-sum.rs b/src/test/run-pass/pure-sum.rs index 60eb3f9debd25..3b2897cf3a6f5 100644 --- a/src/test/run-pass/pure-sum.rs +++ b/src/test/run-pass/pure-sum.rs @@ -15,7 +15,7 @@ fn sums_to(v: Vec , sum: int) -> bool { let mut i = 0u; let mut sum0 = 0; while i < v.len() { - sum0 += *v.get(i); + sum0 += v[i]; i += 1u; } return sum0 == sum; @@ -25,7 +25,7 @@ fn sums_to_using_uniq(v: Vec , sum: int) -> bool { let mut i = 0u; let mut sum0 = box 0; while i < v.len() { - *sum0 += *v.get(i); + *sum0 += v[i]; i += 1u; } return *sum0 == sum; @@ -35,7 +35,7 @@ fn sums_to_using_rec(v: Vec , sum: int) -> bool { let mut i = 0u; let mut sum0 = F {f: 0}; while i < v.len() { - sum0.f += *v.get(i); + sum0.f += v[i]; i += 1u; } return sum0.f == sum; @@ -47,7 +47,7 @@ fn sums_to_using_uniq_rec(v: Vec , sum: int) -> bool { let mut i = 0u; let mut sum0 = F {f: box 0}; while i < v.len() { - *sum0.f += *v.get(i); + *sum0.f += v[i]; i += 1u; } return *sum0.f == sum; diff --git a/src/test/run-pass/regions-dependent-addr-of.rs b/src/test/run-pass/regions-dependent-addr-of.rs index 252c0b5578ac6..68a451b62acc4 100644 --- a/src/test/run-pass/regions-dependent-addr-of.rs +++ b/src/test/run-pass/regions-dependent-addr-of.rs @@ -42,7 +42,7 @@ fn get_v2(a: &A, i: uint) -> &int { fn get_v3(a: &A, i: uint) -> &int { let foo = &a.value; - foo.v3.get(i) + &foo.v3[i] } fn get_v4(a: &A, _i: uint) -> &int { @@ -97,7 +97,7 @@ pub fn main() { assert_eq!(*p, a.value.v2[1]); let p = get_v3(&a, 1); - assert_eq!(*p, *a.value.v3.get(1)); + assert_eq!(*p, a.value.v3[1]); let p = get_v4(&a, 1); assert_eq!(*p, a.value.v4.f); diff --git a/src/test/run-pass/regions-infer-borrow-scope-view.rs b/src/test/run-pass/regions-infer-borrow-scope-view.rs index c4e0e3bb4fc11..ce9edb5678a09 100644 --- a/src/test/run-pass/regions-infer-borrow-scope-view.rs +++ b/src/test/run-pass/regions-infer-borrow-scope-view.rs @@ -15,5 +15,5 @@ pub fn main() { let v = vec!(1i, 2, 3); let x = view(v.as_slice()); let y = view(x.as_slice()); - assert!((*v.get(0) == x[0]) && (*v.get(0) == y[0])); + assert!((v[0] == x[0]) && (v[0] == y[0])); } diff --git a/src/test/run-pass/running-with-no-runtime.rs b/src/test/run-pass/running-with-no-runtime.rs index 3f559df4b7e7a..d0762d1f3d8f2 100644 --- a/src/test/run-pass/running-with-no-runtime.rs +++ b/src/test/run-pass/running-with-no-runtime.rs @@ -41,7 +41,7 @@ fn start(argc: int, argv: *const *const u8) -> int { fn main() { let args = os::args(); - let me = args.get(0).as_slice(); + let me = args[0].as_slice(); let x: &[u8] = &[1u8]; pass(Command::new(me).arg(x).output().unwrap()); diff --git a/src/test/run-pass/size-and-align.rs b/src/test/run-pass/size-and-align.rs index 1078359dc145e..65928fd7bf332 100644 --- a/src/test/run-pass/size-and-align.rs +++ b/src/test/run-pass/size-and-align.rs @@ -11,7 +11,7 @@ enum clam { a(T, int), b, } fn uhoh(v: Vec> ) { - match *v.get(1) { + match v[1] { a::(ref _t, ref u) => { println!("incorrect"); println!("{}", u); diff --git a/src/test/run-pass/static-impl.rs b/src/test/run-pass/static-impl.rs index d0dacc2ff7a9d..ff6e0e4bbc9f5 100644 --- a/src/test/run-pass/static-impl.rs +++ b/src/test/run-pass/static-impl.rs @@ -63,9 +63,9 @@ pub fn main() { assert_eq!((vec!(1i)).length_().str(), "1".to_string()); let vect = vec!(3i, 4).map_(|a| *a + 4); - assert_eq!(*vect.get(0), 7); + assert_eq!(vect[0], 7); let vect = (vec!(3i, 4)).map_::(|a| *a as uint + 4u); - assert_eq!(*vect.get(0), 7u); + assert_eq!(vect[0], 7u); let mut x = 0u; 10u.multi(|_n| x += 2u ); assert_eq!(x, 20u); diff --git a/src/test/run-pass/swap-2.rs b/src/test/run-pass/swap-2.rs index 7789fe5abb42e..4eb9274551f92 100644 --- a/src/test/run-pass/swap-2.rs +++ b/src/test/run-pass/swap-2.rs @@ -13,10 +13,10 @@ use std::mem::swap; pub fn main() { let mut a: Vec = vec!(0, 1, 2, 3, 4, 5, 6); a.as_mut_slice().swap(2, 4); - assert_eq!(*a.get(2), 4); - assert_eq!(*a.get(4), 2); + assert_eq!(a[2], 4); + assert_eq!(a[4], 2); let mut n = 42; swap(&mut n, a.get_mut(0)); - assert_eq!(*a.get(0), 42); + assert_eq!(a[0], 42); assert_eq!(n, 0); } diff --git a/src/test/run-pass/task-comm-16.rs b/src/test/run-pass/task-comm-16.rs index d45e7a20c3b20..a6cc8c463e808 100644 --- a/src/test/run-pass/task-comm-16.rs +++ b/src/test/run-pass/task-comm-16.rs @@ -29,9 +29,9 @@ fn test_vec() { let v0: Vec = vec!(0, 1, 2); tx.send(v0); let v1 = rx.recv(); - assert_eq!(*v1.get(0), 0); - assert_eq!(*v1.get(1), 1); - assert_eq!(*v1.get(2), 2); + assert_eq!(v1[0], 0); + assert_eq!(v1[1], 1); + assert_eq!(v1[2], 2); } fn test_str() { diff --git a/src/test/run-pass/trait-with-bounds-default.rs b/src/test/run-pass/trait-with-bounds-default.rs index ec9f666eb198d..6b2c5093c83bd 100644 --- a/src/test/run-pass/trait-with-bounds-default.rs +++ b/src/test/run-pass/trait-with-bounds-default.rs @@ -32,7 +32,7 @@ impl Getter for int { } impl Getter for Option { - fn do_get(&self) -> T { self.get_ref().clone() } + fn do_get(&self) -> T { self.as_ref().unwrap().clone() } } diff --git a/src/test/run-pass/type-use-i1-versus-i8.rs b/src/test/run-pass/type-use-i1-versus-i8.rs index 97bf9e9e8e2a6..99c68ac8100c8 100644 --- a/src/test/run-pass/type-use-i1-versus-i8.rs +++ b/src/test/run-pass/type-use-i1-versus-i8.rs @@ -8,12 +8,12 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::mem; +use std::ptr; pub fn main() { unsafe { let mut x: bool = false; // this line breaks it - mem::overwrite(&mut x, false); + ptr::write(&mut x, false); } } diff --git a/src/test/run-pass/ufcs-explicit-self.rs b/src/test/run-pass/ufcs-explicit-self.rs index 9ffb56c516af5..b96820eee14b7 100644 --- a/src/test/run-pass/ufcs-explicit-self.rs +++ b/src/test/run-pass/ufcs-explicit-self.rs @@ -8,8 +8,6 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -use std::owned::Box; - struct Foo { f: int, } diff --git a/src/test/run-pass/unique-autoderef-index.rs b/src/test/run-pass/unique-autoderef-index.rs index ec328d65ac849..f9bd5114e7da9 100644 --- a/src/test/run-pass/unique-autoderef-index.rs +++ b/src/test/run-pass/unique-autoderef-index.rs @@ -11,5 +11,5 @@ pub fn main() { let i = box vec!(100i); - assert_eq!(*i.get(0), 100i); + assert_eq!((*i)[0], 100i); } diff --git a/src/test/run-pass/unique-in-vec-copy.rs b/src/test/run-pass/unique-in-vec-copy.rs index fda3c53bdf404..33a28ddb2fca7 100644 --- a/src/test/run-pass/unique-in-vec-copy.rs +++ b/src/test/run-pass/unique-in-vec-copy.rs @@ -13,12 +13,12 @@ pub fn main() { let mut a = vec!(box 10i); let b = a.clone(); - assert_eq!(**a.get(0), 10); - assert_eq!(**b.get(0), 10); + assert_eq!(*a[0], 10); + assert_eq!(*b[0], 10); // This should only modify the value in a, not b **a.get_mut(0) = 20; - assert_eq!(**a.get(0), 20); - assert_eq!(**b.get(0), 10); + assert_eq!(*a[0], 20); + assert_eq!(*b[0], 10); } diff --git a/src/test/run-pass/unique-in-vec.rs b/src/test/run-pass/unique-in-vec.rs index b7029ab38bc79..0f8527664b92e 100644 --- a/src/test/run-pass/unique-in-vec.rs +++ b/src/test/run-pass/unique-in-vec.rs @@ -10,5 +10,5 @@ pub fn main() { let vect = vec!(box 100i); - assert!(*vect.get(0) == box 100); + assert!(vect[0] == box 100); } diff --git a/src/test/run-pass/vec-concat.rs b/src/test/run-pass/vec-concat.rs index a0400a9dcc579..02a791e797519 100644 --- a/src/test/run-pass/vec-concat.rs +++ b/src/test/run-pass/vec-concat.rs @@ -13,9 +13,10 @@ use std::vec; pub fn main() { let a: Vec = vec!(1, 2, 3, 4, 5); let b: Vec = vec!(6, 7, 8, 9, 0); - let v: Vec = a.append(b.as_slice()); - println!("{}", *v.get(9)); - assert_eq!(*v.get(0), 1); - assert_eq!(*v.get(7), 8); - assert_eq!(*v.get(9), 0); + let mut v: Vec = a; + v.push_all(b.as_slice()); + println!("{}", v[9]); + assert_eq!(v[0], 1); + assert_eq!(v[7], 8); + assert_eq!(v[9], 0); } diff --git a/src/test/run-pass/vec-growth.rs b/src/test/run-pass/vec-growth.rs index 08f9b3c176bc7..d5e5f94d26182 100644 --- a/src/test/run-pass/vec-growth.rs +++ b/src/test/run-pass/vec-growth.rs @@ -15,9 +15,9 @@ pub fn main() { v.push(3i); v.push(4i); v.push(5i); - assert_eq!(*v.get(0), 1); - assert_eq!(*v.get(1), 2); - assert_eq!(*v.get(2), 3); - assert_eq!(*v.get(3), 4); - assert_eq!(*v.get(4), 5); + assert_eq!(v[0], 1); + assert_eq!(v[1], 2); + assert_eq!(v[2], 3); + assert_eq!(v[3], 4); + assert_eq!(v[4], 5); } diff --git a/src/test/run-pass/vec-late-init.rs b/src/test/run-pass/vec-late-init.rs index 118095b6c9a23..dec0b3eaa78fb 100644 --- a/src/test/run-pass/vec-late-init.rs +++ b/src/test/run-pass/vec-late-init.rs @@ -12,5 +12,5 @@ pub fn main() { let mut later: Vec ; if true { later = vec!(1); } else { later = vec!(2); } - println!("{}", *later.get(0)); + println!("{}", later[0]); } diff --git a/src/test/run-pass/vec.rs b/src/test/run-pass/vec.rs index c5031a6e51fa3..5e19868de1ddd 100644 --- a/src/test/run-pass/vec.rs +++ b/src/test/run-pass/vec.rs @@ -11,12 +11,12 @@ pub fn main() { let v: Vec = vec!(10, 20); - assert_eq!(*v.get(0), 10); - assert_eq!(*v.get(1), 20); + assert_eq!(v[0], 10); + assert_eq!(v[1], 20); let mut x: uint = 0; - assert_eq!(*v.get(x), 10); - assert_eq!(*v.get(x + 1), 20); + assert_eq!(v[x], 10); + assert_eq!(v[x + 1], 20); x = x + 1; - assert_eq!(*v.get(x), 20); - assert_eq!(*v.get(x - 1), 10); + assert_eq!(v[x], 20); + assert_eq!(v[x - 1], 10); }