1
Fork 0
rust/library/alloc/src
Matthias Krüger fae72a07dd
Rollup merge of #137105 - zachs18:cow-derefpure-restrict, r=Nadrieril
Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str.

Fixes #136046

`feature(deref_patterns)` tracking issue: https://github.com/rust-lang/rust/issues/87121

`Cow<'_, T>` should only implement `DerefPure` if its `Deref` impl is pure, which requires `<T::Owned as Borrow<T>>::borrow`  to be pure. This PR restricts `impl DerefPure for Cow<'_, T>` to `T: Sized + Clone`, `T = [U: Clone]`, and `T = str` (for all of whom `<T::Owned as Borrow<T>>::borrow` is implemented in the stdlib and is pure).

cc ``@Nadrieril``

------

An alternate approach would be to introduce a new `unsafe trait BorrowPure<T>` analogous to `DerefPure`  that could be implemented for `T: Sized`, `&T`, `&mut T`, `String`, `Vec`, `Box`, `PathBuf`, `OsString`, etc. https://github.com/rust-lang/rust/compare/master...zachs18:borrow-pure-trait
2025-02-17 06:38:15 +01:00
..
boxed replace placeholder version 2024-11-27 12:10:21 +00:00
collections Rollup merge of #136705 - compiler-errors:edition-library, r=jhpratt 2025-02-10 00:51:54 -08:00
ffi Mark extern blocks as unsafe 2025-02-09 17:11:13 +00:00
raw_vec Polymorphize RawVec 2024-08-09 20:06:26 -04:00
rc Use c"lit" for CStrings without unwrap 2024-12-02 18:16:36 +00:00
testing alloc: add #![warn(unreachable_pub)] 2025-01-20 18:50:56 +01:00
vec alloc: Apply missing_unsafe_on_extern 2025-02-13 13:10:27 -08:00
alloc.rs Mark extern blocks as unsafe 2025-02-09 17:11:13 +00:00
borrow.rs Restrict DerefPure for Cow<T> impl to T = impl Clone, [impl Clone], str. 2025-02-15 21:02:00 -06:00
boxed.rs docs: fix broken intra-doc links that never worked 2025-02-15 12:21:38 -07:00
bstr.rs Add doc aliases for BStr and BString 2025-01-22 09:19:24 +02:00
fmt.rs Added struct fmt::FormattingOptions 2024-12-05 21:48:01 +01:00
lib.miri.rs add 'x.py miri', and make it work for 'library/{core,alloc,std}' 2024-04-03 20:27:20 +02:00
lib.rs Rollup merge of #135488 - GrigorenkoPV:vec_pop_if, r=jhpratt 2025-02-09 19:44:50 +01:00
macros.rs Update the explanation for why we use box_new in vec! 2025-01-12 13:17:16 -05:00
raw_vec.rs alloc: add #![warn(unreachable_pub)] 2025-01-20 18:50:56 +01:00
rc.rs Rollup merge of #136228 - hkBst:patch-28, r=Mark-Simulacrum 2025-02-10 00:51:50 -08:00
slice.rs Auto merge of #134633 - GrigorenkoPV:get_disjoint_mut, r=cuviper 2025-02-13 21:09:31 +00:00
str.rs Inline str::repeat 2024-11-06 18:54:50 +00:00
string.rs Implement Extend<AsciiChar> for String 2025-02-08 16:51:04 -05:00
sync.rs Rustfmt 2025-02-08 22:12:13 +00:00
task.rs Stabilize noop_waker 2024-12-05 14:14:17 -08:00