Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 13 pull requests #34196

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
adf2c43
run rustfmt on liballoc_jemalloc folder
srinivasreddy Jun 5, 2016
d6560dd
run rustfmt on map.rs in libcollections/btree folder
srinivasreddy Jun 5, 2016
27d4ed4
run rustfmt on librustc_bitflags folder
srinivasreddy Jun 5, 2016
75fc40c
Remove a gotcha from book/error-handling.md
jviide Jun 6, 2016
4504df7
Test case for borrowk ICE #25579
imjacobclark Jun 7, 2016
96c85f4
run rustfmt on libflate folder
srinivasreddy Jun 7, 2016
7abdbd4
docs: simplify wording
matklad Jun 7, 2016
0379493
Resolving build failure
imjacobclark Jun 7, 2016
c39e37a
Add explanation for E0503.
m-decoster Jun 8, 2016
5439806
Add explanation for E0508.
m-decoster Jun 8, 2016
d592675
Updated README to account for changes in MSYS2
seventh-chord Jun 8, 2016
4c5f3a6
Resolving line length build fail
imjacobclark Jun 8, 2016
92e8228
Fixed two little Game Of Thrones References
hoodie Jun 7, 2016
34bcc3d
Fix markdown formatting error of E0277, E0310 and E0502.
kennytm Jun 8, 2016
bc4def9
docs: Improve char::to_{lower,upper}case examples
ollie27 Jun 8, 2016
8180a91
Fix BTreeMap example typo
rwz Jun 9, 2016
f617b49
Rollup merge of #34086 - srinivasreddy:rustfmt_liballoc_jemalloc, r=n…
sanxiyn Jun 10, 2016
e1e193a
Rollup merge of #34088 - srinivasreddy:rustfmt_map.rs, r=nrc
sanxiyn Jun 10, 2016
e0d4bb3
Rollup merge of #34129 - jviide:from-string-box-error, r=steveklabnik
sanxiyn Jun 10, 2016
cef62e3
Rollup merge of #34133 - m-decoster:master, r=GuillaumeGomez
sanxiyn Jun 10, 2016
874227a
Rollup merge of #34136 - imjacobclark:ice-test-case-25579, r=nikomats…
sanxiyn Jun 10, 2016
e4dad08
Rollup merge of #34145 - matklad:any-docs, r=steveklabnik
sanxiyn Jun 10, 2016
c7b3de9
Rollup merge of #34146 - srinivasreddy:libflate_rustfmt, r=nagisa
sanxiyn Jun 10, 2016
01d3b23
Rollup merge of #34148 - srinivasreddy:bitflags_rustfmt, r=nagisa
sanxiyn Jun 10, 2016
a9aa284
Rollup merge of #34159 - seventh-chord:master, r=alexcrichton
sanxiyn Jun 10, 2016
9638804
Rollup merge of #34160 - hoodie:bug/GoT_References, r=GuillaumeGomez
sanxiyn Jun 10, 2016
a320467
Rollup merge of #34161 - kennytm:fix-E0277-format, r=GuillaumeGomez
sanxiyn Jun 10, 2016
2092031
Rollup merge of #34165 - ollie27:docs_char_case, r=steveklabnik
sanxiyn Jun 10, 2016
48a6112
Rollup merge of #34175 - rwz:patch-2, r=alexcrichton
sanxiyn Jun 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ installing from pacman should be just fine.

3. Run `mingw32_shell.bat` or `mingw64_shell.bat` from wherever you installed
MSYS2 (i.e. `C:\msys`), depending on whether you want 32-bit or 64-bit Rust.
(As of the latest version of MSYS2 you have to run `msys2_shell.cmd -mingw32`
or `msys2_shell.cmd -mingw64` from the command line instead)

4. Navigate to Rust's source code, configure and build it:

Expand Down
20 changes: 8 additions & 12 deletions src/doc/book/error-handling.md
Original file line number Diff line number Diff line change
Expand Up @@ -1829,7 +1829,7 @@ use std::error::Error;

fn search<P: AsRef<Path>>
(file_path: P, city: &str)
-> Result<Vec<PopulationCount>, Box<Error+Send+Sync>> {
-> Result<Vec<PopulationCount>, Box<Error>> {
let mut found = vec![];
let file = try!(File::open(file_path));
let mut rdr = csv::Reader::from_reader(file);
Expand Down Expand Up @@ -1858,20 +1858,17 @@ Instead of `x.unwrap()`, we now have `try!(x)`. Since our function returns a
`Result<T, E>`, the `try!` macro will return early from the function if an
error occurs.

There is one big gotcha in this code: we used `Box<Error + Send + Sync>`
instead of `Box<Error>`. We did this so we could convert a plain string to an
error type. We need these extra bounds so that we can use the
[corresponding `From`
impls](../std/convert/trait.From.html):
At the end of `search` we also convert a plain string to an error type
by using the [corresponding `From` impls](../std/convert/trait.From.html):

```rust,ignore
// We are making use of this impl in the code above, since we call `From::from`
// on a `&'static str`.
impl<'a, 'b> From<&'b str> for Box<Error + Send + Sync + 'a>
impl<'a> From<&'a str> for Box<Error>

// But this is also useful when you need to allocate a new string for an
// error message, usually with `format!`.
impl From<String> for Box<Error + Send + Sync>
impl From<String> for Box<Error>
```

Since `search` now returns a `Result<T, E>`, `main` should use case analysis
Expand Down Expand Up @@ -1964,7 +1961,7 @@ use std::io;

fn search<P: AsRef<Path>>
(file_path: &Option<P>, city: &str)
-> Result<Vec<PopulationCount>, Box<Error+Send+Sync>> {
-> Result<Vec<PopulationCount>, Box<Error>> {
let mut found = vec![];
let input: Box<io::Read> = match *file_path {
None => Box::new(io::stdin()),
Expand Down Expand Up @@ -2175,9 +2172,8 @@ heuristics!
`unwrap`. Be warned: if it winds up in someone else's hands, don't be
surprised if they are agitated by poor error messages!
* If you're writing a quick 'n' dirty program and feel ashamed about panicking
anyway, then use either a `String` or a `Box<Error + Send + Sync>` for your
error type (the `Box<Error + Send + Sync>` type is because of the
[available `From` impls](../std/convert/trait.From.html)).
anyway, then use either a `String` or a `Box<Error>` for your
error type.
* Otherwise, in a program, define your own error types with appropriate
[`From`](../std/convert/trait.From.html)
and
Expand Down
29 changes: 20 additions & 9 deletions src/liballoc_jemalloc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,26 @@ fn main() {
jemalloc.parent().unwrap().display());
let stem = jemalloc.file_stem().unwrap().to_str().unwrap();
let name = jemalloc.file_name().unwrap().to_str().unwrap();
let kind = if name.ends_with(".a") {"static"} else {"dylib"};
let kind = if name.ends_with(".a") {
"static"
} else {
"dylib"
};
println!("cargo:rustc-link-lib={}={}", kind, &stem[3..]);
return
return;
}

let compiler = gcc::Config::new().get_compiler();
let ar = build_helper::cc2ar(compiler.path(), &target);
let cflags = compiler.args().iter().map(|s| s.to_str().unwrap())
.collect::<Vec<_>>().join(" ");
let cflags = compiler.args()
.iter()
.map(|s| s.to_str().unwrap())
.collect::<Vec<_>>()
.join(" ");

let mut stack = src_dir.join("../jemalloc")
.read_dir().unwrap()
.read_dir()
.unwrap()
.map(|e| e.unwrap())
.collect::<Vec<_>>();
while let Some(entry) = stack.pop() {
Expand All @@ -57,7 +65,9 @@ fn main() {
}

let mut cmd = Command::new("sh");
cmd.arg(src_dir.join("../jemalloc/configure").to_str().unwrap()
cmd.arg(src_dir.join("../jemalloc/configure")
.to_str()
.unwrap()
.replace("C:\\", "/c/")
.replace("\\", "/"))
.current_dir(&build_dir)
Expand Down Expand Up @@ -117,9 +127,10 @@ fn main() {

run(&mut cmd);
run(Command::new("make")
.current_dir(&build_dir)
.arg("build_lib_static")
.arg("-j").arg(env::var("NUM_JOBS").unwrap()));
.current_dir(&build_dir)
.arg("build_lib_static")
.arg("-j")
.arg(env::var("NUM_JOBS").unwrap()));

if target.contains("windows") {
println!("cargo:rustc-link-lib=static=jemalloc");
Expand Down
11 changes: 6 additions & 5 deletions src/liballoc_jemalloc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ use libc::{c_int, c_void, size_t};
not(target_env = "musl")),
link(name = "pthread"))]
#[cfg(not(cargobuild))]
extern {}
extern "C" {}

// Note that the symbols here are prefixed by default on OSX and Windows (we
// don't explicitly request it), and on Android and DragonFly we explicitly
// request it as unprefixing cause segfaults (mismatches in allocators).
extern {
extern "C" {
#[cfg_attr(any(target_os = "macos", target_os = "android", target_os = "ios",
target_os = "dragonfly", target_os = "windows"),
link_name = "je_mallocx")]
Expand Down Expand Up @@ -136,8 +136,9 @@ pub extern "C" fn __rust_usable_size(size: usize, align: usize) -> usize {
// are available.
#[no_mangle]
#[cfg(target_os = "android")]
pub extern fn pthread_atfork(_prefork: *mut u8,
_postfork_parent: *mut u8,
_postfork_child: *mut u8) -> i32 {
pub extern "C" fn pthread_atfork(_prefork: *mut u8,
_postfork_parent: *mut u8,
_postfork_child: *mut u8)
-> i32 {
0
}
Loading