diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2025-01-30 20:47:08 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-01-30 20:47:08 +0100 |
| commit | 410442f61044ebc8b9dc7659748536e9418f138c (patch) | |
| tree | 2e9f5eb927fee195b645e7c6d1f024ee158f1590 | |
| parent | 41c8ce99a986f43be0744b7c3ed29130a9fef01e (diff) | |
| parent | b320e1741c738363184c87657f972a739d704908 (diff) | |
| download | rust-410442f61044ebc8b9dc7659748536e9418f138c.tar.gz rust-410442f61044ebc8b9dc7659748536e9418f138c.zip | |
Rollup merge of #136271 - Sky9x:debug-maybeuninit-footgun, r=tgross35
Remove minor future footgun in `impl Debug for MaybeUninit` No longer breaks if `MaybeUninit` moves modules (technically it could break if `MaybeUninit` were renamed but realistically that will never happen) Debug impl originally added in #133282
| -rw-r--r-- | library/core/src/mem/maybe_uninit.rs | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/library/core/src/mem/maybe_uninit.rs b/library/core/src/mem/maybe_uninit.rs index ac5307a671d..0d8c3ef906b 100644 --- a/library/core/src/mem/maybe_uninit.rs +++ b/library/core/src/mem/maybe_uninit.rs @@ -276,10 +276,9 @@ impl<T: Copy> Clone for MaybeUninit<T> { impl<T> fmt::Debug for MaybeUninit<T> { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { // NB: there is no `.pad_fmt` so we can't use a simpler `format_args!("MaybeUninit<{..}>"). - // This needs to be adjusted if `MaybeUninit` moves modules. let full_name = type_name::<Self>(); - let short_name = full_name.split_once("mem::maybe_uninit::").unwrap().1; - f.pad(short_name) + let prefix_len = full_name.find("MaybeUninit").unwrap(); + f.pad(&full_name[prefix_len..]) } } |
