Skip to content

Commit d48df9d

Browse files
committed
Auto merge of rust-lang#137235 - matthiaskrgr:rollup-2kjua2t, r=matthiaskrgr
Rollup of 10 pull requests Successful merges: - rust-lang#135711 (Do not ICE on default_field_value const with lifetimes) - rust-lang#136599 (librustdoc: more usages of `Joined::joined`) - rust-lang#136876 (Locking documentation updates) - rust-lang#137000 (Deeply normalize item bounds in new solver) - rust-lang#137126 (fix docs for inherent str constructors) - rust-lang#137161 (Pattern Migration 2024: fix incorrect messages/suggestions when errors arise in macro expansions) - rust-lang#137191 (Update mdbook and move error_index_generator) - rust-lang#137203 (Improve MIR modification) - rust-lang#137206 (Make E0599 a structured error) - rust-lang#137218 (misc `layout_of` cleanup) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 102e63b + 1eeac08 commit d48df9d

File tree

2 files changed

+66
-46
lines changed

2 files changed

+66
-46
lines changed

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

+8-8
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ impl str {
198198
/// Basic usage:
199199
///
200200
/// ```
201-
/// use std::str;
201+
/// #![feature(inherent_str_constructors)]
202202
///
203203
/// // some bytes, in a vector
204204
/// let sparkle_heart = vec![240, 159, 146, 150];
@@ -207,13 +207,13 @@ impl str {
207207
/// let sparkle_heart = str::from_utf8(&sparkle_heart)?;
208208
///
209209
/// assert_eq!("💖", sparkle_heart);
210-
/// # Ok::<_, str::Utf8Error>(())
210+
/// # Ok::<_, std::str::Utf8Error>(())
211211
/// ```
212212
///
213213
/// Incorrect bytes:
214214
///
215215
/// ```
216-
/// use std::str;
216+
/// #![feature(inherent_str_constructors)]
217217
///
218218
/// // some invalid bytes, in a vector
219219
/// let sparkle_heart = vec![0, 159, 146, 150];
@@ -227,7 +227,7 @@ impl str {
227227
/// A "stack allocated string":
228228
///
229229
/// ```
230-
/// use std::str;
230+
/// #![feature(inherent_str_constructors)]
231231
///
232232
/// // some bytes, in a stack-allocated array
233233
/// let sparkle_heart = [240, 159, 146, 150];
@@ -250,7 +250,7 @@ impl str {
250250
/// Basic usage:
251251
///
252252
/// ```
253-
/// use std::str;
253+
/// #![feature(inherent_str_constructors)]
254254
///
255255
/// // "Hello, Rust!" as a mutable vector
256256
/// let mut hellorust = vec![72, 101, 108, 108, 111, 44, 32, 82, 117, 115, 116, 33];
@@ -264,7 +264,7 @@ impl str {
264264
/// Incorrect bytes:
265265
///
266266
/// ```
267-
/// use std::str;
267+
/// #![feature(inherent_str_constructors)]
268268
///
269269
/// // Some invalid bytes in a mutable vector
270270
/// let mut invalid = vec![128, 223];
@@ -294,7 +294,7 @@ impl str {
294294
/// Basic usage:
295295
///
296296
/// ```
297-
/// use std::str;
297+
/// #![feature(inherent_str_constructors)]
298298
///
299299
/// // some bytes, in a vector
300300
/// let sparkle_heart = vec![240, 159, 146, 150];
@@ -324,7 +324,7 @@ impl str {
324324
/// Basic usage:
325325
///
326326
/// ```
327-
/// use std::str;
327+
/// #![feature(inherent_str_constructors)]
328328
///
329329
/// let mut heart = vec![240, 159, 146, 150];
330330
/// let heart = unsafe { str::from_utf8_unchecked_mut(&mut heart) };

Diff for: std/src/fs.rs

+58-38
Original file line numberDiff line numberDiff line change
@@ -624,20 +624,20 @@ impl File {
624624
self.inner.datasync()
625625
}
626626

627-
/// Acquire an exclusive advisory lock on the file. Blocks until the lock can be acquired.
627+
/// Acquire an exclusive lock on the file. Blocks until the lock can be acquired.
628628
///
629-
/// This acquires an exclusive advisory lock; no other file handle to this file may acquire
630-
/// another lock.
629+
/// This acquires an exclusive lock; no other file handle to this file may acquire another lock.
631630
///
632-
/// If this file handle/descriptor, or a clone of it, already holds an advisory lock the exact
633-
/// behavior is unspecified and platform dependent, including the possibility that it will
634-
/// deadlock. However, if this method returns, then an exclusive lock is held.
631+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
632+
/// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
633+
/// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
634+
/// cause non-lockholders to block.
635635
///
636-
/// If the file not open for writing, it is unspecified whether this function returns an error.
636+
/// If this file handle/descriptor, or a clone of it, already holds an lock the exact behavior
637+
/// is unspecified and platform dependent, including the possibility that it will deadlock.
638+
/// However, if this method returns, then an exclusive lock is held.
637639
///
638-
/// Note, this is an advisory lock meant to interact with [`lock_shared`], [`try_lock`],
639-
/// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
640-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
640+
/// If the file not open for writing, it is unspecified whether this function returns an error.
641641
///
642642
/// The lock will be released when this file (along with any other file descriptors/handles
643643
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -648,8 +648,12 @@ impl File {
648648
/// and the `LockFileEx` function on Windows with the `LOCKFILE_EXCLUSIVE_LOCK` flag. Note that,
649649
/// this [may change in the future][changes].
650650
///
651+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
652+
/// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
653+
///
651654
/// [changes]: io#platform-specific-behavior
652655
///
656+
/// [`lock`]: File::lock
653657
/// [`lock_shared`]: File::lock_shared
654658
/// [`try_lock`]: File::try_lock
655659
/// [`try_lock_shared`]: File::try_lock_shared
@@ -674,18 +678,19 @@ impl File {
674678
self.inner.lock()
675679
}
676680

677-
/// Acquire a shared (non-exclusive) advisory lock on the file. Blocks until the lock can be acquired.
681+
/// Acquire a shared (non-exclusive) lock on the file. Blocks until the lock can be acquired.
678682
///
679-
/// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but
680-
/// none may hold an exclusive lock at the same time.
683+
/// This acquires a shared lock; more than one file handle may hold a shared lock, but none may
684+
/// hold an exclusive lock at the same time.
681685
///
682-
/// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact
683-
/// behavior is unspecified and platform dependent, including the possibility that it will
684-
/// deadlock. However, if this method returns, then a shared lock is held.
686+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
687+
/// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
688+
/// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
689+
/// cause non-lockholders to block.
685690
///
686-
/// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`],
687-
/// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
688-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
691+
/// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior
692+
/// is unspecified and platform dependent, including the possibility that it will deadlock.
693+
/// However, if this method returns, then a shared lock is held.
689694
///
690695
/// The lock will be released when this file (along with any other file descriptors/handles
691696
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -696,9 +701,13 @@ impl File {
696701
/// and the `LockFileEx` function on Windows. Note that, this
697702
/// [may change in the future][changes].
698703
///
704+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
705+
/// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
706+
///
699707
/// [changes]: io#platform-specific-behavior
700708
///
701709
/// [`lock`]: File::lock
710+
/// [`lock_shared`]: File::lock_shared
702711
/// [`try_lock`]: File::try_lock
703712
/// [`try_lock_shared`]: File::try_lock_shared
704713
/// [`unlock`]: File::unlock
@@ -722,24 +731,23 @@ impl File {
722731
self.inner.lock_shared()
723732
}
724733

725-
/// Try to acquire an exclusive advisory lock on the file.
734+
/// Try to acquire an exclusive lock on the file.
726735
///
727736
/// Returns `Ok(false)` if a different lock is already held on this file (via another
728737
/// handle/descriptor).
729738
///
730-
/// This acquires an exclusive advisory lock; no other file handle to this file may acquire
731-
/// another lock.
739+
/// This acquires an exclusive lock; no other file handle to this file may acquire another lock.
732740
///
733-
/// If this file handle/descriptor, or a clone of it, already holds an advisory lock, the exact
734-
/// behavior is unspecified and platform dependent, including the possibility that it will
735-
/// deadlock. However, if this method returns `Ok(true)`, then it has acquired an exclusive
736-
/// lock.
741+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
742+
/// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
743+
/// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
744+
/// cause non-lockholders to block.
737745
///
738-
/// If the file not open for writing, it is unspecified whether this function returns an error.
746+
/// If this file handle/descriptor, or a clone of it, already holds an lock, the exact behavior
747+
/// is unspecified and platform dependent, including the possibility that it will deadlock.
748+
/// However, if this method returns `Ok(true)`, then it has acquired an exclusive lock.
739749
///
740-
/// Note, this is an advisory lock meant to interact with [`lock`], [`lock_shared`],
741-
/// [`try_lock_shared`], and [`unlock`]. Its interactions with other methods, such as [`read`]
742-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
750+
/// If the file not open for writing, it is unspecified whether this function returns an error.
743751
///
744752
/// The lock will be released when this file (along with any other file descriptors/handles
745753
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
@@ -751,10 +759,14 @@ impl File {
751759
/// and `LOCKFILE_FAIL_IMMEDIATELY` flags. Note that, this
752760
/// [may change in the future][changes].
753761
///
762+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
763+
/// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
764+
///
754765
/// [changes]: io#platform-specific-behavior
755766
///
756767
/// [`lock`]: File::lock
757768
/// [`lock_shared`]: File::lock_shared
769+
/// [`try_lock`]: File::try_lock
758770
/// [`try_lock_shared`]: File::try_lock_shared
759771
/// [`unlock`]: File::unlock
760772
/// [`read`]: Read::read
@@ -777,22 +789,23 @@ impl File {
777789
self.inner.try_lock()
778790
}
779791

780-
/// Try to acquire a shared (non-exclusive) advisory lock on the file.
792+
/// Try to acquire a shared (non-exclusive) lock on the file.
781793
///
782794
/// Returns `Ok(false)` if an exclusive lock is already held on this file (via another
783795
/// handle/descriptor).
784796
///
785-
/// This acquires a shared advisory lock; more than one file handle may hold a shared lock, but
786-
/// none may hold an exclusive lock at the same time.
797+
/// This acquires a shared lock; more than one file handle may hold a shared lock, but none may
798+
/// hold an exclusive lock at the same time.
787799
///
788-
/// If this file handle, or a clone of it, already holds an advisory lock, the exact behavior is
800+
/// This lock may be advisory or mandatory. This lock is meant to interact with [`lock`],
801+
/// [`try_lock`], [`lock_shared`], [`try_lock_shared`], and [`unlock`]. Its interactions with
802+
/// other methods, such as [`read`] and [`write`] are platform specific, and it may or may not
803+
/// cause non-lockholders to block.
804+
///
805+
/// If this file handle, or a clone of it, already holds an lock, the exact behavior is
789806
/// unspecified and platform dependent, including the possibility that it will deadlock.
790807
/// However, if this method returns `Ok(true)`, then it has acquired a shared lock.
791808
///
792-
/// Note, this is an advisory lock meant to interact with [`lock`], [`try_lock`],
793-
/// [`try_lock`], and [`unlock`]. Its interactions with other methods, such as [`read`]
794-
/// and [`write`] are platform specific, and it may or may not cause non-lockholders to block.
795-
///
796809
/// The lock will be released when this file (along with any other file descriptors/handles
797810
/// duplicated or inherited from it) is closed, or if the [`unlock`] method is called.
798811
///
@@ -803,11 +816,15 @@ impl File {
803816
/// `LOCKFILE_FAIL_IMMEDIATELY` flag. Note that, this
804817
/// [may change in the future][changes].
805818
///
819+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
820+
/// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
821+
///
806822
/// [changes]: io#platform-specific-behavior
807823
///
808824
/// [`lock`]: File::lock
809825
/// [`lock_shared`]: File::lock_shared
810826
/// [`try_lock`]: File::try_lock
827+
/// [`try_lock_shared`]: File::try_lock_shared
811828
/// [`unlock`]: File::unlock
812829
/// [`read`]: Read::read
813830
/// [`write`]: Write::write
@@ -844,6 +861,9 @@ impl File {
844861
/// and the `UnlockFile` function on Windows. Note that, this
845862
/// [may change in the future][changes].
846863
///
864+
/// On Windows, locking a file will fail if the file is opened only for append. To lock a file,
865+
/// open it with one of `.read(true)`, `.read(true).append(true)`, or `.write(true)`.
866+
///
847867
/// [changes]: io#platform-specific-behavior
848868
///
849869
/// # Examples

0 commit comments

Comments
 (0)