Skip to content

Commit 7530c7d

Browse files
authored
Rollup merge of #86081 - LingMan:try_into, r=jyn514
Use `try_into` instead of asserting manually `@rustbot` modify labels +C-cleanup +T-compiler
2 parents fa38fad + 07dbd4d commit 7530c7d

File tree

1 file changed

+2
-10
lines changed
  • compiler/rustc_target/src/abi

1 file changed

+2
-10
lines changed

compiler/rustc_target/src/abi/mod.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -753,11 +753,7 @@ impl FieldsShape {
753753
match *self {
754754
FieldsShape::Primitive => 0,
755755
FieldsShape::Union(count) => count.get(),
756-
FieldsShape::Array { count, .. } => {
757-
let usize_count = count as usize;
758-
assert_eq!(usize_count as u64, count);
759-
usize_count
760-
}
756+
FieldsShape::Array { count, .. } => count.try_into().unwrap(),
761757
FieldsShape::Arbitrary { ref offsets, .. } => offsets.len(),
762758
}
763759
}
@@ -791,11 +787,7 @@ impl FieldsShape {
791787
unreachable!("FieldsShape::memory_index: `Primitive`s have no fields")
792788
}
793789
FieldsShape::Union(_) | FieldsShape::Array { .. } => i,
794-
FieldsShape::Arbitrary { ref memory_index, .. } => {
795-
let r = memory_index[i];
796-
assert_eq!(r as usize as u32, r);
797-
r as usize
798-
}
790+
FieldsShape::Arbitrary { ref memory_index, .. } => memory_index[i].try_into().unwrap(),
799791
}
800792
}
801793

0 commit comments

Comments
 (0)