Auto merge of #23219 - Manishearth:rollup, r=Manishearth
This commit is contained in:
commit
777f5d9599
@ -115,7 +115,7 @@ The Rust community congregates in a few places:
|
||||
|
||||
## Contributing
|
||||
|
||||
To contribute to Rust, please see [CONTRIBUTING.md](CONTRIBUTING.md).
|
||||
To contribute to Rust, please see [CONTRIBUTING](CONTRIBUTING.md).
|
||||
|
||||
Rust has an [IRC] culture and most real-time collaboration happens in a
|
||||
variety of channels on Mozilla's IRC network, irc.mozilla.org. The
|
||||
@ -131,4 +131,4 @@ Rust is primarily distributed under the terms of both the MIT license
|
||||
and the Apache License (Version 2.0), with portions covered by various
|
||||
BSD-like licenses.
|
||||
|
||||
See LICENSE-APACHE, LICENSE-MIT, and COPYRIGHT for details.
|
||||
See [LICENSE-APACHE](LICENSE-APACHE), [LICENSE-MIT](LICENSE-MIT), and [COPYRIGHT](COPYRIGHT) for details.
|
||||
|
@ -389,11 +389,11 @@ safe concurrent programs.
|
||||
Here's an example of a concurrent Rust program:
|
||||
|
||||
```{rust}
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let guards: Vec<_> = (0..10).map(|_| {
|
||||
Thread::scoped(|| {
|
||||
thread::scoped(|| {
|
||||
println!("Hello, world!");
|
||||
})
|
||||
}).collect();
|
||||
@ -421,16 +421,16 @@ problem.
|
||||
Let's see an example. This Rust code will not compile:
|
||||
|
||||
```{rust,ignore}
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let mut numbers = vec![1, 2, 3];
|
||||
|
||||
let guards: Vec<_> = (0..3).map(|i| {
|
||||
Thread::scoped(move || {
|
||||
thread::scoped(move || {
|
||||
numbers[i] += 1;
|
||||
println!("numbers[{}] is {}", i, numbers[i]);
|
||||
});
|
||||
})
|
||||
}).collect();
|
||||
}
|
||||
```
|
||||
@ -439,10 +439,10 @@ It gives us this error:
|
||||
|
||||
```text
|
||||
7:25: 10:6 error: cannot move out of captured outer variable in an `FnMut` closure
|
||||
7 Thread::scoped(move || {
|
||||
7 thread::scoped(move || {
|
||||
8 numbers[i] += 1;
|
||||
9 println!("numbers[{}] is {}", i, numbers[i]);
|
||||
10 });
|
||||
10 })
|
||||
error: aborting due to previous error
|
||||
```
|
||||
|
||||
@ -471,7 +471,7 @@ mutation doesn't cause a data race.
|
||||
Here's what using an Arc with a Mutex looks like:
|
||||
|
||||
```{rust}
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
use std::sync::{Arc,Mutex};
|
||||
|
||||
fn main() {
|
||||
@ -479,11 +479,11 @@ fn main() {
|
||||
|
||||
let guards: Vec<_> = (0..3).map(|i| {
|
||||
let number = numbers.clone();
|
||||
Thread::scoped(move || {
|
||||
thread::scoped(move || {
|
||||
let mut array = number.lock().unwrap();
|
||||
array[i] += 1;
|
||||
println!("numbers[{}] is {}", i, array[i]);
|
||||
});
|
||||
})
|
||||
}).collect();
|
||||
}
|
||||
```
|
||||
@ -535,15 +535,15 @@ As an example, Rust's ownership system is _entirely_ at compile time. The
|
||||
safety check that makes this an error about moved values:
|
||||
|
||||
```{rust,ignore}
|
||||
use std::thread::Thread;
|
||||
use std::thread;
|
||||
|
||||
fn main() {
|
||||
let numbers = vec![1, 2, 3];
|
||||
|
||||
let guards: Vec<_> = (0..3).map(|i| {
|
||||
Thread::scoped(move || {
|
||||
thread::scoped(move || {
|
||||
println!("{}", numbers[i]);
|
||||
});
|
||||
})
|
||||
}).collect();
|
||||
}
|
||||
```
|
||||
|
@ -3007,10 +3007,6 @@ A type cast expression is denoted with the binary operator `as`.
|
||||
Executing an `as` expression casts the value on the left-hand side to the type
|
||||
on the right-hand side.
|
||||
|
||||
A numeric value can be cast to any numeric type. A raw pointer value can be
|
||||
cast to or from any integral type or raw pointer type. Any other cast is
|
||||
unsupported and will fail to compile.
|
||||
|
||||
An example of an `as` expression:
|
||||
|
||||
```
|
||||
|
@ -631,9 +631,6 @@ impl<'b, T> DerefMut for RefMut<'b, T> {
|
||||
///
|
||||
/// Types like `Cell<T>` and `RefCell<T>` use this type to wrap their internal data.
|
||||
///
|
||||
/// `UnsafeCell<T>` doesn't opt-out from any marker traits, instead, types with an `UnsafeCell<T>`
|
||||
/// interior are expected to opt-out from those traits themselves.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
|
@ -193,14 +193,9 @@ pub trait Copy : MarkerTrait {
|
||||
/// the `sync` crate do ensure that any mutation cannot cause data
|
||||
/// races. Hence these types are `Sync`.
|
||||
///
|
||||
/// Users writing their own types with interior mutability (or anything
|
||||
/// else that is not thread-safe) should use the `NoSync` marker type
|
||||
/// (from `std::marker`) to ensure that the compiler doesn't
|
||||
/// consider the user-defined type to be `Sync`. Any types with
|
||||
/// interior mutability must also use the `std::cell::UnsafeCell` wrapper
|
||||
/// around the value(s) which can be mutated when behind a `&`
|
||||
/// reference; not doing this is undefined behaviour (for example,
|
||||
/// `transmute`-ing from `&T` to `&mut T` is illegal).
|
||||
/// Any types with interior mutability must also use the `std::cell::UnsafeCell` wrapper around the
|
||||
/// value(s) which can be mutated when behind a `&` reference; not doing this is undefined
|
||||
/// behaviour (for example, `transmute`-ing from `&T` to `&mut T` is illegal).
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[lang="sync"]
|
||||
#[rustc_on_unimplemented = "`{Self}` cannot be shared between threads safely"]
|
||||
|
@ -1517,7 +1517,7 @@ pub trait FromStrRadix {
|
||||
fn from_str_radix(str: &str, radix: u32) -> Result<Self, Self::Err>;
|
||||
}
|
||||
|
||||
/// A utility function that just calls FromStrRadix::from_str_radix.
|
||||
/// A utility function that just calls `FromStrRadix::from_str_radix`.
|
||||
#[unstable(feature = "core", reason = "needs reevaluation")]
|
||||
pub fn from_str_radix<T: FromStrRadix>(str: &str, radix: u32)
|
||||
-> Result<T, T::Err> {
|
||||
|
@ -927,7 +927,7 @@ pub fn build_output_filenames(input: &Input,
|
||||
// We want to toss everything after the final '.'
|
||||
let dirpath = match *odir {
|
||||
Some(ref d) => d.clone(),
|
||||
None => PathBuf::new(".")
|
||||
None => PathBuf::new("")
|
||||
};
|
||||
|
||||
// If a crate name is present, we use it as the link name
|
||||
@ -954,8 +954,11 @@ pub fn build_output_filenames(input: &Input,
|
||||
if *odir != None {
|
||||
sess.warn("ignoring --out-dir flag due to -o flag.");
|
||||
}
|
||||
|
||||
let cur_dir = Path::new("");
|
||||
|
||||
OutputFilenames {
|
||||
out_directory: out_file.parent().unwrap().to_path_buf(),
|
||||
out_directory: out_file.parent().unwrap_or(cur_dir).to_path_buf(),
|
||||
out_filestem: out_file.file_stem().unwrap()
|
||||
.to_str().unwrap().to_string(),
|
||||
single_output_file: ofile,
|
||||
|
4
src/test/run-make/bare-outfile/Makefile
Normal file
4
src/test/run-make/bare-outfile/Makefile
Normal file
@ -0,0 +1,4 @@
|
||||
-include ../tools.mk
|
||||
|
||||
all:
|
||||
$(rustc) -o foo foo.rs
|
12
src/test/run-make/bare-outfile/foo.rs
Normal file
12
src/test/run-make/bare-outfile/foo.rs
Normal file
@ -0,0 +1,12 @@
|
||||
// Copyright 2015 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 <LICENSE-APACHE or
|
||||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
|
||||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
|
||||
// option. This file may not be copied, modified, or distributed
|
||||
// except according to those terms.
|
||||
|
||||
fn main() {
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user