Skip to content

Commit 2155135

Browse files
committed
Use assert_usize instead of unwrap_usize in several places
1 parent c2b663c commit 2155135

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

src/librustc_codegen_llvm/debuginfo/metadata.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -342,9 +342,7 @@ fn fixed_vec_metadata(
342342
let (size, align) = cx.size_and_align_of(array_or_slice_type);
343343

344344
let upper_bound = match array_or_slice_type.sty {
345-
ty::Array(_, len) => {
346-
len.unwrap_usize(cx.tcx) as c_longlong
347-
}
345+
ty::Array(_, len) => len.unwrap_usize(cx.tcx) as c_longlong,
348346
_ => -1
349347
};
350348

src/librustc_mir/borrow_check/places_conflict.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,8 +332,8 @@ fn place_base_conflict<'a, 'gcx: 'tcx, 'tcx>(
332332
},
333333
(StaticKind::Promoted(promoted_1), StaticKind::Promoted(promoted_2)) => {
334334
if promoted_1 == promoted_2 {
335-
if let ty::Array(_, size) = s1.ty.sty {
336-
if size.unwrap_usize(tcx) == 0 {
335+
if let ty::Array(_, len) = s1.ty.sty {
336+
if let Some(0) = len.assert_usize(tcx) {
337337
// Ignore conflicts with promoted [T; 0].
338338
debug!("place_element_conflict: IGNORE-LEN-0-PROMOTED");
339339
return Overlap::Disjoint;

0 commit comments

Comments
 (0)