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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 0 deletions
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

Lines changed: 9 additions & 1 deletion
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

Lines changed: 8 additions & 0 deletions
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

Lines changed: 4 additions & 3 deletions
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

Lines changed: 41 additions & 0 deletions
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
}

0 commit comments

Comments
 (0)