Skip to content

Commit ed716d4

Browse files
wildarchsaleemjaffer
authored andcommitted
Return instead of collecting to mut result.
1 parent e395026 commit ed716d4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

src/librustc/ty/layout.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1833,17 +1833,19 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
18331833
})
18341834
}
18351835

1836-
fn pointee_info_at(this: TyLayout<'tcx>, cx: &C, offset: Size
1836+
fn pointee_info_at(
1837+
this: TyLayout<'tcx>,
1838+
cx: &C,
1839+
offset: Size,
18371840
) -> Option<PointeeInfo> {
1838-
let mut result = None;
18391841
match this.ty.sty {
18401842
ty::RawPtr(mt) if offset.bytes() == 0 => {
1841-
result = cx.layout_of(mt.ty).ok()
1843+
cx.layout_of(mt.ty).ok()
18421844
.map(|layout| PointeeInfo {
18431845
size: layout.size,
18441846
align: layout.align.abi,
18451847
safe: None,
1846-
});
1848+
})
18471849
}
18481850

18491851
ty::Ref(_, ty, mt) if offset.bytes() == 0 => {
@@ -1877,12 +1879,12 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
18771879
}
18781880
};
18791881

1880-
result = cx.layout_of(ty).ok()
1882+
cx.layout_of(ty).ok()
18811883
.map(|layout| PointeeInfo {
18821884
size: layout.size,
18831885
align: layout.align.abi,
18841886
safe: Some(kind),
1885-
});
1887+
})
18861888
}
18871889

18881890
_ => {
@@ -1915,6 +1917,8 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
19151917
}
19161918
}
19171919

1920+
let mut result = None;
1921+
19181922
if let Some(variant) = data_variant {
19191923
let ptr_end = offset + Pointer.size(cx);
19201924
for i in 0..variant.fields.count() {
@@ -1945,10 +1949,10 @@ impl<'a, 'tcx, C> TyLayoutMethods<'tcx, C> for Ty<'tcx>
19451949
}
19461950
}
19471951
}
1952+
1953+
result
19481954
}
19491955
}
1950-
1951-
result
19521956
}
19531957

19541958
}

0 commit comments

Comments
 (0)