diff options
| author | Yuki Okushi <jtitor@2k36.org> | 2021-06-07 15:21:05 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-07 15:21:05 +0900 |
| commit | 7530c7d1bdae3fc511294369e10dabf259996272 (patch) | |
| tree | 04a4e52b11f473366d5aba11f245c0caaa77b408 | |
| parent | fa38fad5a2f111eb17b8beb833a053c30b61846a (diff) | |
| parent | 07dbd4d39826b1c4a4e0bcd7501dae9236be8bbe (diff) | |
| download | rust-7530c7d1bdae3fc511294369e10dabf259996272.tar.gz rust-7530c7d1bdae3fc511294369e10dabf259996272.zip | |
Rollup merge of #86081 - LingMan:try_into, r=jyn514
Use `try_into` instead of asserting manually `@rustbot` modify labels +C-cleanup +T-compiler
| -rw-r--r-- | compiler/rustc_target/src/abi/mod.rs | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/compiler/rustc_target/src/abi/mod.rs b/compiler/rustc_target/src/abi/mod.rs index 1679d029374..8e71ded3d1d 100644 --- a/compiler/rustc_target/src/abi/mod.rs +++ b/compiler/rustc_target/src/abi/mod.rs @@ -753,11 +753,7 @@ impl FieldsShape { match *self { FieldsShape::Primitive => 0, FieldsShape::Union(count) => count.get(), - FieldsShape::Array { count, .. } => { - let usize_count = count as usize; - assert_eq!(usize_count as u64, count); - usize_count - } + FieldsShape::Array { count, .. } => count.try_into().unwrap(), FieldsShape::Arbitrary { ref offsets, .. } => offsets.len(), } } @@ -791,11 +787,7 @@ impl FieldsShape { unreachable!("FieldsShape::memory_index: `Primitive`s have no fields") } FieldsShape::Union(_) | FieldsShape::Array { .. } => i, - FieldsShape::Arbitrary { ref memory_index, .. } => { - let r = memory_index[i]; - assert_eq!(r as usize as u32, r); - r as usize - } + FieldsShape::Arbitrary { ref memory_index, .. } => memory_index[i].try_into().unwrap(), } } |
