]> git.lizzy.rs Git - rust.git/commitdiff
rollup merge of #20275: inthecloud247/patch-1
authorAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 00:36:40 +0000 (16:36 -0800)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 30 Dec 2014 00:36:40 +0000 (16:36 -0800)
Updating curl flag and instructions to follow better security practices
used by other projects: https://github.com/saltstack/salt-bootstrap

Other references:
http://www.reddit.com/r/linux/comments/1s58my/please_stop_piping_curl1_to_sh1/
http://www.seancassidy.me/dont-pipe-to-your-shell.html
https://news.ycombinator.com/item?id=8550511
http://output.chrissnell.com/post/69023793377/stop-piping-curl-1-to-sh-1
http://www.reddit.com/comments/1pqtcb

1  2 
src/doc/guide.md

diff --combined src/doc/guide.md
index 1a2723980c99d9f3d66b6f4b696244d7164f4aeb,6f32693fdae65459954a592a07748b7d30c9f1a8..d094c47da93bb3f1386e61ae2dd9d210cdf23e0a
@@@ -23,11 -23,16 +23,16 @@@ Linux or a Mac, all you need to do is t
  in the `$`s, they just indicate the start of each command):
  
  ```bash
$ curl -s https://static.rust-lang.org/rustup.sh | sudo sh
curl -L https://static.rust-lang.org/rustup.sh | sudo sh
  ```
  
- (If you're concerned about `curl | sudo sh`, please keep reading. Disclaimer
- below.)
+ 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 -L https://static.rust-lang.org/rustup.sh -O
+ 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)
@@@ -482,7 -487,7 +487,7 @@@ src/main.rs:2     let x
  
  Giving it a type will compile, though:
  
 -```{ignore}
 +```{rust}
  let x: int;
  ```
  
@@@ -1044,9 -1049,7 +1049,9 @@@ struct Point(int, int, int)
  
  These two will not be equal, even if they have the same values:
  
 -```{rust,ignore}
 +```{rust}
 +# struct Color(int, int, int);
 +# struct Point(int, int, int);
  let black  = Color(0, 0, 0);
  let origin = Point(0, 0, 0);
  ```
@@@ -1606,6 -1609,10 +1611,6 @@@ let a = [1i, 2i, 3i];     // a: [int, .
  let mut m = [1i, 2i, 3i]; // mut m: [int, ..3]
  ```
  
 -You can create an array with a given number of elements, all initialized to the
 -same value, with `[val, ..N]` syntax. The compiler ensures that arrays are
 -always initialized.
 -
  There's a shorthand for initializing each element of an array to the same
  value. In this example, each element of `a` will be initialized to `0i`:
  
@@@ -1893,7 -1900,7 +1898,7 @@@ authors = ["Your Name <you@example.com>
  Cargo gets this information from your environment. If it's not correct, go ahead
  and fix that.
  
 -Finally, Cargo generated a hello, world for us. Check out `src/main.rs`:
 +Finally, Cargo generated a "Hello, world!" for us. Check out `src/main.rs`:
  
  ```{rust}
  fn main() {
@@@ -3034,7 -3041,7 +3039,7 @@@ test foo ... FAILE
  failures:
  
  ---- foo stdout ----
 -        task 'foo' failed at 'assertion failed: false', /home/you/projects/testing/tests/lib.rs:3
 +        thread 'foo' failed at 'assertion failed: false', /home/you/projects/testing/tests/lib.rs:3
  
  
  
@@@ -3043,7 -3050,7 +3048,7 @@@ failures
  
  test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
  
 -task '<main>' failed at 'Some tests failed', /home/you/src/rust/src/libtest/lib.rs:243
 +thread '<main>' failed at 'Some tests failed', /home/you/src/rust/src/libtest/lib.rs:243
  ```
  
  Lots of output! Let's break this down:
@@@ -3086,7 -3093,7 +3091,7 @@@ failed, especially as we accumulate mor
  failures:
  
  ---- foo stdout ----
 -        task 'foo' failed at 'assertion failed: false', /home/you/projects/testing/tests/lib.rs:3
 +        thread 'foo' failed at 'assertion failed: false', /home/you/projects/testing/tests/lib.rs:3
  
  
  
@@@ -3095,7 -3102,7 +3100,7 @@@ failures
  
  test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured
  
 -task '<main>' failed at 'Some tests failed', /home/you/src/rust/src/libtest/lib.rs:243
 +thread '<main>' failed at 'Some tests failed', /home/you/src/rust/src/libtest/lib.rs:243
  ```
  
  After all the tests run, Rust will show us any output from our failed tests.
@@@ -4261,7 -4268,7 +4266,7 @@@ is that a moving closure always takes o
  it uses. Ordinary closures, in contrast, just create a reference into
  the enclosing stack frame. Moving closures are most useful with Rust's
  concurrency features, and so we'll just leave it at this for
 -now. We'll talk about them more in the "Tasks" section of the guide.
 +now. We'll talk about them more in the "Threads" section of the guide.
  
  ## Accepting closures as arguments
  
@@@ -4288,9 -4295,7 +4293,9 @@@ let square = |x: int| { x * x }
  We've seen this before. We make a closure that takes an integer, and returns
  its square.
  
 -```{rust,ignore}
 +```{rust}
 +# fn twice(x: int, f: |int| -> int) -> int { f(x) + f(x) }
 +# let square = |x: int| { x * x };
  twice(5i, square); // evaluates to 50
  ```
  
@@@ -5213,7 -5218,9 +5218,7 @@@ as you can see, there's no overhead of 
  hence 'statically dispatched'. The downside is that we have two copies of
  the same function, so our binary is a little bit larger.
  
 -# Tasks
 -
 -**NOTE**: this section is currently out of date and will be rewritten soon.
 +# Threads 
  
  Concurrency and parallelism are topics that are of increasing interest to a
  broad subsection of software developers. Modern computers are often multi-core,
@@@ -5222,22 -5229,24 +5227,22 @@@ processor. Rust's semantics lend themse
  issues that programmers have with concurrency. Many concurrency errors that are
  runtime errors in other languages are compile-time errors in Rust.
  
 -Rust's concurrency primitive is called a **task**. Tasks are similar to
 -threads, and do not share memory in an unsafe manner, preferring message
 -passing to communicate. It's worth noting that tasks are implemented as a
 -library, and not part of the language. This means that in the future, other
 -concurrency libraries can be written for Rust to help in specific scenarios.
 -Here's an example of creating a task:
 +Rust's concurrency primitive is called a **thread**. It's worth noting that
 +threads are implemented as a library, and not part of the language. This means
 +that in the future, other concurrency libraries can be written for Rust to help
 +in specific scenarios. Here's an example of creating a thread:
  
  ```{rust,ignore}
  spawn(move || {
 -    println!("Hello from a task!");
 +    println!("Hello from a thread!");
  });
  ```
  
  The `spawn` function takes a closure as an argument, and runs that
 -closure in a new task. Typically, you will want to use a moving
 +closure in a new thread. Typically, you will want to use a moving
  closure, so that the closure takes ownership of any variables that it
  touches.  This implies that those variables are not usable from the
 -parent task after the child task is spawned:
 +parent thread after the child thread is spawned:
  
  ```{rust,ignore}
  let mut x = vec![1i, 2i, 3i];
@@@ -5253,15 -5262,15 +5258,15 @@@ println!("The value of x[0] is: {}", x[
  other languages would let us do this, but it's not safe to do
  so. Rust's borrow checker catches the error.
  
 -If tasks were only able to capture these values, they wouldn't be very useful.
 -Luckily, tasks can communicate with each other through **channel**s. Channels
 +If threads were only able to capture these values, they wouldn't be very useful.
 +Luckily, threads can communicate with each other through **channel**s. Channels
  work like this:
  
  ```{rust,ignore}
  let (tx, rx) = channel();
  
  spawn(move || {
 -    tx.send("Hello from a task!".to_string());
 +    tx.send("Hello from a thread!".to_string());
  });
  
  let message = rx.recv();
@@@ -5274,14 -5283,14 +5279,14 @@@ receive the message on the `Receiver<T>
  method blocks until it gets a message. There's a similar method, `.try_recv()`,
  which returns an `Result<T, TryRecvError>` and does not block.
  
 -If you want to send messages to the task as well, create two channels!
 +If you want to send messages to the thread as well, create two channels!
  
  ```{rust,ignore}
  let (tx1, rx1) = channel();
  let (tx2, rx2) = channel();
  
  spawn(move || {
 -    tx1.send("Hello from a task!".to_string());
 +    tx1.send("Hello from a thread!".to_string());
      let message = rx2.recv();
      println!("{}", message);
  });
@@@ -5292,9 -5301,9 +5297,9 @@@ println!("{}", message)
  tx2.send("Goodbye from main!".to_string());
  ```
  
 -The closure has one sending end and one receiving end, and the main
 -task has one of each as well. Now they can talk back and forth in
 -whatever way they wish.
 +The closure has one sending end and one receiving end, and the main thread has
 +one of each as well. Now they can talk back and forth in whatever way they
 +wish.
  
  Notice as well that because `Sender` and `Receiver` are generic, while you can
  pass any kind of information through the channel, the ends are strongly typed.
@@@ -5333,7 -5342,7 +5338,7 @@@ we'll just get the value immediately
  
  ## Success and failure
  
 -Tasks don't always succeed, they can also panic. A task that wishes to panic
 +Threads don't always succeed, they can also panic. A thread that wishes to panic
  can call the `panic!` macro, passing a message:
  
  ```{rust,ignore}
@@@ -5342,14 -5351,14 +5347,14 @@@ spawn(move || 
  });
  ```
  
 -If a task panics, it is not possible for it to recover. However, it can
 -notify other tasks that it has panicked. We can do this with `task::try`:
 +If a thread panics, it is not possible for it to recover. However, it can
 +notify other thread that it has panicked. We can do this with `thread::try`:
  
  ```{rust,ignore}
 -use std::task;
 +use std::thread;
  use std::rand;
  
 -let result = task::try(move || {
 +let result = thread::try(move || {
      if rand::random() {
          println!("OK");
      } else {
  });
  ```
  
 -This task will randomly panic or succeed. `task::try` returns a `Result`
 +This thread will randomly panic or succeed. `thread::try` returns a `Result`
  type, so we can handle the response like any other computation that may
  fail.
  
@@@ -5406,7 -5415,7 +5411,7 @@@ fn main() 
  }
  ```
  
 -You can have the macros expanded like this: `rustc print.rs --pretty=expanded`, which will
 +You can have the macros expanded like this: `rustc --pretty=expanded print.rs`, which will
  give us this huge result:
  
  ```{rust,ignore}