Skip to content

Commit f136e9e

Browse files
authoredOct 22, 2016
Auto merge of #37337 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 10 pull requests - Successful merges: #37043, #37209, #37211, #37219, #37244, #37253, #37286, #37297, #37309, #37314 - Failed merges:
2 parents a6fa572 + 1c2d223 commit f136e9e

File tree

14 files changed

+263
-133
lines changed

14 files changed

+263
-133
lines changed
 

‎src/bootstrap/bin/rustc.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ fn main() {
3636
let args = env::args_os().skip(1).collect::<Vec<_>>();
3737
// Detect whether or not we're a build script depending on whether --target
3838
// is passed (a bit janky...)
39-
let target = args.windows(2).find(|w| &*w[0] == "--target")
40-
.and_then(|w| w[1].to_str());
39+
let target = args.windows(2)
40+
.find(|w| &*w[0] == "--target")
41+
.and_then(|w| w[1].to_str());
4142
let version = args.iter().find(|w| &**w == "-vV");
4243

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

6566
let mut cmd = Command::new(rustc);
6667
cmd.args(&args)
67-
.arg("--cfg").arg(format!("stage{}", stage))
68-
.env(bootstrap::util::dylib_path_var(),
69-
env::join_paths(&dylib_path).unwrap());
68+
.arg("--cfg")
69+
.arg(format!("stage{}", stage))
70+
.env(bootstrap::util::dylib_path_var(),
71+
env::join_paths(&dylib_path).unwrap());
7072

7173
if let Some(target) = target {
7274
// The stage0 compiler has a special sysroot distinct from what we
@@ -101,9 +103,8 @@ fn main() {
101103
// This... is a bit of a hack how we detect this. Ideally this
102104
// information should be encoded in the crate I guess? Would likely
103105
// require an RFC amendment to RFC 1513, however.
104-
let is_panic_abort = args.windows(2).any(|a| {
105-
&*a[0] == "--crate-name" && &*a[1] == "panic_abort"
106-
});
106+
let is_panic_abort = args.windows(2)
107+
.any(|a| &*a[0] == "--crate-name" && &*a[1] == "panic_abort");
107108
if is_panic_abort {
108109
cmd.arg("-C").arg("panic=abort");
109110
}
@@ -116,7 +117,7 @@ fn main() {
116117
cmd.arg("-Cdebuginfo=1");
117118
}
118119
let debug_assertions = match env::var("RUSTC_DEBUG_ASSERTIONS") {
119-
Ok(s) => if s == "true" {"y"} else {"n"},
120+
Ok(s) => if s == "true" { "y" } else { "n" },
120121
Err(..) => "n",
121122
};
122123
cmd.arg("-C").arg(format!("debug-assertions={}", debug_assertions));

‎src/bootstrap/bin/rustdoc.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ fn main() {
2929

3030
let mut cmd = Command::new(rustdoc);
3131
cmd.args(&args)
32-
.arg("--cfg").arg(format!("stage{}", stage))
33-
.arg("--cfg").arg("dox")
34-
.env(bootstrap::util::dylib_path_var(),
35-
env::join_paths(&dylib_path).unwrap());
32+
.arg("--cfg")
33+
.arg(format!("stage{}", stage))
34+
.arg("--cfg")
35+
.arg("dox")
36+
.env(bootstrap::util::dylib_path_var(),
37+
env::join_paths(&dylib_path).unwrap());
3638
std::process::exit(match cmd.status() {
3739
Ok(s) => s.code().unwrap_or(1),
3840
Err(e) => panic!("\n\nfailed to run {:?}: {}\n\n", cmd, e),

‎src/build_helper/lib.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ pub fn run_silent(cmd: &mut Command) {
2525
};
2626
if !status.success() {
2727
fail(&format!("command did not execute successfully: {:?}\n\
28-
expected success, got: {}", cmd, status));
28+
expected success, got: {}",
29+
cmd,
30+
status));
2931
}
3032
}
3133

@@ -65,7 +67,9 @@ pub fn output(cmd: &mut Command) -> String {
6567
};
6668
if !output.status.success() {
6769
panic!("command did not execute successfully: {:?}\n\
68-
expected success, got: {}", cmd, output.status);
70+
expected success, got: {}",
71+
cmd,
72+
output.status);
6973
}
7074
String::from_utf8(output.stdout).unwrap()
7175
}

‎src/doc/book/guessing-game.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ displaying the message.
276276
[expect]: ../std/result/enum.Result.html#method.expect
277277
[panic]: error-handling.html
278278

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

282282
```bash

‎src/liballoc/raw_vec.rs

+3-11
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ impl<T> RawVec<T> {
5757
pub fn new() -> Self {
5858
unsafe {
5959
// !0 is usize::MAX. This branch should be stripped at compile time.
60-
let cap = if mem::size_of::<T>() == 0 {
61-
!0
62-
} else {
63-
0
64-
};
60+
let cap = if mem::size_of::<T>() == 0 { !0 } else { 0 };
6561

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

210206
let (new_cap, ptr) = if self.cap == 0 {
211207
// skip to 4 because tiny Vec's are dumb; but not if that would cause overflow
212-
let new_cap = if elem_size > (!0) / 8 {
213-
1
214-
} else {
215-
4
216-
};
208+
let new_cap = if elem_size > (!0) / 8 { 1 } else { 4 };
217209
let ptr = heap::allocate(new_cap * elem_size, align);
218210
(new_cap, ptr)
219211
} else {
@@ -347,7 +339,7 @@ impl<T> RawVec<T> {
347339
let elem_size = mem::size_of::<T>();
348340
// Nothing we can really do about these checks :(
349341
let required_cap = used_cap.checked_add(needed_extra_cap)
350-
.expect("capacity overflow");
342+
.expect("capacity overflow");
351343
// Cannot overflow, because `cap <= isize::MAX`, and type of `cap` is `usize`.
352344
let double_cap = self.cap * 2;
353345
// `double_cap` guarantees exponential growth.

‎src/liballoc_jemalloc/build.rs

+14-18
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,8 @@ fn main() {
3535
// that the feature set used by std is the same across all
3636
// targets, which means we have to build the alloc_jemalloc crate
3737
// for targets like emscripten, even if we don't use it.
38-
if target.contains("rumprun") ||
39-
target.contains("bitrig") ||
40-
target.contains("openbsd") ||
41-
target.contains("msvc") ||
42-
target.contains("emscripten")
43-
{
38+
if target.contains("rumprun") || target.contains("bitrig") || target.contains("openbsd") ||
39+
target.contains("msvc") || target.contains("emscripten") {
4440
println!("cargo:rustc-cfg=dummy_jemalloc");
4541
return;
4642
}
@@ -64,16 +60,16 @@ fn main() {
6460
// only msvc returns None for ar so unwrap is okay
6561
let ar = build_helper::cc2ar(compiler.path(), &target).unwrap();
6662
let cflags = compiler.args()
67-
.iter()
68-
.map(|s| s.to_str().unwrap())
69-
.collect::<Vec<_>>()
70-
.join(" ");
63+
.iter()
64+
.map(|s| s.to_str().unwrap())
65+
.collect::<Vec<_>>()
66+
.join(" ");
7167

7268
let mut stack = src_dir.join("../jemalloc")
73-
.read_dir()
74-
.unwrap()
75-
.map(|e| e.unwrap())
76-
.collect::<Vec<_>>();
69+
.read_dir()
70+
.unwrap()
71+
.map(|e| e.unwrap())
72+
.collect::<Vec<_>>();
7773
while let Some(entry) = stack.pop() {
7874
let path = entry.path();
7975
if entry.file_type().unwrap().is_dir() {
@@ -155,10 +151,10 @@ fn main() {
155151

156152
run(&mut cmd);
157153
run(Command::new("make")
158-
.current_dir(&build_dir)
159-
.arg("build_lib_static")
160-
.arg("-j")
161-
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
154+
.current_dir(&build_dir)
155+
.arg("build_lib_static")
156+
.arg("-j")
157+
.arg(env::var("NUM_JOBS").expect("NUM_JOBS was not set")));
162158

163159
if target.contains("windows") {
164160
println!("cargo:rustc-link-lib=static=jemalloc");

‎src/liballoc_system/lib.rs

+1-5
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,7 @@ mod imp {
221221
HEAP_REALLOC_IN_PLACE_ONLY,
222222
ptr as LPVOID,
223223
size as SIZE_T) as *mut u8;
224-
if new.is_null() {
225-
old_size
226-
} else {
227-
size
228-
}
224+
if new.is_null() { old_size } else { size }
229225
} else {
230226
old_size
231227
}

‎src/libarena/lib.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,8 @@ mod tests {
335335

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

338-
let result = arena.alloc_outer(|| {
339-
Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) }
340-
});
338+
let result =
339+
arena.alloc_outer(|| Outer { inner: arena.alloc_inner(|| Inner { value: 10 }) });
341340

342341
assert_eq!(result.inner.value, 10);
343342
}

0 commit comments

Comments
 (0)
Please sign in to comment.