Skip to content

Commit f07ed2a

Browse files
committed
Auto merge of #55943 - kennytm:rollup, r=kennytm
Rollup of 16 pull requests Successful merges: - #54906 (Reattach all grandchildren when constructing specialization graph.) - #55182 (Redox: Update to new changes) - #55211 (Add BufWriter::buffer method) - #55507 (Add link to std::mem::size_of to size_of intrinsic documentation) - #55530 (Speed up String::from_utf16) - #55556 (Use `Mmap` to open the rmeta file.) - #55622 (NetBSD: link libstd with librt in addition to libpthread) - #55827 (A few tweaks to iterations/collecting) - #55901 (fix various typos in doc comments) - #55926 (Change sidebar selector to fix compatibility with docs.rs) - #55930 (A handful of hir tweaks) - #55932 (core/char: Speed up `to_digit()` for `radix <= 10`) - #55935 (appveyor: Use VS2017 for all our images) - #55936 (save-analysis: be even more aggressive about ignorning macro-generated defs) - #55948 (submodules: update clippy from d8b4269 to 7e0ddef) - #55956 (add tests for some fixed ICEs)
2 parents 4ec0ba9 + cdfa41e commit f07ed2a

File tree

83 files changed

+603
-200
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+603
-200
lines changed

appveyor.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
environment:
2-
SCCACHE_DIGEST: f808afabb4a4eb1d7112bcb3fa6be03b61e93412890c88e177c667eb37f46353d7ec294e559b16f9f4b5e894f2185fe7670a0df15fd064889ecbd80f0c34166c
2+
# This is required for at least an AArch64 compiler in one image, and is
3+
# otherwise recommended by AppVeyor currently for seeing if it has any
4+
# affect on our job times.
5+
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview
36

47
# By default schannel checks revocation of certificates unlike some other SSL
58
# backends, but we've historically had problems on CI where a revocation
@@ -88,7 +91,6 @@ environment:
8891
DIST_REQUIRE_ALL_TOOLS: 1
8992
DEPLOY: 1
9093
CI_JOB_NAME: dist-x86_64-msvc
91-
APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 Preview
9294
- RUST_CONFIGURE_ARGS: >
9395
--build=i686-pc-windows-msvc
9496
--target=i586-pc-windows-msvc

src/Cargo.lock

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,12 +2278,14 @@ version = "0.0.0"
22782278
dependencies = [
22792279
"flate2 1.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
22802280
"log 0.4.5 (registry+https://github.com/rust-lang/crates.io-index)",
2281+
"memmap 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)",
22812282
"proc_macro 0.0.0",
22822283
"rustc 0.0.0",
22832284
"rustc_data_structures 0.0.0",
22842285
"rustc_errors 0.0.0",
22852286
"rustc_target 0.0.0",
22862287
"serialize 0.0.0",
2288+
"stable_deref_trait 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)",
22872289
"syntax 0.0.0",
22882290
"syntax_ext 0.0.0",
22892291
"syntax_pos 0.0.0",

src/liballoc/collections/btree/node.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ struct LeafNode<K, V> {
6969

7070
/// This node's index into the parent node's `edges` array.
7171
/// `*node.parent.edges[node.parent_idx]` should be the same thing as `node`.
72-
/// This is only guaranteed to be initialized when `parent` is nonnull.
72+
/// This is only guaranteed to be initialized when `parent` is non-null.
7373
parent_idx: MaybeUninit<u16>,
7474

7575
/// The number of keys and values this node stores.

src/liballoc/raw_vec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ use boxed::Box;
4444
/// This enables you to use capacity growing logic catch the overflows in your length
4545
/// that might occur with zero-sized types.
4646
///
47-
/// However this means that you need to be careful when roundtripping this type
47+
/// However this means that you need to be careful when round-tripping this type
4848
/// with a `Box<[T]>`: `cap()` won't yield the len. However `with_capacity`,
4949
/// `shrink_to_fit`, and `from_box` will actually set RawVec's private capacity
5050
/// field. This allows zero-sized types to not be special-cased by consumers of

src/liballoc/string.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,15 @@ impl String {
618618
/// ```
619619
#[stable(feature = "rust1", since = "1.0.0")]
620620
pub fn from_utf16(v: &[u16]) -> Result<String, FromUtf16Error> {
621-
decode_utf16(v.iter().cloned()).collect::<Result<_, _>>().map_err(|_| FromUtf16Error(()))
621+
let mut ret = String::with_capacity(v.len());
622+
for c in decode_utf16(v.iter().cloned()) {
623+
if let Ok(c) = c {
624+
ret.push(c);
625+
} else {
626+
return Err(FromUtf16Error(()));
627+
}
628+
}
629+
Ok(ret)
622630
}
623631

624632
/// Decode a UTF-16 encoded slice `v` into a `String`, replacing

src/libcore/benches/char/methods.rs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
use test::Bencher;
12+
13+
const CHARS: [char; 9] = ['0', 'x', '2', '5', 'A', 'f', '7', '8', '9'];
14+
const RADIX: [u32; 5] = [2, 8, 10, 16, 32];
15+
16+
#[bench]
17+
fn bench_to_digit_radix_2(b: &mut Bencher) {
18+
b.iter(|| CHARS.iter().cycle().take(10_000).map(|c| c.to_digit(2)).min())
19+
}
20+
21+
#[bench]
22+
fn bench_to_digit_radix_10(b: &mut Bencher) {
23+
b.iter(|| CHARS.iter().cycle().take(10_000).map(|c| c.to_digit(10)).min())
24+
}
25+
26+
#[bench]
27+
fn bench_to_digit_radix_16(b: &mut Bencher) {
28+
b.iter(|| CHARS.iter().cycle().take(10_000).map(|c| c.to_digit(16)).min())
29+
}
30+
31+
#[bench]
32+
fn bench_to_digit_radix_36(b: &mut Bencher) {
33+
b.iter(|| CHARS.iter().cycle().take(10_000).map(|c| c.to_digit(36)).min())
34+
}
35+
36+
#[bench]
37+
fn bench_to_digit_radix_var(b: &mut Bencher) {
38+
b.iter(|| CHARS.iter().cycle()
39+
.zip(RADIX.iter().cycle())
40+
.take(10_000)
41+
.map(|(c, radix)| c.to_digit(*radix)).min())
42+
}

src/libcore/benches/char/mod.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2017 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
mod methods;

src/libcore/benches/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ extern crate core;
1515
extern crate test;
1616

1717
mod any;
18+
mod char;
1819
mod hash;
1920
mod iter;
2021
mod num;

src/libcore/char/methods.rs

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,15 +121,24 @@ impl char {
121121
#[stable(feature = "rust1", since = "1.0.0")]
122122
#[inline]
123123
pub fn to_digit(self, radix: u32) -> Option<u32> {
124-
if radix > 36 {
125-
panic!("to_digit: radix is too high (maximum 36)");
126-
}
127-
let val = match self {
128-
'0' ..= '9' => self as u32 - '0' as u32,
129-
'a' ..= 'z' => self as u32 - 'a' as u32 + 10,
130-
'A' ..= 'Z' => self as u32 - 'A' as u32 + 10,
131-
_ => return None,
124+
assert!(radix <= 36, "to_digit: radix is too high (maximum 36)");
125+
126+
// the code is split up here to improve execution speed for cases where
127+
// the `radix` is constant and 10 or smaller
128+
let val = if radix <= 10 {
129+
match self {
130+
'0' ..= '9' => self as u32 - '0' as u32,
131+
_ => return None,
132+
}
133+
} else {
134+
match self {
135+
'0'..='9' => self as u32 - '0' as u32,
136+
'a'..='z' => self as u32 - 'a' as u32 + 10,
137+
'A'..='Z' => self as u32 - 'A' as u32 + 10,
138+
_ => return None,
139+
}
132140
};
141+
133142
if val < radix { Some(val) }
134143
else { None }
135144
}

src/libcore/intrinsics.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -672,6 +672,9 @@ extern "rust-intrinsic" {
672672
///
673673
/// More specifically, this is the offset in bytes between successive
674674
/// items of the same type, including alignment padding.
675+
///
676+
/// The stabilized version of this intrinsic is
677+
/// [`std::mem::size_of`](../../std/mem/fn.size_of.html).
675678
pub fn size_of<T>() -> usize;
676679

677680
/// Moves a value to an uninitialized memory location.

0 commit comments

Comments
 (0)