Skip to content

Commit 9649c1f

Browse files
committed
Auto merge of rust-lang#55974 - pietroalbini:rollup, r=pietroalbini
Rollup of 17 pull requests Successful merges: - rust-lang#55182 (Redox: Update to new changes) - rust-lang#55211 (Add BufWriter::buffer method) - rust-lang#55507 (Add link to std::mem::size_of to size_of intrinsic documentation) - rust-lang#55530 (Speed up String::from_utf16) - rust-lang#55556 (Use `Mmap` to open the rmeta file.) - rust-lang#55622 (NetBSD: link libstd with librt in addition to libpthread) - rust-lang#55750 (Make `NodeId` and `HirLocalId` `newtype_index`) - rust-lang#55778 (Wrap some query results in `Lrc`.) - rust-lang#55781 (More precise spans for temps and their drops) - rust-lang#55785 (Add mem::forget_unsized() for forgetting unsized values) - rust-lang#55852 (Rewrite `...` as `..=` as a `MachineApplicable` 2018 idiom lint) - rust-lang#55865 (Unix RwLock: avoid racy access to write_locked) - rust-lang#55901 (fix various typos in doc comments) - rust-lang#55926 (Change sidebar selector to fix compatibility with docs.rs) - rust-lang#55930 (A handful of hir tweaks) - rust-lang#55932 (core/char: Speed up `to_digit()` for `radix <= 10`) - rust-lang#55956 (add tests for some fixed ICEs) Failed merges: r? @ghost
2 parents 99e3fca + d0e08ce commit 9649c1f

File tree

120 files changed

+934
-390
lines changed

Some content is hidden

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

120 files changed

+934
-390
lines changed

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: 7 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.
@@ -714,6 +717,10 @@ extern "rust-intrinsic" {
714717
/// initialize memory previous set to the result of `uninit`.
715718
pub fn uninit<T>() -> T;
716719

720+
/// Moves a value out of scope without running drop glue.
721+
#[cfg(not(stage0))]
722+
pub fn forget<T: ?Sized>(_: T);
723+
717724
/// Reinterprets the bits of a value of one type as another type.
718725
///
719726
/// Both types must have the same size. Neither the original, nor the result,

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@
106106
#![feature(staged_api)]
107107
#![feature(stmt_expr_attributes)]
108108
#![feature(unboxed_closures)]
109+
#![feature(unsized_locals)]
109110
#![feature(untagged_unions)]
110111
#![feature(unwind_attributes)]
111112
#![feature(doc_alias)]

0 commit comments

Comments
 (0)