Skip to content

Commit

Permalink
Unrolled build for rust-lang#136271
Browse files Browse the repository at this point in the history
Rollup merge of rust-lang#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 rust-lang#133282
  • Loading branch information
rust-timer authored Jan 31, 2025
2 parents a730edc + b320e17 commit c8dff04
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions library/core/src/mem/maybe_uninit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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..])
}
}

Expand Down

0 comments on commit c8dff04

Please sign in to comment.