From 1bfb3ad051fee3e19a4d2f8d5bb9144fded543cb Mon Sep 17 00:00:00 2001 From: Darren Kulp Date: Fri, 17 Jul 2020 10:11:11 -0700 Subject: Avoid needless `std::mem::replace` In Rust 1.45.0, `std::mem::replace` gained the `#[must_use]` attribute, causing a new diagnostic for some `bindgen` code : error: unused return value of `std::mem::replace` that must be used --> src/ir/comp.rs:751:17 | 751 | / mem::replace( 752 | | self, 753 | | CompFields::AfterComputingBitfieldUnits { 754 | | fields, 755 | | has_bitfield_units, 756 | | }, 757 | | ); | |__________________^ | = note: `-D unused-must-use` implied by `-D warnings` = note: if you don't need the old value, you can just assign the new value directly error: unused return value of `std::mem::replace` that must be used --> src/ir/comp.rs:760:17 | 760 | mem::replace(self, CompFields::ErrorComputingBitfieldUnits); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: if you don't need the old value, you can just assign the new value directly error: aborting due to 2 previous errors --- src/ir/comp.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/ir/comp.rs b/src/ir/comp.rs index 4eeb4745..9bb429d2 100644 --- a/src/ir/comp.rs +++ b/src/ir/comp.rs @@ -748,16 +748,13 @@ impl CompFields { match result { Ok((fields, has_bitfield_units)) => { - mem::replace( - self, - CompFields::AfterComputingBitfieldUnits { - fields, - has_bitfield_units, - }, - ); + *self = CompFields::AfterComputingBitfieldUnits { + fields, + has_bitfield_units, + }; } Err(()) => { - mem::replace(self, CompFields::ErrorComputingBitfieldUnits); + *self = CompFields::ErrorComputingBitfieldUnits; } } } -- cgit v1.2.3