mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 07:14:28 +00:00
e17a222a0a
deref patterns: impl `DerefPure` for more std types Context: [deref patterns](https://github.com/rust-lang/rust/issues/87121). The requirements of `DerefPure` aren't precise yet, but these types unambiguously satisfy them. Interestingly, a hypothetical `impl DerefMut for Cow` that does a `Clone` would *not* be eligible for `DerefPure` if we allow mixing deref patterns with normal patterns. If the following is exhaustive then the `DerefMut` would cause UB: ```rust match &mut Cow::Borrowed(&()) { Cow::Owned(_) => ..., // Doesn't match deref!(_x) if false => ..., // Causes the variant to switch to `Owned` Cow::Borrowed(_) => ..., // Doesn't match // We reach unreachable } ``` |
||
---|---|---|
.. | ||
alloc | ||
backtrace@e151306182 | ||
core | ||
panic_abort | ||
panic_unwind | ||
portable-simd | ||
proc_macro | ||
profiler_builtins | ||
rtstartup | ||
rustc-std-workspace-alloc | ||
rustc-std-workspace-core | ||
rustc-std-workspace-std | ||
std | ||
stdarch@c0257c1660 | ||
sysroot | ||
test | ||
unwind |