str: Add method .into_owned(self) -> ~str to Str

The method .into_owned() is meant to be used as an optimization when you
need to get a ~str from a Str, but don't want to unnecessarily copy it
if it's already a ~str.

This is meant to ease functions that look like

  fn foo<S: Str>(strs: &[S])

Previously they could work with the strings as slices using .as_slice(),
but producing ~str required copying the string, even if the vector
turned out be a &[~str] already.
librustc: Introduce a new visitor type based on traits and port syntax to it.

This is preparation for removing `@fn`.

This does *not* use default methods yet, because I don't know
whether they work. If they do, a forthcoming PR will use them.

This also changes the precedence of `as`.
librustc: Disallow "unsafe" for external functions
auto merge of #8235 : pcwalton/rust/unsafe-extern-fns, r=pcwalton

r? @brson
replace all remaining `for` with `foreach` or `do`
make `for` parse as `foreach` does

Closes #6997
rm obsolete documentation on `for`

it is documented in the container/iterator tutorial, not the basic
tutorial
Merge pull request #8244 from thestinger/for

make `for` parse as `foreach` does

r=huonw, bors is acting up and this has been run through the try bots
modified logging function to truncate output and adjusted error output formatting tests to be compatible with both the new and old runtimes
fixed the buffer to make it a more reasonable size
option: mutate() and mutate_default() should return bool

Fixes #8047.
std: use ptr.offset where possible in the vec iterator.

Closes #8212.
std: add benchmark for vec.mut_iter.
Explicitly impl Clone for RWArc

RWArc had a clone() method, but it was part of impl RWArc instead of
an implementation of Clone.

Stick with the explicit implementation instead of deriving Clone so we
can have a docstring.

Fixes #8052.
Remove unused variables.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
Rename sum -> _sum.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
Move `use` statements.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
auto merge of #8257 : mozilla/rust/rollup, r=thestinger

1f9c392 r=brson
54e685d r=graydon
1992765 r=thestinger
75155cd r=bblum
def8891 r=graydon
auto merge of #8204 : kballard/rust/str-into-owned, r=graydon

The method .into_owned() is meant to be used as an optimization when you
need to get a ~str from a Str, but don't want to unnecessarily copy it
if it's already a ~str.

This is meant to ease functions that look like

  fn foo<S: Str>(strs: &[S])

Previously they could work with the strings as slices using .as_slice(),
but producing ~str required copying the string, even if the vector
turned out be a &[~str] already.

I don't have any concrete uses for this yet, since the one conversion I've done to `&[S]` so far (see PR #8203) didn't actually need owned strings. But having this here may make using `Str` more attractive.

It also may be worth adding an `into_managed()` function, but that one is less obviously useful than `into_owned()`.
std: expose the keyed HashMap constructor, for runtime-less use.

The `new` constructor uses the task-local RNG to retrieve seeds for the
two key values, which requires the runtime. Exposing a constructor that
takes the keys directly allows HashMaps to be used in programs that wish
to avoid the runtime.