Skip to content

Commit cde8145

Browse files
committed
Auto merge of rust-lang#129999 - matthiaskrgr:rollup-pzr9c8p, r=matthiaskrgr
Rollup of 11 pull requests Successful merges: - rust-lang#128919 (Add an internal lint that warns when accessing untracked data) - rust-lang#129472 (fix ICE when `asm_const` and `const_refs_to_static` are combined) - rust-lang#129653 (clarify that addr_of creates read-only pointers) - rust-lang#129775 (bootstrap: Try to track down why `initial_libdir` sometimes fails) - rust-lang#129939 (explain why Rvalue::Len still exists) - rust-lang#129942 (copy rustc rustlib artifacts from ci-rustc) - rust-lang#129943 (use the bootstrapped compiler for `test-float-parse` test) - rust-lang#129944 (Add compat note for trait solver change) - rust-lang#129947 (Add digit separators in `Duration` examples) - rust-lang#129955 (Temporarily remove fmease from the review rotation) - rust-lang#129957 (forward linker option to lint-docs) r? `@ghost` `@rustbot` modify labels: rollup
2 parents e51a0bc + ab4b4f8 commit cde8145

File tree

2 files changed

+22
-14
lines changed

2 files changed

+22
-14
lines changed

Diff for: core/src/ptr/mod.rs

+8
Original file line numberDiff line numberDiff line change
@@ -2277,6 +2277,14 @@ impl<F: FnPtr> fmt::Debug for F {
22772277
/// `addr_of!(expr)` is equivalent to `&raw const expr`. The macro is *soft-deprecated*;
22782278
/// use `&raw const` instead.
22792279
///
2280+
/// It is still an open question under which conditions writing through an `addr_of!`-created
2281+
/// pointer is permitted. If the place `expr` evaluates to is based on a raw pointer, then the
2282+
/// result of `addr_of!` inherits all permissions from that raw pointer. However, if the place is
2283+
/// based on a reference, local variable, or `static`, then until all details are decided, the same
2284+
/// rules as for shared references apply: it is UB to write through a pointer created with this
2285+
/// operation, except for bytes located inside an `UnsafeCell`. Use `&raw mut` (or [`addr_of_mut`])
2286+
/// to create a raw pointer that definitely permits mutation.
2287+
///
22802288
/// Creating a reference with `&`/`&mut` is only allowed if the pointer is properly aligned
22812289
/// and points to initialized data. For cases where those requirements do not hold,
22822290
/// raw pointers should be used instead. However, `&expr as *const _` creates a reference

Diff for: core/src/time.rs

+14-14
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ impl Duration {
250250
/// ```
251251
/// use std::time::Duration;
252252
///
253-
/// let duration = Duration::from_millis(2569);
253+
/// let duration = Duration::from_millis(2_569);
254254
///
255255
/// assert_eq!(2, duration.as_secs());
256256
/// assert_eq!(569_000_000, duration.subsec_nanos());
@@ -279,7 +279,7 @@ impl Duration {
279279
/// let duration = Duration::from_micros(1_000_002);
280280
///
281281
/// assert_eq!(1, duration.as_secs());
282-
/// assert_eq!(2000, duration.subsec_nanos());
282+
/// assert_eq!(2_000, duration.subsec_nanos());
283283
/// ```
284284
#[stable(feature = "duration_from_micros", since = "1.27.0")]
285285
#[must_use]
@@ -472,7 +472,7 @@ impl Duration {
472472
/// ```
473473
/// use std::time::Duration;
474474
///
475-
/// let duration = Duration::new(5, 730023852);
475+
/// let duration = Duration::new(5, 730_023_852);
476476
/// assert_eq!(duration.as_secs(), 5);
477477
/// ```
478478
///
@@ -501,7 +501,7 @@ impl Duration {
501501
/// ```
502502
/// use std::time::Duration;
503503
///
504-
/// let duration = Duration::from_millis(5432);
504+
/// let duration = Duration::from_millis(5_432);
505505
/// assert_eq!(duration.as_secs(), 5);
506506
/// assert_eq!(duration.subsec_millis(), 432);
507507
/// ```
@@ -547,7 +547,7 @@ impl Duration {
547547
/// ```
548548
/// use std::time::Duration;
549549
///
550-
/// let duration = Duration::from_millis(5010);
550+
/// let duration = Duration::from_millis(5_010);
551551
/// assert_eq!(duration.as_secs(), 5);
552552
/// assert_eq!(duration.subsec_nanos(), 10_000_000);
553553
/// ```
@@ -566,8 +566,8 @@ impl Duration {
566566
/// ```
567567
/// use std::time::Duration;
568568
///
569-
/// let duration = Duration::new(5, 730023852);
570-
/// assert_eq!(duration.as_millis(), 5730);
569+
/// let duration = Duration::new(5, 730_023_852);
570+
/// assert_eq!(duration.as_millis(), 5_730);
571571
/// ```
572572
#[stable(feature = "duration_as_u128", since = "1.33.0")]
573573
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@@ -584,8 +584,8 @@ impl Duration {
584584
/// ```
585585
/// use std::time::Duration;
586586
///
587-
/// let duration = Duration::new(5, 730023852);
588-
/// assert_eq!(duration.as_micros(), 5730023);
587+
/// let duration = Duration::new(5, 730_023_852);
588+
/// assert_eq!(duration.as_micros(), 5_730_023);
589589
/// ```
590590
#[stable(feature = "duration_as_u128", since = "1.33.0")]
591591
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@@ -602,8 +602,8 @@ impl Duration {
602602
/// ```
603603
/// use std::time::Duration;
604604
///
605-
/// let duration = Duration::new(5, 730023852);
606-
/// assert_eq!(duration.as_nanos(), 5730023852);
605+
/// let duration = Duration::new(5, 730_023_852);
606+
/// assert_eq!(duration.as_nanos(), 5_730_023_852);
607607
/// ```
608608
#[stable(feature = "duration_as_u128", since = "1.33.0")]
609609
#[rustc_const_stable(feature = "duration_as_u128", since = "1.33.0")]
@@ -879,7 +879,7 @@ impl Duration {
879879
/// use std::time::Duration;
880880
///
881881
/// let dur = Duration::new(2, 345_678_000);
882-
/// assert_eq!(dur.as_millis_f64(), 2345.678);
882+
/// assert_eq!(dur.as_millis_f64(), 2_345.678);
883883
/// ```
884884
#[unstable(feature = "duration_millis_float", issue = "122451")]
885885
#[must_use]
@@ -900,7 +900,7 @@ impl Duration {
900900
/// use std::time::Duration;
901901
///
902902
/// let dur = Duration::new(2, 345_678_000);
903-
/// assert_eq!(dur.as_millis_f32(), 2345.678);
903+
/// assert_eq!(dur.as_millis_f32(), 2_345.678);
904904
/// ```
905905
#[unstable(feature = "duration_millis_float", issue = "122451")]
906906
#[must_use]
@@ -1017,7 +1017,7 @@ impl Duration {
10171017
///
10181018
/// let dur = Duration::new(2, 700_000_000);
10191019
/// assert_eq!(dur.mul_f32(3.14), Duration::new(8, 478_000_641));
1020-
/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847800, 0));
1020+
/// assert_eq!(dur.mul_f32(3.14e5), Duration::new(847_800, 0));
10211021
/// ```
10221022
#[stable(feature = "duration_float", since = "1.38.0")]
10231023
#[must_use = "this returns the result of the operation, \

0 commit comments

Comments
 (0)