diff options
author | Darren Kulp <darren@kulp.ch> | 2020-07-17 10:11:11 -0700 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2020-07-20 12:26:11 +0200 |
commit | 1bfb3ad051fee3e19a4d2f8d5bb9144fded543cb (patch) | |
tree | 4bcf70af173014f9c82c916cb503fc2d64c78efc | |
parent | f94036fd18eefee801b3e99c564b2b0bc1a81218 (diff) |
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
-rw-r--r-- | src/ir/comp.rs | 13 |
1 files 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; } } } |