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.
Replace 'blk' -> 'block' in AstBuilder.

I didn't rename variables because they are local and are not parts of
the public interfaces.

Signed-off-by: OGINO Masanori <masanori.ogino@gmail.com>
Fix calling destructor on uninitialized dynamic library crash.

A test case was also created for this situation to prevent the problem
occuring again.

A similar problem was also fixed for the symbol method.

There was some minor code cleanup.
std: Implement SingleThreaded spawn mode for newsched
auto merge of #8221 : brson/rust/single-threaded, r=graydon

This is the last major runtime feature needed for the transition to the new scheduler.
std: Speed up str::is_utf8

Use unchecked vec indexing since the vector bounds are checked by the
loop. Iterators are not easy to use in this case since we skip 1-4 bytes
each lap. This part of the commit speeds up is_utf8 for ASCII input.

Check codepoint ranges by checking the byte ranges manually instead of
computing a full decoding for multibyte encodings. This is easy to read
and corresponds to the UTF-8 syntax in the RFC.

No changes to what we accept. A comment notes that surrogate halves are
accepted.

Before:

	test str::bench::is_utf8_100_ascii ... bench: 165 ns/iter (+/- 3)
	test str::bench::is_utf8_100_multibyte ... bench: 218 ns/iter (+/- 5)

After:
	test str::bench::is_utf8_100_ascii ... bench: 130 ns/iter (+/- 1)
	test str::bench::is_utf8_100_multibyte ... bench: 156 ns/iter (+/- 3)
Add SendDeferred trait and use it to fix #8214.
Fix nasty double-free bug where a newrt chan could get killed after rescheduling but before suppressing_finalize.
Fix embarrassing bug where 'unkillable' would unwind improperly when it receives a kill signal.
(cleanup) Use more do...finally in extra::sync.
Don't fail from kill signals if already unwinding.
Add an assert_may_sleep() check on every context switch.
Add trait name to conflicting implementation error message
Add backticks around trait name in conflicting implementations error message
auto merge of #8234 : bblum/rust/assorted-fixes, r=brson

This fixes 4 bugs that prevented the extra::arc and extra::sync tests from passing on the new runtime.

* In ```Add SendDeferred trait``` I add a non-rescheduling ```send_deferred``` method to our various channel types. The ```extra::sync``` concurrency primitives need this guarantee so they can send while inside of an exclusive. (This fixes deterministic deadlocks seen with ```RUST_THREADS=1```.)
* In "Fix nasty double-free bug" I make sure that a ```ChanOne``` suppresses_finalize *before* rescheduling away to the receiver, so in case it gets a kill signal upon coming back, the destructor is inhibited as desired. (This is pretty uncommon on multiple CPUs but showed up always with ```RUST_THREADS=1```.)
* In ```Fix embarrassing bug where 'unkillable' would unwind improperly``` I make sure the task's unkillable counter stays consistent when a kill signal is received right at the start of an unkillable section. (This is a very uncommon race and can only occur with multiple CPUs.)
* In ```Don't fail from kill signals if already unwinding``` I do pretty much what it says on the tin. Surprising that it took the whole suite of sync/arc tests to expose this.

The other two commits are cleanup.

r @brson
Rename IpAddr -> SocketAddr, extract IpAddr from SocketAddr

multicast functions now take IpAddr (without port), because they dont't
need port.

Uv* types renamed:
* UvIpAddr -> UvSocketAddr
* UvIpv4 -> UvIpv4SocketAddr
* UvIpv6 -> UvIpv6SocketAddr

"Socket address" is a common name for (ip-address, port) pair (e.g. in
sockaddr_in struct).
Sha2: Remove unecessary integer type specifications.
Sha2: Rearrage traits / impls / structs.

The code was arranged so that the core Sha2 code came first, and then
all of the various implementation of Digest followed along later. The
problem is that the Sha512 compression function code is far away from
the Sha512 Digest implementation, so, if you are trying to read over
the code, you need to scroll all around the file for no good reason. The
code was rearranged so that all of the Sha512 code is in one place and
all of the Sha256 code is in another and so that all impls for a struct
are near the definition of that struct.
Sha2: Remove the result_X() methods; move logic into the Digest impls.

The result_X() methods just calculate an output of a fixed size. They don't
really have much to do with running the actually hash algorithm until the very
last step - the output. It makes much more sense to put all this logic into
the Digest impls for each specific variation on the hash function.
Sha2: Create cryptoutil.rs and re-write the Sha2 module to make use of it.

There are 2 main pieces of functionality in cryptoutil.rs:
* A set of unsafe function for efficiently reading and writing u32 and u64
  values. All of these functions are fairly easy to audit to confirm that
  they do what they are supposed to.
* A FixedBuffer struct. This struct keeps track of input data until there
  is enough of it to execute the a function on it which expects a fixed
  block of data.

The Sha2 module was rewritten to take advantage of the new functions in
cryptoutil as well as FixedBuffer. The result is that the duplicate code
for maintaining a buffer of input data is removed from the Sha512 and
Sha256 implementation. Additionally, the FixedBuffer code is much more
efficient than the previous code was.