Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into ios
Browse files Browse the repository at this point in the history
  • Loading branch information
vhbit committed Apr 4, 2015
2 parents 19b334c + 6971727 commit 54db9fa
Show file tree
Hide file tree
Showing 112 changed files with 963 additions and 975 deletions.
96 changes: 92 additions & 4 deletions AUTHORS.txt

Large diffs are not rendered by default.

19 changes: 16 additions & 3 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,6 @@ opt verify-install 1 "verify installed binaries work"
# This is used by the automation to produce single-target nightlies
opt dist-host-only 0 "only install bins for the host architecture"
opt inject-std-version 1 "inject the current compiler version of libstd into programs"
opt jemalloc 1 "build liballoc with jemalloc"
opt llvm-version-check 1 "don't check if the LLVM version is supported, build anyway"

valopt localstatedir "/var/lib" "local state directory"
Expand All @@ -562,6 +561,7 @@ valopt android-cross-path "/opt/ndk_standalone" "Android NDK standalone path"
# (others are conditionally saved).
opt_nosave manage-submodules 1 "let the build manage the git submodules"
opt_nosave clang 0 "prefer clang to gcc for building the runtime"
opt_nosave jemalloc 1 "build liballoc with jemalloc"

valopt_nosave prefix "/usr/local" "set installation prefix"
valopt_nosave local-rust-root "/usr/local" "set prefix for local rust binary"
Expand Down Expand Up @@ -669,7 +669,6 @@ probe CFG_LD ld
probe CFG_VALGRIND valgrind
probe CFG_PERF perf
probe CFG_ISCC iscc
probe CFG_JAVAC javac
probe CFG_ANTLR4 antlr4
probe CFG_GRUN grun
probe CFG_FLEX flex
Expand All @@ -679,6 +678,14 @@ probe CFG_XELATEX xelatex
probe CFG_GDB gdb
probe CFG_LLDB lldb

# On MacOS X, invoking `javac` pops up a dialog if the JDK is not
# installed. Since `javac` is only used if `antlr4` is available,
# probe for it only in this case.
if [ ! -z "$CFG_ANTLR4" ]
then
probe CFG_JAVAC javac
fi

if [ ! -z "$CFG_GDB" ]
then
# Store GDB's version
Expand Down Expand Up @@ -775,7 +782,7 @@ if [ $CFG_OSTYPE = unknown-bitrig ]
then
step_msg "on Bitrig, forcing use of clang, disabling jemalloc"
CFG_ENABLE_CLANG=1
CFG_ENABLE_JEMALLOC=0
CFG_DISABLE_JEMALLOC=1
fi

if [ -z "$CFG_ENABLE_CLANG" -a -z "$CFG_GCC" ]
Expand Down Expand Up @@ -828,6 +835,12 @@ then
putvar CFG_ENABLE_CLANG
fi

# Same with jemalloc. save the setting here.
if [ ! -z "$CFG_DISABLE_JEMALLOC" ]
then
putvar CFG_DISABLE_JEMALLOC
fi

if [ ! -z "$CFG_LLVM_ROOT" -a -z "$CFG_DISABLE_LLVM_VERSION_CHECK" -a -e "$CFG_LLVM_ROOT/bin/llvm-config" ]
then
step_msg "using custom LLVM at $CFG_LLVM_ROOT"
Expand Down
3 changes: 0 additions & 3 deletions src/doc/trpl/closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,6 @@ we called `add_num`, it mutated the underlying value, as we'd expect. We also
needed to declare `add_num` as `mut` too, because we’re mutating its
environment.

We also had to declare `add_num` as mut, since we will be modifying its
environment.

If we change to a `move` closure, it's different:

```rust
Expand Down
32 changes: 9 additions & 23 deletions src/doc/trpl/concurrency.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,14 @@ When `guard` goes out of scope, it will block execution until the thread is
finished. If we didn't want this behaviour, we could use `thread::spawn()`:

```
# #![feature(old_io, std_misc)]
use std::thread;
use std::old_io::timer;
use std::time::Duration;
fn main() {
thread::spawn(|| {
println!("Hello from a thread!");
});
timer::sleep(Duration::milliseconds(50));
thread::sleep_ms(50);
}
```

Expand Down Expand Up @@ -147,10 +144,7 @@ As an example, here is a Rust program that would have a data race in many
languages. It will not compile:

```ignore
# #![feature(old_io, std_misc)]
use std::thread;
use std::old_io::timer;
use std::time::Duration;
fn main() {
let mut data = vec![1u32, 2, 3];
Expand All @@ -161,14 +155,14 @@ fn main() {
});
}
timer::sleep(Duration::milliseconds(50));
thread::sleep_ms(50);
}
```

This gives us an error:

```text
12:17 error: capture of moved value: `data`
8:17 error: capture of moved value: `data`
data[i] += 1;
^~~~
```
Expand All @@ -187,10 +181,7 @@ only one person at a time can mutate what's inside. For that, we can use the
but for a different reason:

```ignore
# #![feature(old_io, std_misc)]
use std::thread;
use std::old_io::timer;
use std::time::Duration;
use std::sync::Mutex;
fn main() {
Expand All @@ -203,17 +194,17 @@ fn main() {
});
}
timer::sleep(Duration::milliseconds(50));
thread::sleep_ms(50);
}
```

Here's the error:

```text
<anon>:11:9: 11:22 error: the trait `core::marker::Send` is not implemented for the type `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` [E0277]
<anon>:9:9: 9:22 error: the trait `core::marker::Send` is not implemented for the type `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` [E0277]
<anon>:11 thread::spawn(move || {
^~~~~~~~~~~~~
<anon>:11:9: 11:22 note: `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` cannot be sent between threads safely
<anon>:9:9: 9:22 note: `std::sync::mutex::MutexGuard<'_, collections::vec::Vec<u32>>` cannot be sent between threads safely
<anon>:11 thread::spawn(move || {
^~~~~~~~~~~~~
```
Expand All @@ -232,11 +223,8 @@ guard across thread boundaries, which gives us our error.
We can use `Arc<T>` to fix this. Here's the working version:

```
# #![feature(old_io, std_misc)]
use std::sync::{Arc, Mutex};
use std::thread;
use std::old_io::timer;
use std::time::Duration;
fn main() {
let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
Expand All @@ -249,20 +237,17 @@ fn main() {
});
}
timer::sleep(Duration::milliseconds(50));
thread::sleep_ms(50);
}
```

We now call `clone()` on our `Arc`, which increases the internal count. This
handle is then moved into the new thread. Let's examine the body of the
thread more closely:

```
# #![feature(old_io, std_misc)]
```rust
# use std::sync::{Arc, Mutex};
# use std::thread;
# use std::old_io::timer;
# use std::time::Duration;
# fn main() {
# let data = Arc::new(Mutex::new(vec![1u32, 2, 3]));
# for i in 0..2 {
Expand All @@ -272,6 +257,7 @@ thread::spawn(move || {
data[i] += 1;
});
# }
# thread::sleep_ms(50);
# }
```

Expand Down
4 changes: 2 additions & 2 deletions src/doc/trpl/installing-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ $ sudo sh rustup.sh
```

If you're on Windows, please download either the [32-bit
installer](https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe)
installer](https://static.rust-lang.org/dist/rust-1.0.0-beta-i686-pc-windows-gnu.exe)
or the [64-bit
installer](https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.exe)
installer](https://static.rust-lang.org/dist/rust-1.0.0-beta-x86_64-pc-windows-gnu.exe)
and run it.

If you decide you don't want Rust anymore, we'll be a bit sad, but that's okay.
Expand Down
50 changes: 50 additions & 0 deletions src/doc/trpl/unstable.md
Original file line number Diff line number Diff line change
@@ -1 +1,51 @@
% Unstable Rust

Rust provides three distribution channels for Rust: nightly, beta, and stable.
Unstable features are only available on nightly Rust. For more details on this
process, see [this post](http://blog.rust-lang.org/2014/10/30/Stability.html).

To install nightly Rust, you can use `rustup.sh`:

```bash
$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh -s -- --channel=nightly
```

If you're concerned about the [potential insecurity](http://curlpipesh.tumblr.com/) of using `curl | sudo sh`,
please keep reading and see our disclaimer below. And feel free to use a two-step version of the installation and examine our installation script:

```bash
$ curl -f -L https://static.rust-lang.org/rustup.sh -O
$ sudo sh rustup.sh --channel=nightly
```

If you're on Windows, please download either the [32-bit
installer](https://static.rust-lang.org/dist/rust-nightly-i686-pc-windows-gnu.exe)
or the [64-bit
installer](https://static.rust-lang.org/dist/rust-nightly-x86_64-pc-windows-gnu.exe)
and run it.

If you decide you don't want Rust anymore, we'll be a bit sad, but that's okay.
Not every programming language is great for everyone. Just run the uninstall
script:

```bash
$ sudo /usr/local/lib/rustlib/uninstall.sh
```

If you used the Windows installer, just re-run the `.exe` and it will give you
an uninstall option.

You can re-run this script any time you want to update Rust. Which, at this
point, is often. Rust is still pre-1.0, and so people assume that you're using
a very recent Rust.

This brings me to one other point: some people, and somewhat rightfully so, get
very upset when we tell you to `curl | sudo sh`. And they should be! Basically,
when you do this, you are trusting that the good people who maintain Rust
aren't going to hack your computer and do bad things. That's a good instinct!
If you're one of those people, please check out the documentation on [building
Rust from Source](https://github.com/rust-lang/rust#building-from-source), or
[the official binary downloads](http://www.rust-lang.org/install.html). And we
promise that this method will not be the way to install Rust forever: it's just
the easiest way to keep people updated while Rust is in its alpha state.

2 changes: 1 addition & 1 deletion src/liballoc/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ impl<T> Weak<T> {
/// ```
pub fn upgrade(&self) -> Option<Arc<T>> {
// We use a CAS loop to increment the strong count instead of a
// fetch_add because once the count hits 0 is must never be above 0.
// fetch_add because once the count hits 0 it must never be above 0.
let inner = self.inner();
loop {
let n = inner.strong.load(SeqCst);
Expand Down
5 changes: 4 additions & 1 deletion src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,16 @@ struct TyDesc {
align: usize
}

trait AllTypes { fn dummy(&self) { } }
impl<T:?Sized> AllTypes for T { }

unsafe fn get_tydesc<T>() -> *const TyDesc {
use std::raw::TraitObject;

let ptr = &*(1 as *const T);

// Can use any trait that is implemented for all types.
let obj = mem::transmute::<&marker::MarkerTrait, TraitObject>(ptr);
let obj = mem::transmute::<&AllTypes, TraitObject>(ptr);
obj.vtable as *const TyDesc
}

Expand Down
Loading

0 comments on commit 54db9fa

Please sign in to comment.