Skip to content

Commit db3a450

Browse files
committed
Auto merge of rust-lang#81240 - JohnTitor:rollup-ieaz82a, r=JohnTitor
Rollup of 11 pull requests Successful merges: - rust-lang#79655 (Add Vec visualization to understand capacity) - rust-lang#80172 (Use consistent punctuation for 'Prelude contents' docs) - rust-lang#80429 (Add regression test for mutual recursion in obligation forest) - rust-lang#80601 (Improve grammar in documentation of format strings) - rust-lang#81046 (Improve unknown external crate error) - rust-lang#81178 (Visit only terminators when removing landing pads) - rust-lang#81179 (Fix broken links with `--document-private-items` in the standard library) - rust-lang#81184 (Remove unnecessary `after_run` function) - rust-lang#81185 (Fix ICE in mir when evaluating SizeOf on unsized type) - rust-lang#81187 (Fix typo in counters.rs) - rust-lang#81219 (Document security implications of std::env::temp_dir) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 6c6ff48 + f37bab3 commit db3a450

File tree

6 files changed

+52
-26
lines changed

6 files changed

+52
-26
lines changed

alloc/src/fmt.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -282,21 +282,22 @@
282282
//! `%`. The actual grammar for the formatting syntax is:
283283
//!
284284
//! ```text
285-
//! format_string := <text> [ maybe-format <text> ] *
286-
//! maybe-format := '{' '{' | '}' '}' | <format>
285+
//! format_string := text [ maybe_format text ] *
286+
//! maybe_format := '{' '{' | '}' '}' | format
287287
//! format := '{' [ argument ] [ ':' format_spec ] '}'
288288
//! argument := integer | identifier
289289
//!
290-
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision][type]
290+
//! format_spec := [[fill]align][sign]['#']['0'][width]['.' precision]type
291291
//! fill := character
292292
//! align := '<' | '^' | '>'
293293
//! sign := '+' | '-'
294294
//! width := count
295295
//! precision := count | '*'
296-
//! type := identifier | '?' | ''
296+
//! type := '' | '?' | 'x?' | 'X?' | identifier
297297
//! count := parameter | integer
298298
//! parameter := argument '$'
299299
//! ```
300+
//! In the above grammar, `text` may not contain any `'{'` or `'}'` characters.
300301
//!
301302
//! # Formatting traits
302303
//!

alloc/src/vec/mod.rs

+22
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,27 @@ mod spec_extend;
285285
/// you would see if you coerced it to a slice), followed by [`capacity`]` -
286286
/// `[`len`] logically uninitialized, contiguous elements.
287287
///
288+
/// A vector containing the elements `'a'` and `'b'` with capacity 4 can be
289+
/// visualized as below. The top part is the `Vec` struct, it contains a
290+
/// pointer to the head of the allocation in the heap, length and capacity.
291+
/// The bottom part is the allocation on the heap, a contiguous memory block.
292+
///
293+
/// ```text
294+
/// ptr len capacity
295+
/// +--------+--------+--------+
296+
/// | 0x0123 | 2 | 4 |
297+
/// +--------+--------+--------+
298+
/// |
299+
/// v
300+
/// Heap +--------+--------+--------+--------+
301+
/// | 'a' | 'b' | uninit | uninit |
302+
/// +--------+--------+--------+--------+
303+
/// ```
304+
///
305+
/// - **uninit** represents memory that is not initialized, see [`MaybeUninit`].
306+
/// - Note: the ABI is not stable and `Vec` makes no guarantees about its memory
307+
/// layout (including the order of fields).
308+
///
288309
/// `Vec` will never perform a "small optimization" where elements are actually
289310
/// stored on the stack for two reasons:
290311
///
@@ -345,6 +366,7 @@ mod spec_extend;
345366
/// [`push`]: Vec::push
346367
/// [`insert`]: Vec::insert
347368
/// [`reserve`]: Vec::reserve
369+
/// [`MaybeUninit`]: core::mem::MaybeUninit
348370
/// [owned slice]: Box
349371
/// [slice]: ../../std/primitive.slice.html
350372
/// [`&`]: ../../std/primitive.reference.html

alloc/src/vec/spec_from_iter_nested.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use super::{SpecExtend, Vec};
55

66
/// Another specialization trait for Vec::from_iter
77
/// necessary to manually prioritize overlapping specializations
8-
/// see [`SpecFromIter`] for details.
8+
/// see [`SpecFromIter`](super::SpecFromIter) for details.
99
pub(super) trait SpecFromIterNested<T, I> {
1010
fn from_iter(iter: I) -> Self;
1111
}

std/src/env.rs

+9-6
Original file line numberDiff line numberDiff line change
@@ -561,6 +561,13 @@ pub fn home_dir() -> Option<PathBuf> {
561561

562562
/// Returns the path of a temporary directory.
563563
///
564+
/// The temporary directory may be shared among users, or between processes
565+
/// with different privileges; thus, the creation of any files or directories
566+
/// in the temporary directory must use a secure method to create a uniquely
567+
/// named file. Creating a file or directory with a fixed or predictable name
568+
/// may result in "insecure temporary file" security vulnerabilities. Consider
569+
/// using a crate that securely creates temporary files or directories.
570+
///
564571
/// # Unix
565572
///
566573
/// Returns the value of the `TMPDIR` environment variable if it is
@@ -580,14 +587,10 @@ pub fn home_dir() -> Option<PathBuf> {
580587
///
581588
/// ```no_run
582589
/// use std::env;
583-
/// use std::fs::File;
584590
///
585-
/// fn main() -> std::io::Result<()> {
591+
/// fn main() {
586592
/// let mut dir = env::temp_dir();
587-
/// dir.push("foo.txt");
588-
///
589-
/// let f = File::create(dir)?;
590-
/// Ok(())
593+
/// println!("Temporary directory: {}", dir.display());
591594
/// }
592595
/// ```
593596
#[stable(feature = "env", since = "1.0.0")]

std/src/io/prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! The I/O Prelude
1+
//! The I/O Prelude.
22
//!
33
//! The purpose of this module is to alleviate imports of many common I/O traits
44
//! by adding a glob import to the top of I/O heavy modules:

std/src/prelude/mod.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//! The Rust Prelude.
1+
//! # The Rust Prelude
22
//!
33
//! Rust comes with a variety of things in its standard library. However, if
44
//! you had to manually import every single thing that you used, it would be
@@ -28,35 +28,35 @@
2828
//! The current version of the prelude (version 1) lives in
2929
//! [`std::prelude::v1`], and re-exports the following:
3030
//!
31-
//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]},
31+
//! * [`std::marker`]::{[`Copy`], [`Send`], [`Sized`], [`Sync`], [`Unpin`]}:
3232
//! marker traits that indicate fundamental properties of types.
33-
//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}, various
33+
//! * [`std::ops`]::{[`Drop`], [`Fn`], [`FnMut`], [`FnOnce`]}: various
3434
//! operations for both destructors and overloading `()`.
35-
//! * [`std::mem`]::[`drop`][`mem::drop`], a convenience function for explicitly
35+
//! * [`std::mem`]::[`drop`][`mem::drop`]: a convenience function for explicitly
3636
//! dropping a value.
37-
//! * [`std::boxed`]::[`Box`], a way to allocate values on the heap.
38-
//! * [`std::borrow`]::[`ToOwned`], the conversion trait that defines
37+
//! * [`std::boxed`]::[`Box`]: a way to allocate values on the heap.
38+
//! * [`std::borrow`]::[`ToOwned`]: the conversion trait that defines
3939
//! [`to_owned`], the generic method for creating an owned type from a
4040
//! borrowed type.
41-
//! * [`std::clone`]::[`Clone`], the ubiquitous trait that defines
41+
//! * [`std::clone`]::[`Clone`]: the ubiquitous trait that defines
4242
//! [`clone`][`Clone::clone`], the method for producing a copy of a value.
43-
//! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`] }, the
43+
//! * [`std::cmp`]::{[`PartialEq`], [`PartialOrd`], [`Eq`], [`Ord`]}: the
4444
//! comparison traits, which implement the comparison operators and are often
4545
//! seen in trait bounds.
46-
//! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}, generic
46+
//! * [`std::convert`]::{[`AsRef`], [`AsMut`], [`Into`], [`From`]}: generic
4747
//! conversions, used by savvy API authors to create overloaded methods.
4848
//! * [`std::default`]::[`Default`], types that have default values.
49-
//! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`]
50-
//! [`DoubleEndedIterator`], [`ExactSizeIterator`]}, iterators of various
49+
//! * [`std::iter`]::{[`Iterator`], [`Extend`], [`IntoIterator`],
50+
//! [`DoubleEndedIterator`], [`ExactSizeIterator`]}: iterators of various
5151
//! kinds.
5252
//! * [`std::option`]::[`Option`]::{[`self`][`Option`], [`Some`], [`None`]}, a
5353
//! type which expresses the presence or absence of a value. This type is so
5454
//! commonly used, its variants are also exported.
55-
//! * [`std::result`]::[`Result`]::{[`self`][`Result`], [`Ok`], [`Err`]}, a type
55+
//! * [`std::result`]::[`Result`]::{[`self`][`Result`], [`Ok`], [`Err`]}: a type
5656
//! for functions that may succeed or fail. Like [`Option`], its variants are
5757
//! exported as well.
58-
//! * [`std::string`]::{[`String`], [`ToString`]}, heap allocated strings.
59-
//! * [`std::vec`]::[`Vec`], a growable, heap-allocated vector.
58+
//! * [`std::string`]::{[`String`], [`ToString`]}: heap-allocated strings.
59+
//! * [`std::vec`]::[`Vec`]: a growable, heap-allocated vector.
6060
//!
6161
//! [`mem::drop`]: crate::mem::drop
6262
//! [`std::borrow`]: crate::borrow

0 commit comments

Comments
 (0)