Skip to content

Commit 17a465c

Browse files
committed
Avoid unneeded else branches
1 parent 9b549d3 commit 17a465c

File tree

1 file changed

+13
-22
lines changed

1 file changed

+13
-22
lines changed

src/librustc_mir/dataflow/move_paths/builder.rs

+13-22
Original file line numberDiff line numberDiff line change
@@ -429,30 +429,21 @@ impl<'b, 'a, 'tcx> Gatherer<'b, 'a, 'tcx> {
429429
fn gather_init(&mut self, place: PlaceRef<'cx, 'tcx>, kind: InitKind) {
430430
debug!("gather_init({:?}, {:?})", self.loc, place);
431431

432-
let place = match place.projection {
433-
// Check if we are assigning into a field of a union, if so, lookup the place
434-
// of the union so it is marked as initialized again.
435-
Some(box Projection {
436-
base: proj_base,
437-
elem: ProjectionElem::Field(_, _),
438-
}) => {
439-
if let ty::Adt(def, _) =
440-
Place::ty_from(place.base, proj_base, self.builder.body, self.builder.tcx)
441-
.ty
442-
.sty
443-
{
444-
if def.is_union() {
445-
PlaceRef { base: place.base, projection: proj_base }
446-
} else {
447-
place
448-
}
449-
} else {
450-
place
432+
let mut place = place;
433+
434+
// Check if we are assigning into a field of a union, if so, lookup the place
435+
// of the union so it is marked as initialized again.
436+
if let Some(box Projection { base: proj_base, elem: ProjectionElem::Field(_, _) }) =
437+
place.projection
438+
{
439+
if let ty::Adt(def, _) =
440+
Place::ty_from(place.base, proj_base, self.builder.body, self.builder.tcx).ty.sty
441+
{
442+
if def.is_union() {
443+
place = PlaceRef { base: place.base, projection: proj_base }
451444
}
452445
}
453-
454-
_ => place
455-
};
446+
}
456447

457448
if let LookupResult::Exact(path) = self.builder.data.rev_lookup.find(place) {
458449
let init = self.builder.data.inits.push(Init {

0 commit comments

Comments
 (0)