Skip to content

Commit 479d848

Browse files
committed
Eliminate uses of struct_formatter
This pattern was previously used with `cfg` fields but is no longer needed. This is the version of 8d68ec6 ("Eliminate uses of struct_formatter") for `main`.
1 parent f508b33 commit 479d848

File tree

3 files changed

+74
-79
lines changed

3 files changed

+74
-79
lines changed

src/unix/aix/mod.rs

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -592,20 +592,19 @@ cfg_if! {
592592

593593
impl PartialEq for sigaction {
594594
fn eq(&self, other: &sigaction) -> bool {
595-
let union_eq = self.sa_union == other.sa_union;
596595
self.sa_mask == other.sa_mask
597596
&& self.sa_flags == other.sa_flags
598-
&& union_eq
597+
&& self.sa_union == other.sa_union
599598
}
600599
}
601600
impl Eq for sigaction {}
602601
impl ::fmt::Debug for sigaction {
603602
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
604-
let mut struct_formatter = f.debug_struct("sigaction");
605-
struct_formatter.field("sa_union", &self.sa_union);
606-
struct_formatter.field("sa_mask", &self.sa_mask);
607-
struct_formatter.field("sa_flags", &self.sa_flags);
608-
struct_formatter.finish()
603+
f.debug_struct("sigaction")
604+
.field("sa_union", &self.sa_union)
605+
.field("sa_mask", &self.sa_mask)
606+
.field("sa_flags", &self.sa_flags)
607+
.finish()
609608
}
610609
}
611610
impl ::hash::Hash for sigaction {
@@ -647,26 +646,25 @@ cfg_if! {
647646

648647
impl PartialEq for poll_ctl_ext {
649648
fn eq(&self, other: &poll_ctl_ext) -> bool {
650-
let union_eq = self.u == other.u;
651649
self.version == other.version
652650
&& self.command == other.command
653651
&& self.events == other.events
654652
&& self.fd == other.fd
655653
&& self.reversed64 == other.reversed64
656-
&& union_eq
654+
&& self.u == other.u
657655
}
658656
}
659657
impl Eq for poll_ctl_ext {}
660658
impl ::fmt::Debug for poll_ctl_ext {
661659
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
662-
let mut struct_formatter = f.debug_struct("poll_ctl_ext");
663-
struct_formatter.field("version", &self.version);
664-
struct_formatter.field("command", &self.command);
665-
struct_formatter.field("events", &self.events);
666-
struct_formatter.field("fd", &self.fd);
667-
struct_formatter.field("u", &self.u);
668-
struct_formatter.field("reversed64", &self.reversed64);
669-
struct_formatter.finish()
660+
f.debug_struct("poll_ctl_ext")
661+
.field("version", &self.version)
662+
.field("command", &self.command)
663+
.field("events", &self.events)
664+
.field("fd", &self.fd)
665+
.field("u", &self.u)
666+
.field("reversed64", &self.reversed64)
667+
.finish()
670668
}
671669
}
672670
impl ::hash::Hash for poll_ctl_ext {

src/unix/aix/powerpc64.rs

Lines changed: 52 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -308,18 +308,18 @@ cfg_if! {
308308
impl Eq for siginfo_t {}
309309
impl ::fmt::Debug for siginfo_t {
310310
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
311-
let mut struct_formatter = f.debug_struct("siginfo_t");
312-
struct_formatter.field("si_signo", &self.si_signo);
313-
struct_formatter.field("si_errno", &self.si_errno);
314-
struct_formatter.field("si_code", &self.si_code);
315-
struct_formatter.field("si_pid", &self.si_pid);
316-
struct_formatter.field("si_uid", &self.si_uid);
317-
struct_formatter.field("si_status", &self.si_status);
318-
struct_formatter.field("si_addr", &self.si_addr);
319-
struct_formatter.field("si_band", &self.si_band);
320-
struct_formatter.field("si_value", &self.si_value);
321-
struct_formatter.field("__si_flags", &self.__si_flags);
322-
struct_formatter.finish()
311+
f.debug_struct("siginfo_t")
312+
.field("si_signo", &self.si_signo)
313+
.field("si_errno", &self.si_errno)
314+
.field("si_code", &self.si_code)
315+
.field("si_pid", &self.si_pid)
316+
.field("si_uid", &self.si_uid)
317+
.field("si_status", &self.si_status)
318+
.field("si_addr", &self.si_addr)
319+
.field("si_band", &self.si_band)
320+
.field("si_value", &self.si_value)
321+
.field("__si_flags", &self.__si_flags)
322+
.finish()
323323
}
324324
}
325325
impl ::hash::Hash for siginfo_t {
@@ -375,13 +375,13 @@ cfg_if! {
375375
impl Eq for fileops_t {}
376376
impl ::fmt::Debug for fileops_t {
377377
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
378-
let mut struct_formatter = f.debug_struct("fileops_t");
379-
struct_formatter.field("fo_rw", &self.fo_rw);
380-
struct_formatter.field("fo_ioctl", &self.fo_ioctl);
381-
struct_formatter.field("fo_select", &self.fo_select);
382-
struct_formatter.field("fo_close", &self.fo_close);
383-
struct_formatter.field("fo_fstat", &self.fo_fstat);
384-
struct_formatter.finish()
378+
f.debug_struct("fileops_t")
379+
.field("fo_rw", &self.fo_rw)
380+
.field("fo_ioctl", &self.fo_ioctl)
381+
.field("fo_select", &self.fo_select)
382+
.field("fo_close", &self.fo_close)
383+
.field("fo_fstat", &self.fo_fstat)
384+
.finish()
385385
}
386386
}
387387
impl ::hash::Hash for fileops_t {
@@ -416,23 +416,23 @@ cfg_if! {
416416
impl Eq for file {}
417417
impl ::fmt::Debug for file {
418418
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
419-
let mut struct_formatter = f.debug_struct("file");
420-
struct_formatter.field("f_flag", &self.f_flag);
421-
struct_formatter.field("f_count", &self.f_count);
422-
struct_formatter.field("f_options", &self.f_options);
423-
struct_formatter.field("f_type", &self.f_type);
424-
struct_formatter.field("f_data", &self.f_data);
425-
struct_formatter.field("f_offset", &self.f_offset);
426-
struct_formatter.field("f_dir_off", &self.f_dir_off);
427-
struct_formatter.field("f_cred", &self.f_cred);
428-
struct_formatter.field("f_lock", &self.f_lock);
429-
struct_formatter.field("f_offset_lock", &self.f_offset_lock);
430-
struct_formatter.field("f_vinfo", &self.f_vinfo);
431-
struct_formatter.field("f_ops", &self.f_ops);
432-
struct_formatter.field("f_parentp", &self.f_parentp);
433-
struct_formatter.field("f_fnamep", &self.f_fnamep);
434-
struct_formatter.field("f_fdata", &self.f_fdata);
435-
struct_formatter.finish()
419+
f.debug_struct("file")
420+
.field("f_flag", &self.f_flag)
421+
.field("f_count", &self.f_count)
422+
.field("f_options", &self.f_options)
423+
.field("f_type", &self.f_type)
424+
.field("f_data", &self.f_data)
425+
.field("f_offset", &self.f_offset)
426+
.field("f_dir_off", &self.f_dir_off)
427+
.field("f_cred", &self.f_cred)
428+
.field("f_lock", &self.f_lock)
429+
.field("f_offset_lock", &self.f_offset_lock)
430+
.field("f_vinfo", &self.f_vinfo)
431+
.field("f_ops", &self.f_ops)
432+
.field("f_parentp", &self.f_parentp)
433+
.field("f_fnamep", &self.f_fnamep)
434+
.field("f_fdata", &self.f_fdata)
435+
.finish()
436436
}
437437
}
438438
impl ::hash::Hash for file {
@@ -499,16 +499,16 @@ cfg_if! {
499499
impl Eq for ld_info {}
500500
impl ::fmt::Debug for ld_info {
501501
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
502-
let mut struct_formatter = f.debug_struct("ld_info");
503-
struct_formatter.field("ldinfo_next", &self.ldinfo_next);
504-
struct_formatter.field("ldinfo_flags", &self.ldinfo_flags);
505-
struct_formatter.field("ldinfo_textorg", &self.ldinfo_textorg);
506-
struct_formatter.field("ldinfo_textsize", &self.ldinfo_textsize);
507-
struct_formatter.field("ldinfo_dataorg", &self.ldinfo_dataorg);
508-
struct_formatter.field("ldinfo_datasize", &self.ldinfo_datasize);
509-
struct_formatter.field("ldinfo_filename", &self.ldinfo_filename);
510-
struct_formatter.field("_file", &self._file);
511-
struct_formatter.finish()
502+
f.debug_struct("ld_info")
503+
.field("ldinfo_next", &self.ldinfo_next)
504+
.field("ldinfo_flags", &self.ldinfo_flags)
505+
.field("ldinfo_textorg", &self.ldinfo_textorg)
506+
.field("ldinfo_textsize", &self.ldinfo_textsize)
507+
.field("ldinfo_dataorg", &self.ldinfo_dataorg)
508+
.field("ldinfo_datasize", &self.ldinfo_datasize)
509+
.field("ldinfo_filename", &self.ldinfo_filename)
510+
.field("_file", &self._file)
511+
.finish()
512512
}
513513
}
514514
impl ::hash::Hash for ld_info {
@@ -564,12 +564,12 @@ cfg_if! {
564564
impl Eq for pollfd_ext {}
565565
impl ::fmt::Debug for pollfd_ext {
566566
fn fmt(&self, f: &mut ::fmt::Formatter<'_>) -> ::fmt::Result {
567-
let mut struct_formatter = f.debug_struct("pollfd_ext");
568-
struct_formatter.field("fd", &self.fd);
569-
struct_formatter.field("events", &self.events);
570-
struct_formatter.field("revents", &self.revents);
571-
struct_formatter.field("data", &self.data);
572-
struct_formatter.finish()
567+
f.debug_struct("pollfd_ext")
568+
.field("fd", &self.fd)
569+
.field("events", &self.events)
570+
.field("revents", &self.revents)
571+
.field("data", &self.data)
572+
.finish()
573573
}
574574
}
575575
impl ::hash::Hash for pollfd_ext {

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1730,16 +1730,13 @@ cfg_if! {
17301730
impl Eq for xucred {}
17311731
impl ::fmt::Debug for xucred {
17321732
fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result {
1733-
let mut struct_formatter = f.debug_struct("xucred");
1734-
struct_formatter.field("cr_version", &self.cr_version);
1735-
struct_formatter.field("cr_uid", &self.cr_uid);
1736-
struct_formatter.field("cr_ngroups", &self.cr_ngroups);
1737-
struct_formatter.field("cr_groups", &self.cr_groups);
1738-
struct_formatter.field(
1739-
"cr_pid__c_anonymous_union",
1740-
&self.cr_pid__c_anonymous_union
1741-
);
1742-
struct_formatter.finish()
1733+
f.debug_struct("xucred")
1734+
.field("cr_version", &self.cr_version)
1735+
.field("cr_uid", &self.cr_uid)
1736+
.field("cr_ngroups", &self.cr_ngroups)
1737+
.field("cr_groups", &self.cr_groups)
1738+
.field("cr_pid__c_anonymous_union", &self.cr_pid__c_anonymous_union)
1739+
.finish()
17431740
}
17441741
}
17451742
impl ::hash::Hash for xucred {

0 commit comments

Comments
 (0)