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
This commit is contained in:
commit
410442f610
1 changed files with 2 additions and 3 deletions
|
@ -276,10 +276,9 @@ impl<T: Copy> Clone for MaybeUninit<T> {
|
||||||
impl<T> fmt::Debug for MaybeUninit<T> {
|
impl<T> fmt::Debug for MaybeUninit<T> {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
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<{..}>").
|
// 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 full_name = type_name::<Self>();
|
||||||
let short_name = full_name.split_once("mem::maybe_uninit::").unwrap().1;
|
let prefix_len = full_name.find("MaybeUninit").unwrap();
|
||||||
f.pad(short_name)
|
f.pad(&full_name[prefix_len..])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue