Skip to content

Commit af6d886

Browse files
committed
Auto merge of #72187 - RalfJung:rollup-a7a9jdi, r=RalfJung
Rollup of 12 pull requests Successful merges: - #71525 (`prefix` should not be mutable.) - #71741 (Pointer printing: do not print 0 offset) - #71870 (Be slightly more precise about any::type_name()'s guarantees.) - #71909 (Document From trait for Option implementations) - #71964 (Fix bootstrap failing on win32) - #72137 (Clean up E0581 explanation) - #72138 (Add doc comment for `rustc_middle::mir::mono::Linkage`) - #72150 (Remove UnnormalizedProjection) - #72151 (Update books) - #72163 (docs: remove comment referencing non-existent method) - #72169 (Clean up E0582 explanation) - #72183 (Fix Arc::decr_strong_count doc test) Failed merges: r? @ghost
2 parents 7c34d8d + 56986be commit af6d886

File tree

72 files changed

+228
-239
lines changed

Some content is hidden

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

72 files changed

+228
-239
lines changed

src/bootstrap/bootstrap.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -180,13 +180,16 @@ def format_build_time(duration):
180180
def default_build_triple():
181181
"""Build triple as in LLVM"""
182182
default_encoding = sys.getdefaultencoding()
183-
required = not sys.platform == 'win32'
184-
ostype = require(["uname", "-s"], exit=required).decode(default_encoding)
185-
cputype = require(['uname', '-m'], exit=required).decode(default_encoding)
183+
required = sys.platform != 'win32'
184+
ostype = require(["uname", "-s"], exit=required)
185+
cputype = require(['uname', '-m'], exit=required)
186186

187187
if ostype is None or cputype is None:
188188
return 'x86_64-pc-windows-msvc'
189189

190+
ostype = ostype.decode(default_encoding)
191+
cputype = cputype.decode(default_encoding)
192+
190193
# The goal here is to come up with the same triple as LLVM would,
191194
# at least for the subset of platforms we're willing to target.
192195
ostype_mapper = {

src/liballoc/sync.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,12 +835,14 @@ impl<T: ?Sized> Arc<T> {
835835
///
836836
/// unsafe {
837837
/// let ptr = Arc::into_raw(five);
838-
/// Arc::decr_strong_count(ptr);
838+
/// Arc::incr_strong_count(ptr);
839839
///
840-
/// // This assertion is deterministic because we haven't shared
840+
/// // Those assertions are deterministic because we haven't shared
841841
/// // the `Arc` between threads.
842842
/// let five = Arc::from_raw(ptr);
843-
/// assert_eq!(0, Arc::strong_count(&five));
843+
/// assert_eq!(2, Arc::strong_count(&five));
844+
/// Arc::decr_strong_count(ptr);
845+
/// assert_eq!(1, Arc::strong_count(&five));
844846
/// }
845847
/// ```
846848
#[inline]

src/libcore/any.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -446,14 +446,16 @@ impl TypeId {
446446
/// # Note
447447
///
448448
/// This is intended for diagnostic use. The exact contents and format of the
449-
/// string are not specified, other than being a best-effort description of the
450-
/// type. For example, `type_name::<Option<String>>()` could return the
451-
/// `"Option<String>"` or `"std::option::Option<std::string::String>"`, but not
452-
/// `"foobar"`. In addition, the output may change between versions of the
453-
/// compiler.
449+
/// string returned are not specified, other than being a best-effort
450+
/// description of the type. For example, amongst the strings
451+
/// that `type_name::<Option<String>>()` might return are `"Option<String>"` and
452+
/// `"std::option::Option<std::string::String>"`.
454453
///
455-
/// The type name should not be considered a unique identifier of a type;
456-
/// multiple types may share the same type name.
454+
/// The returned string must not be considered to be a unique identifier of a
455+
/// type as multiple types may map to the same type name. Similarly, there is no
456+
/// guarantee that all parts of a type will appear in the returned string: for
457+
/// example, lifetime specifiers are currently not included. In addition, the
458+
/// output may change between versions of the compiler.
457459
///
458460
/// The current implementation uses the same infrastructure as compiler
459461
/// diagnostics and debuginfo, but this is not guaranteed.

src/libcore/option.rs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1357,20 +1357,65 @@ impl<'a, T> IntoIterator for &'a mut Option<T> {
13571357

13581358
#[stable(since = "1.12.0", feature = "option_from")]
13591359
impl<T> From<T> for Option<T> {
1360+
/// Copies `val` into a new `Some`.
1361+
///
1362+
/// # Examples
1363+
///
1364+
/// ```
1365+
/// let o: Option<u8> = Option::from(67);
1366+
///
1367+
/// assert_eq!(Some(67), o);
1368+
/// ```
13601369
fn from(val: T) -> Option<T> {
13611370
Some(val)
13621371
}
13631372
}
13641373

13651374
#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")]
13661375
impl<'a, T> From<&'a Option<T>> for Option<&'a T> {
1376+
/// Converts from `&Option<T>` to `Option<&T>`.
1377+
///
1378+
/// # Examples
1379+
///
1380+
/// Converts an `Option<`[`String`]`>` into an `Option<`[`usize`]`>`, preserving the original.
1381+
/// The [`map`] method takes the `self` argument by value, consuming the original,
1382+
/// so this technique uses `as_ref` to first take an `Option` to a reference
1383+
/// to the value inside the original.
1384+
///
1385+
/// [`map`]: ../../std/option/enum.Option.html#method.map
1386+
/// [`String`]: ../../std/string/struct.String.html
1387+
/// [`usize`]: ../../std/primitive.usize.html
1388+
///
1389+
/// ```
1390+
/// let s: Option<String> = Some(String::from("Hello, Rustaceans!"));
1391+
/// let o: Option<usize> = Option::from(&s).map(|ss: &String| ss.len());
1392+
///
1393+
/// println!("Can still print s: {:?}", s);
1394+
///
1395+
/// assert_eq!(o, Some(18));
1396+
/// ```
13671397
fn from(o: &'a Option<T>) -> Option<&'a T> {
13681398
o.as_ref()
13691399
}
13701400
}
13711401

13721402
#[stable(feature = "option_ref_from_ref_option", since = "1.30.0")]
13731403
impl<'a, T> From<&'a mut Option<T>> for Option<&'a mut T> {
1404+
/// Converts from `&mut Option<T>` to `Option<&mut T>`
1405+
///
1406+
/// # Examples
1407+
///
1408+
/// ```
1409+
/// let mut s = Some(String::from("Hello"));
1410+
/// let o: Option<&mut String> = Option::from(&mut s);
1411+
///
1412+
/// match o {
1413+
/// Some(t) => *t = String::from("Hello, Rustaceans!"),
1414+
/// None => (),
1415+
/// }
1416+
///
1417+
/// assert_eq!(s, Some(String::from("Hello, Rustaceans!")));
1418+
/// ```
13741419
fn from(o: &'a mut Option<T>) -> Option<&'a mut T> {
13751420
o.as_mut()
13761421
}

0 commit comments

Comments
 (0)