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

+4-2
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

+2
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

+1-1
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

+1-1
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

+9-1
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

+42
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

+11
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

+1
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

+17-8
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

+3
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.

src/libcore/num/f32.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ impl f32 {
445445
/// signaling NaNs on MIPS are quiet NaNs on x86, and vice-versa.
446446
///
447447
/// Rather than trying to preserve signaling-ness cross-platform, this
448-
/// implementation favours preserving the exact bits. This means that
448+
/// implementation favors preserving the exact bits. This means that
449449
/// any payloads encoded in NaNs will be preserved even if the result of
450450
/// this method is sent over the network from an x86 machine to a MIPS one.
451451
///

src/libcore/task/wake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ impl Drop for Waker {
108108
/// is ready to be run.
109109
///
110110
/// This is similar to the `Waker` type, but cannot be sent across threads.
111-
/// Task executors can use this type to implement more optimized singlethreaded wakeup
111+
/// Task executors can use this type to implement more optimized single-threaded wakeup
112112
/// behavior.
113113
#[repr(transparent)]
114114
#[derive(Clone)]

src/libproc_macro/lib.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ impl TokenTree {
535535
}
536536
}
537537

538-
/// Prints token treee in a form convenient for debugging.
538+
/// Prints token tree in a form convenient for debugging.
539539
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
540540
impl fmt::Debug for TokenTree {
541541
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
@@ -730,7 +730,7 @@ impl fmt::Debug for Group {
730730

731731
/// An `Punct` is an single punctuation character like `+`, `-` or `#`.
732732
///
733-
/// Multicharacter operators like `+=` are represented as two instances of `Punct` with different
733+
/// Multi-character operators like `+=` are represented as two instances of `Punct` with different
734734
/// forms of `Spacing` returned.
735735
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
736736
#[derive(Clone)]
@@ -788,7 +788,7 @@ impl Punct {
788788

789789
/// Returns the spacing of this punctuation character, indicating whether it's immediately
790790
/// followed by another `Punct` in the token stream, so they can potentially be combined into
791-
/// a multicharacter operator (`Joint`), or it's followed by some other token or whitespace
791+
/// a multi-character operator (`Joint`), or it's followed by some other token or whitespace
792792
/// (`Alone`) so the operator has certainly ended.
793793
#[stable(feature = "proc_macro_lib2", since = "1.29.0")]
794794
pub fn spacing(&self) -> Spacing {
@@ -947,7 +947,7 @@ macro_rules! suffixed_int_literals {
947947
/// This function will create an integer like `1u32` where the integer
948948
/// value specified is the first part of the token and the integral is
949949
/// also suffixed at the end.
950-
/// Literals created from negative numbers may not survive rountrips through
950+
/// Literals created from negative numbers may not survive round-trips through
951951
/// `TokenStream` or strings and may be broken into two tokens (`-` and positive literal).
952952
///
953953
/// Literals created through this method have the `Span::call_site()`
@@ -1047,7 +1047,7 @@ impl Literal {
10471047

10481048
/// Creates a new suffixed floating-point literal.
10491049
///
1050-
/// This consturctor will create a literal like `1.0f32` where the value
1050+
/// This constructor will create a literal like `1.0f32` where the value
10511051
/// specified is the preceding part of the token and `f32` is the suffix of
10521052
/// the token. This token will always be inferred to be an `f32` in the
10531053
/// compiler.
@@ -1096,7 +1096,7 @@ impl Literal {
10961096

10971097
/// Creates a new suffixed floating-point literal.
10981098
///
1099-
/// This consturctor will create a literal like `1.0f64` where the value
1099+
/// This constructor will create a literal like `1.0f64` where the value
11001100
/// specified is the preceding part of the token and `f64` is the suffix of
11011101
/// the token. This token will always be inferred to be an `f64` in the
11021102
/// compiler.

src/librustc/cfg/graphviz.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ impl<'a> dot::GraphWalk<'a> for &'a cfg::CFG {
106106
type Node = Node<'a>;
107107
type Edge = Edge<'a>;
108108
fn nodes(&'a self) -> dot::Nodes<'a, Node<'a>> {
109-
let mut v = Vec::new();
110-
self.graph.each_node(|i, nd| { v.push((i, nd)); true });
109+
let v: Vec<_> = self.graph.enumerated_nodes().collect();
111110
v.into()
112111
}
113112
fn edges(&'a self) -> dot::Edges<'a, Edge<'a>> {

src/librustc/dep_graph/cgu_reuse_tracker.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
// except according to those terms.
1010

1111
//! Some facilities for tracking how codegen-units are reused during incremental
12-
//! compilition. This is used for incremental compiliation tests and debug
12+
//! compilation. This is used for incremental compilation tests and debug
1313
//! output.
1414
1515
use session::Session;

src/librustc/hir/def.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ pub enum NonMacroAttrKind {
3636
Tool,
3737
/// Single-segment custom attribute registered by a derive macro (`#[serde(default)]`).
3838
DeriveHelper,
39-
/// Single-segment custom attriubte registered by a legacy plugin (`register_attribute`).
39+
/// Single-segment custom attribute registered by a legacy plugin (`register_attribute`).
4040
LegacyPluginHelper,
4141
/// Single-segment custom attribute not registered in any way (`#[my_attr]`).
4242
Custom,

src/librustc/hir/lowering.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,7 @@ impl<'a> LoweringContext<'a> {
10621062
attrs
10631063
.iter()
10641064
.map(|a| self.lower_attr(a))
1065-
.collect::<Vec<_>>()
1066-
.into()
1065+
.collect()
10671066
}
10681067

10691068
fn lower_attr(&mut self, attr: &Attribute) -> Attribute {

src/librustc/hir/mod.rs

+4-7
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ use syntax_pos::{Span, DUMMY_SP, symbol::InternedString};
2727
use syntax::source_map::{self, Spanned};
2828
use rustc_target::spec::abi::Abi;
2929
use syntax::ast::{self, CrateSugar, Ident, Name, NodeId, DUMMY_NODE_ID, AsmDialect};
30-
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy, MetaItem};
30+
use syntax::ast::{Attribute, Lit, StrStyle, FloatTy, IntTy, UintTy};
3131
use syntax::attr::InlineAttr;
3232
use syntax::ext::hygiene::SyntaxContext;
3333
use syntax::ptr::P;
@@ -58,7 +58,6 @@ macro_rules! hir_vec {
5858
($($x:expr),*) => (
5959
$crate::hir::HirVec::from(vec![$($x),*])
6060
);
61-
($($x:expr,)*) => (hir_vec![$($x),*])
6261
}
6362

6463
pub mod check_attr;
@@ -331,7 +330,7 @@ impl Path {
331330

332331
impl fmt::Debug for Path {
333332
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
334-
write!(f, "path({})", print::to_string(print::NO_ANN, |s| s.print_path(self, false)))
333+
write!(f, "path({})", self)
335334
}
336335
}
337336

@@ -698,8 +697,6 @@ pub struct WhereEqPredicate {
698697
pub rhs_ty: P<Ty>,
699698
}
700699

701-
pub type CrateConfig = HirVec<P<MetaItem>>;
702-
703700
/// The top-level data structure that stores the entire contents of
704701
/// the crate currently being compiled.
705702
///
@@ -1196,8 +1193,8 @@ impl StmtKind {
11961193

11971194
pub fn id(&self) -> NodeId {
11981195
match *self {
1199-
StmtKind::Decl(_, id) => id,
1200-
StmtKind::Expr(_, id) => id,
1196+
StmtKind::Decl(_, id) |
1197+
StmtKind::Expr(_, id) |
12011198
StmtKind::Semi(_, id) => id,
12021199
}
12031200
}

src/librustc/infer/canonical/canonicalizer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
//! This module contains the "canonicalizer" itself.
1212
//!
13-
//! For an overview of what canonicaliation is and how it fits into
13+
//! For an overview of what canonicalization is and how it fits into
1414
//! rustc, check out the [chapter in the rustc guide][c].
1515
//!
1616
//! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html

src/librustc/infer/canonical/query_response.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
556556
}
557557

558558
/// Given two sets of values for the same set of canonical variables, unify them.
559-
/// The second set is produced lazilly by supplying indices from the first set.
559+
/// The second set is produced lazily by supplying indices from the first set.
560560
fn unify_canonical_vars(
561561
&self,
562562
cause: &ObligationCause<'tcx>,

src/librustc/infer/canonical/substitute.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
//! This module contains code to substitute new values into a
1212
//! `Canonical<'tcx, T>`.
1313
//!
14-
//! For an overview of what canonicaliation is and how it fits into
14+
//! For an overview of what canonicalization is and how it fits into
1515
//! rustc, check out the [chapter in the rustc guide][c].
1616
//!
1717
//! [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html

src/librustc/infer/error_reporting/nice_region_error/outlives_closure.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use util::common::ErrorReported;
2020
use infer::lexical_region_resolve::RegionResolutionError::SubSupConflict;
2121

2222
impl<'a, 'gcx, 'tcx> NiceRegionError<'a, 'gcx, 'tcx> {
23-
/// Print the error message for lifetime errors when binding excapes a closure.
23+
/// Print the error message for lifetime errors when binding escapes a closure.
2424
///
2525
/// Consider a case where we have
2626
///

src/librustc/infer/higher_ranked/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
428428
///
429429
/// This routine is only intended to be used when the leak-check has
430430
/// passed; currently, it's used in the trait matching code to create
431-
/// a set of nested obligations frmo an impl that matches against
431+
/// a set of nested obligations from an impl that matches against
432432
/// something higher-ranked. More details can be found in
433433
/// `librustc/middle/traits/README.md`.
434434
///

src/librustc/infer/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1160,10 +1160,10 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
11601160
}
11611161

11621162
/// Takes ownership of the list of variable regions. This implies
1163-
/// that all the region constriants have already been taken, and
1163+
/// that all the region constraints have already been taken, and
11641164
/// hence that `resolve_regions_and_report_errors` can never be
11651165
/// called. This is used only during NLL processing to "hand off" ownership
1166-
/// of the set of region vairables into the NLL region context.
1166+
/// of the set of region variables into the NLL region context.
11671167
pub fn take_region_var_origins(&self) -> VarInfos {
11681168
let (var_infos, data) = self.region_constraints
11691169
.borrow_mut()
@@ -1478,7 +1478,7 @@ impl<'a, 'gcx, 'tcx> InferCtxt<'a, 'gcx, 'tcx> {
14781478
}
14791479

14801480
/// Clears the selection, evaluation, and projection caches. This is useful when
1481-
/// repeatedly attemping to select an Obligation while changing only
1481+
/// repeatedly attempting to select an Obligation while changing only
14821482
/// its ParamEnv, since FulfillmentContext doesn't use 'probe'
14831483
pub fn clear_caches(&self) {
14841484
self.selection_cache.clear();

0 commit comments

Comments
 (0)