Skip to content

Commit f1d6183

Browse files
committed
Auto merge of #55912 - kennytm:rollup, r=kennytm
Rollup of 20 pull requests Successful merges: - #55136 (Remove short doc where it starts with a codeblock) - #55711 (Format BtreeMap::range_mut example) - #55722 (impl_stable_hash_for: support enums and tuple structs with generic parameters) - #55754 (Avoid converting bytes to UTF-8 strings to print, just pass bytes to stdout/err) - #55804 (rustdoc: don't inline `pub use some_crate` unless directly asked to) - #55805 (Move `static_assert!` into librustc_data_structures) - #55837 (Make PhantomData #[structural_match]) - #55840 (Fix TLS errors when downloading stage0) - #55843 (add FromIterator<A> to Box<[A]>) - #55858 (Small fixes on code blocks in rustdoc) - #55863 (Fix a typo in std::panic) - #55870 (Fix typos.) - #55874 (string: Add documentation for `From` impls) - #55879 (save-analysis: Don't panic for macro-generated use globs) - #55882 (Reference count `crate_inherent_impls`s return value.) - #55888 (miri: for uniformity, also move memory_deallocated to AllocationExtra) - #55889 (global allocators: add a few comments) - #55896 (Document optimizations enabled by FusedIterator) - #55905 (Change `Lit::short_name` to `Lit::literal_name`.) - #55908 (Fix their/there grammar nit)
2 parents 9fefb67 + 7921572 commit f1d6183

File tree

62 files changed

+603
-509
lines changed

Some content is hidden

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

62 files changed

+603
-509
lines changed

src/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ This directory contains the source code of the rust project, including:
55

66
For more information on how various parts of the compiler work, see the [rustc guide].
77

8-
Their is also useful content in the following READMEs, which are gradually being moved over to the guide:
8+
There is also useful content in the following READMEs, which are gradually being moved over to the guide:
99
- https://github.com/rust-lang/rust/tree/master/src/librustc/ty/query
1010
- https://github.com/rust-lang/rust/tree/master/src/librustc/dep_graph
1111
- https://github.com/rust-lang/rust/blob/master/src/librustc/infer/region_constraints

src/bootstrap/bootstrap.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@ def _download(path, url, probably_big, verbose, exception):
7979
# see http://serverfault.com/questions/301128/how-to-download
8080
if sys.platform == 'win32':
8181
run(["PowerShell.exe", "/nologo", "-Command",
82-
"(New-Object System.Net.WebClient)"
83-
".DownloadFile('{}', '{}')".format(url, path)],
82+
"[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12;",
83+
"(New-Object System.Net.WebClient).DownloadFile('{}', '{}')".format(url, path)],
8484
verbose=verbose,
8585
exception=exception)
8686
else:

src/bootstrap/compile.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ impl Step for StdLink {
203203

204204
/// Link all libstd rlibs/dylibs into the sysroot location.
205205
///
206-
/// Links those artifacts generated by `compiler` to a the `stage` compiler's
206+
/// Links those artifacts generated by `compiler` to the `stage` compiler's
207207
/// sysroot for the specified `host` and `target`.
208208
///
209209
/// Note that this assumes that `compiler` has already generated the libstd

src/doc/rustdoc/src/the-doc-attribute.md

+3
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,9 @@ mod bar {
186186

187187
Now we'll have a `Re-exports` line, and `Bar` will not link to anywhere.
188188

189+
One special case: In Rust 2018 and later, if you `pub use` one of your dependencies, `rustdoc` will
190+
not eagerly inline it as a module unless you add `#[doc(inline)}`.
191+
189192
## `#[doc(hidden)]`
190193

191194
Any item annotated with `#[doc(hidden)]` will not appear in the documentation, unless

src/etc/lldb_batchmode.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# containing LLDB commands (one command per line), this script will execute the commands one after
1313
# the other.
1414
# LLDB also has the -s and -S commandline options which also execute a list of commands from a text
15-
# file. However, this command are execute `immediately`: a the command of a `run` or `continue`
15+
# file. However, this command are execute `immediately`: the command of a `run` or `continue`
1616
# command will be executed immediately after the `run` or `continue`, without waiting for the next
1717
# breakpoint to be hit. This a command sequence like the following will not yield reliable results:
1818
#

src/liballoc/alloc.rs

+4
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@ use core::usize;
2121
pub use core::alloc::*;
2222

2323
extern "Rust" {
24+
// These are the magic symbols to call the global allocator. rustc generates
25+
// them from the `#[global_allocator]` attribute if there is one, or uses the
26+
// default implementations in libstd (`__rdl_alloc` etc in `src/libstd/alloc.rs`)
27+
// otherwise.
2428
#[allocator]
2529
#[rustc_allocator_nounwind]
2630
fn __rust_alloc(size: usize, align: usize) -> *mut u8;

src/liballoc/boxed.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,15 @@ use core::convert::From;
7373
use core::fmt;
7474
use core::future::Future;
7575
use core::hash::{Hash, Hasher};
76-
use core::iter::FusedIterator;
76+
use core::iter::{Iterator, FromIterator, FusedIterator};
7777
use core::marker::{Unpin, Unsize};
7878
use core::mem;
7979
use core::pin::Pin;
8080
use core::ops::{CoerceUnsized, DispatchFromDyn, Deref, DerefMut, Generator, GeneratorState};
8181
use core::ptr::{self, NonNull, Unique};
8282
use core::task::{LocalWaker, Poll};
8383

84+
use vec::Vec;
8485
use raw_vec::RawVec;
8586
use str::from_boxed_utf8_unchecked;
8687

@@ -699,6 +700,13 @@ impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Box<U>> for Box<T> {}
699700
#[unstable(feature = "dispatch_from_dyn", issue = "0")]
700701
impl<T: ?Sized + Unsize<U>, U: ?Sized> DispatchFromDyn<Box<U>> for Box<T> {}
701702

703+
#[stable(feature = "boxed_slice_from_iter", since = "1.32.0")]
704+
impl<A> FromIterator<A> for Box<[A]> {
705+
fn from_iter<T: IntoIterator<Item = A>>(iter: T) -> Self {
706+
iter.into_iter().collect::<Vec<_>>().into_boxed_slice()
707+
}
708+
}
709+
702710
#[stable(feature = "box_slice_clone", since = "1.3.0")]
703711
impl<T: Clone> Clone for Box<[T]> {
704712
fn clone(&self) -> Self {

src/liballoc/boxed_test.rs

+8
Original file line numberDiff line numberDiff line change
@@ -140,3 +140,11 @@ fn str_slice() {
140140
let boxed: Box<str> = Box::from(s);
141141
assert_eq!(&*boxed, s)
142142
}
143+
144+
#[test]
145+
fn boxed_slice_from_iter() {
146+
let iter = 0..100;
147+
let boxed: Box<[u32]> = iter.collect();
148+
assert_eq!(boxed.len(), 100);
149+
assert_eq!(boxed[7], 7);
150+
}

src/liballoc/collections/btree/map.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -853,9 +853,10 @@ impl<K: Ord, V> BTreeMap<K, V> {
853853
/// ```
854854
/// use std::collections::BTreeMap;
855855
///
856-
/// let mut map: BTreeMap<&str, i32> = ["Alice", "Bob", "Carol", "Cheryl"].iter()
857-
/// .map(|&s| (s, 0))
858-
/// .collect();
856+
/// let mut map: BTreeMap<&str, i32> = ["Alice", "Bob", "Carol", "Cheryl"]
857+
/// .iter()
858+
/// .map(|&s| (s, 0))
859+
/// .collect();
859860
/// for (_, balance) in map.range_mut("B".."Cheryl") {
860861
/// *balance += 100;
861862
/// }

src/liballoc/string.rs

+41
Original file line numberDiff line numberDiff line change
@@ -2206,13 +2206,40 @@ impl<'a> From<&'a str> for String {
22062206
#[cfg(not(test))]
22072207
#[stable(feature = "string_from_box", since = "1.18.0")]
22082208
impl From<Box<str>> for String {
2209+
/// Converts the given boxed `str` slice to a `String`.
2210+
/// It is notable that the `str` slice is owned.
2211+
///
2212+
/// # Examples
2213+
///
2214+
/// Basic usage:
2215+
///
2216+
/// ```
2217+
/// let s1: String = String::from("hello world");
2218+
/// let s2: Box<str> = s1.into_boxed_str();
2219+
/// let s3: String = String::from(s2);
2220+
///
2221+
/// assert_eq!("hello world", s3)
2222+
/// ```
22092223
fn from(s: Box<str>) -> String {
22102224
s.into_string()
22112225
}
22122226
}
22132227

22142228
#[stable(feature = "box_from_str", since = "1.20.0")]
22152229
impl From<String> for Box<str> {
2230+
/// Converts the given `String` to a boxed `str` slice that is owned.
2231+
///
2232+
/// # Examples
2233+
///
2234+
/// Basic usage:
2235+
///
2236+
/// ```
2237+
/// let s1: String = String::from("hello world");
2238+
/// let s2: Box<str> = Box::from(s1);
2239+
/// let s3: String = String::from(s2);
2240+
///
2241+
/// assert_eq!("hello world", s3)
2242+
/// ```
22162243
fn from(s: String) -> Box<str> {
22172244
s.into_boxed_str()
22182245
}
@@ -2272,6 +2299,20 @@ impl<'a> FromIterator<String> for Cow<'a, str> {
22722299

22732300
#[stable(feature = "from_string_for_vec_u8", since = "1.14.0")]
22742301
impl From<String> for Vec<u8> {
2302+
/// Converts the given `String` to a vector `Vec` that holds values of type `u8`.
2303+
///
2304+
/// # Examples
2305+
///
2306+
/// Basic usage:
2307+
///
2308+
/// ```
2309+
/// let s1 = String::from("hello world");
2310+
/// let v1 = Vec::from(s1);
2311+
///
2312+
/// for b in v1 {
2313+
/// println!("{}", b);
2314+
/// }
2315+
/// ```
22752316
fn from(string: String) -> Vec<u8> {
22762317
string.into_bytes()
22772318
}

src/libcore/iter/traits.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -960,7 +960,7 @@ impl<T, U, E> Product<Result<U, E>> for Result<T, E>
960960
///
961961
/// Calling next on a fused iterator that has returned `None` once is guaranteed
962962
/// to return [`None`] again. This trait should be implemented by all iterators
963-
/// that behave this way because it allows for some significant optimizations.
963+
/// that behave this way because it allows optimizing [`Iterator::fuse`].
964964
///
965965
/// Note: In general, you should not use `FusedIterator` in generic bounds if
966966
/// you need a fused iterator. Instead, you should just call [`Iterator::fuse`]

src/libcore/lib.rs

+1
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
#![feature(const_transmute)]
129129
#![feature(reverse_bits)]
130130
#![feature(non_exhaustive)]
131+
#![feature(structural_match)]
131132

132133
#[prelude_import]
133134
#[allow(unused)]

src/libcore/marker.rs

+1
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,7 @@ macro_rules! impls{
578578
///
579579
/// [drop check]: ../../nomicon/dropck.html
580580
#[lang = "phantom_data"]
581+
#[structural_match]
581582
#[stable(feature = "rust1", since = "1.0.0")]
582583
pub struct PhantomData<T:?Sized>;
583584

src/libcore/str/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,7 @@ mod traits {
18961896
#[inline]
18971897
fn index_mut(self, slice: &mut str) -> &mut Self::Output {
18981898
// is_char_boundary checks that the index is in [0, .len()]
1899-
// canot reuse `get` as above, because of NLL trouble
1899+
// cannot reuse `get` as above, because of NLL trouble
19001900
if self.start <= self.end &&
19011901
slice.is_char_boundary(self.start) &&
19021902
slice.is_char_boundary(self.end) {

src/librustc/ich/impls_mir.rs

+17-54
Original file line numberDiff line numberDiff line change
@@ -37,68 +37,31 @@ impl_stable_hash_for!(struct mir::BasicBlockData<'tcx> { statements, terminator,
3737
impl_stable_hash_for!(struct mir::UnsafetyViolation { source_info, description, details, kind });
3838
impl_stable_hash_for!(struct mir::UnsafetyCheckResult { violations, unsafe_blocks });
3939

40-
impl<'a> HashStable<StableHashingContext<'a>>
41-
for mir::BorrowKind {
42-
#[inline]
43-
fn hash_stable<W: StableHasherResult>(&self,
44-
hcx: &mut StableHashingContext<'a>,
45-
hasher: &mut StableHasher<W>) {
46-
mem::discriminant(self).hash_stable(hcx, hasher);
47-
48-
match *self {
49-
mir::BorrowKind::Shared |
50-
mir::BorrowKind::Shallow |
51-
mir::BorrowKind::Unique => {}
52-
mir::BorrowKind::Mut { allow_two_phase_borrow } => {
53-
allow_two_phase_borrow.hash_stable(hcx, hasher);
54-
}
55-
}
56-
}
57-
}
58-
59-
60-
impl<'a> HashStable<StableHashingContext<'a>>
61-
for mir::UnsafetyViolationKind {
62-
#[inline]
63-
fn hash_stable<W: StableHasherResult>(&self,
64-
hcx: &mut StableHashingContext<'a>,
65-
hasher: &mut StableHasher<W>) {
66-
67-
mem::discriminant(self).hash_stable(hcx, hasher);
68-
69-
match *self {
70-
mir::UnsafetyViolationKind::General => {}
71-
mir::UnsafetyViolationKind::MinConstFn => {}
72-
mir::UnsafetyViolationKind::ExternStatic(lint_node_id) |
73-
mir::UnsafetyViolationKind::BorrowPacked(lint_node_id) => {
74-
lint_node_id.hash_stable(hcx, hasher);
75-
}
40+
impl_stable_hash_for!(enum mir::BorrowKind {
41+
Shared,
42+
Shallow,
43+
Unique,
44+
Mut { allow_two_phase_borrow },
45+
});
7646

77-
}
78-
}
79-
}
47+
impl_stable_hash_for!(enum mir::UnsafetyViolationKind {
48+
General,
49+
MinConstFn,
50+
ExternStatic(lint_node_id),
51+
BorrowPacked(lint_node_id),
52+
});
8053

8154
impl_stable_hash_for!(struct mir::Terminator<'tcx> {
8255
kind,
8356
source_info
8457
});
8558

86-
impl<'a, 'gcx, T> HashStable<StableHashingContext<'a>> for mir::ClearCrossCrate<T>
87-
where T: HashStable<StableHashingContext<'a>>
88-
{
89-
#[inline]
90-
fn hash_stable<W: StableHasherResult>(&self,
91-
hcx: &mut StableHashingContext<'a>,
92-
hasher: &mut StableHasher<W>) {
93-
mem::discriminant(self).hash_stable(hcx, hasher);
94-
match *self {
95-
mir::ClearCrossCrate::Clear => {}
96-
mir::ClearCrossCrate::Set(ref value) => {
97-
value.hash_stable(hcx, hasher);
98-
}
99-
}
59+
impl_stable_hash_for!(
60+
impl<T> for enum mir::ClearCrossCrate<T> [ mir::ClearCrossCrate ] {
61+
Clear,
62+
Set(value),
10063
}
101-
}
64+
);
10265

10366
impl<'a> HashStable<StableHashingContext<'a>> for mir::Local {
10467
#[inline]

0 commit comments

Comments
 (0)