Skip to content

Commit

Permalink
Auto merge of #37337 - GuillaumeGomez:rollup, r=GuillaumeGomez
Browse files Browse the repository at this point in the history
Rollup of 10 pull requests

- Successful merges: #37043, #37209, #37211, #37219, #37244, #37253, #37286, #37297, #37309, #37314
- Failed merges:
  • Loading branch information
bors authored Oct 22, 2016
2 parents a6fa572 + 1c2d223 commit f136e9e
Show file tree
Hide file tree
Showing 14 changed files with 263 additions and 133 deletions.
19 changes: 10 additions & 9 deletions src/bootstrap/bin/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@ fn main() {
let args = env::args_os().skip(1).collect::<Vec<_>>();
// Detect whether or not we're a build script depending on whether --target
// is passed (a bit janky...)
let target = args.windows(2).find(|w| &*w[0] == "--target")
.and_then(|w| w[1].to_str());
let target = args.windows(2)
.find(|w| &*w[0] == "--target")
.and_then(|w| w[1].to_str());
let version = args.iter().find(|w| &**w == "-vV");

// Build scripts always use the snapshot compiler which is guaranteed to be
Expand All @@ -64,9 +65,10 @@ fn main() {

let mut cmd = Command::new(rustc);
cmd.args(&args)
.arg("--cfg").arg(format!("stage{}", stage))
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());
.arg("--cfg")
.arg(format!("stage{}", stage))
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());

if let Some(target) = target {
// The stage0 compiler has a special sysroot distinct from what we
Expand Down Expand Up @@ -101,9 +103,8 @@ fn main() {
// This... is a bit of a hack how we detect this. Ideally this
// information should be encoded in the crate I guess? Would likely
// require an RFC amendment to RFC 1513, however.
let is_panic_abort = args.windows(2).any(|a| {
&*a[0] == "--crate-name" && &*a[1] == "panic_abort"
});
let is_panic_abort = args.windows(2)
.any(|a| &*a[0] == "--crate-name" && &*a[1] == "panic_abort");
if is_panic_abort {
cmd.arg("-C").arg("panic=abort");
}
Expand All @@ -116,7 +117,7 @@ fn main() {
cmd.arg("-Cdebuginfo=1");
}
let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") {
Ok(s) => if s == "true" {"y"} else {"n"},
Ok(s) => if s == "true" { "y" } else { "n" },
Err(..) => "n",
};
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));
Expand Down
10 changes: 6 additions & 4 deletions src/bootstrap/bin/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ fn main() {

let mut cmd = Command::new(rustdoc);
cmd.args(&args)
.arg("--cfg").arg(format!("stage{}", stage))
.arg("--cfg").arg("dox")
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());
.arg("--cfg")
.arg(format!("stage{}", stage))
.arg("--cfg")
.arg("dox")
.env(bootstrap::util::dylib_path_var(),
env::join_paths(&dylib_path).unwrap());
std::process::exit(match cmd.status() {
Ok(s) => s.code().unwrap_or(1),
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),
Expand Down
8 changes: 6 additions & 2 deletions src/build_helper/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ pub fn run_silent(cmd: &mut Command) {
};
if !status.success() {
fail(&format!("command did not execute successfully: {:?}\n\
expected success, got: {}", cmd, status));
expected success, got: {}",
cmd,
status));
}
}

Expand Down Expand Up @@ -65,7 +67,9 @@ pub fn output(cmd: &mut Command) -> String {
};
if !output.status.success() {
panic!("command did not execute successfully: {:?}\n\
expected success, got: {}", cmd, output.status);
expected success, got: {}",
cmd,
output.status);
}
String::from_utf8(output.stdout).unwrap()
}
Expand Down
2 changes: 1 addition & 1 deletion src/doc/book/guessing-game.md
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ displaying the message.
[expect]: ../std/result/enum.Result.html#method.expect
[panic]: error-handling.html

If we leave off calling this method, our program will compile, but
If we do not call `expect()`, our program will compile, but
we’ll get a warning:

```bash
Expand Down
14 changes: 3 additions & 11 deletions src/liballoc/raw_vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,7 @@ impl<T> RawVec<T> {
pub fn new() -> Self {
unsafe {
// !0 is usize::MAX. This branch should be stripped at compile time.
let cap = if mem::size_of::<T>() == 0 {
!0
} else {
0
};
let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };

// heap::EMPTY doubles as "unallocated" and "zero-sized allocation"
RawVec {
Expand Down Expand Up @@ -209,11 +205,7 @@ impl<T> RawVec<T> {

let (new_cap, ptr) = if self.cap == 0 {
// skip to 4 because tiny Vec's are dumb; but not if that would cause overflow
let new_cap = if elem_size > (!0) / 8 {
1
} else {
4
};
let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
let ptr = heap::allocate(new_cap * elem_size, align);
(new_cap, ptr)
} else {
Expand Down Expand Up @@ -347,7 +339,7 @@ impl<T> RawVec<T> {
let elem_size = mem::size_of::<T>();
// Nothing we can really do about these checks :(
let required_cap = used_cap.checked_add(needed_extra_cap)
.expect("capacity overflow");
.expect("capacity overflow");
// Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`.
let double_cap = self.cap * 2;
// `double_cap` guarantees exponential growth.
Expand Down
32 changes: 14 additions & 18 deletions src/liballoc_jemalloc/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,8 @@ fn main() {
// that the feature set used by std is the same across all
// targets, which means we have to build the alloc_jemalloc crate
// for targets like emscripten, even if we don't use it.
if target.contains("rumprun") ||
target.contains("bitrig") ||
target.contains("openbsd") ||
target.contains("msvc") ||
target.contains("emscripten")
{
if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") ||
target.contains("msvc") || target.contains("emscripten") {
println!("cargo:rustc-cfg=dummy_jemalloc");
return;
}
Expand All @@ -64,16 +60,16 @@ fn main() {
// only msvc returns None for ar so unwrap is okay
let ar = build_helper::cc2ar(compiler.path(), &target).unwrap();
let cflags = compiler.args()
.iter()
.map(|s| s.to_str().unwrap())
.collect::<Vec<_>>()
.join(" ");
.iter()
.map(|s| s.to_str().unwrap())
.collect::<Vec<_>>()
.join(" ");

let mut stack = src_dir.join("../jemalloc")
.read_dir()
.unwrap()
.map(|e| e.unwrap())
.collect::<Vec<_>>();
.read_dir()
.unwrap()
.map(|e| e.unwrap())
.collect::<Vec<_>>();
while let Some(entry) = stack.pop() {
let path = entry.path();
if entry.file_type().unwrap().is_dir() {
Expand Down Expand Up @@ -155,10 +151,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").expect("NUM_JOBS was not set")));
.current_dir(&build_dir)
.arg("build_lib_static")
.arg("-j")
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));

if target.contains("windows") {
println!("cargo:rustc-link-lib=static=jemalloc");
Expand Down
6 changes: 1 addition & 5 deletions src/liballoc_system/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,11 +221,7 @@ mod imp {
HEAP_REALLOC_IN_PLACE_ONLY,
ptr as LPVOID,
size as SIZE_T) as *mut u8;
if new.is_null() {
old_size
} else {
size
}
if new.is_null() { old_size } else { size }
} else {
old_size
}
Expand Down
5 changes: 2 additions & 3 deletions src/libarena/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,8 @@ mod tests {

let arena = Wrap(TypedArena::new());

let result = arena.alloc_outer(|| {
Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) }
});
let result =
arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) });

assert_eq!(result.inner.value, 10);
}
Expand Down
Loading

0 comments on commit f136e9e

Please sign in to comment.