Skip to content

Commit 7a16714

Browse files
Rollup merge of rust-lang#157130 - alexcrichton:refactor-cast-target-internals, r=nnethercote
Use a `ArrayVec` in `CastTarget` This commit switches a fixed-size list of `[Option<Reg>; 8]` to instead holding `ArrayVec<Reg, 8>` in the `CastTarget` type used when calculating ABIs. This is inspired by [discussion on Zulip][link] where I'm hoping to in the near future extend the usage of this to possibly beyond 8 elements for a new WebAssembly ABI taking advantage of multi-value. For now though this mostly just switches to array/slice-like idioms of accessors rather than dealing with `Option<Reg>` as the unit. [link]: https://rust-lang.zulipchat.com/#narrow/channel/131828-t-compiler/topic/Using.20.60ArgAbi.3A.3Amake_direct_deprecated.60/with/598607139
2 parents 3d68072 + dab3956 commit 7a16714

1 file changed

Lines changed: 2 additions & 3 deletions

File tree

src/abi/pass_mode.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ fn apply_attrs_to_abi_param(param: AbiParam, arg_attrs: ArgAttributes) -> AbiPar
4444

4545
fn cast_target_to_abi_params(cast: &CastTarget) -> SmallVec<[(Size, AbiParam); 2]> {
4646
if let Some(offset_from_start) = cast.rest_offset {
47-
assert!(cast.prefix[1..].iter().all(|p| p.is_none()));
47+
assert_eq!(cast.prefix.len(), 1);
4848
assert_eq!(cast.rest.unit.size, cast.rest.total);
49-
let first = cast.prefix[0].unwrap();
49+
let first = cast.prefix[0];
5050
let second = cast.rest.unit;
5151
return smallvec![
5252
(Size::ZERO, reg_to_abi_param(first)),
@@ -71,7 +71,6 @@ fn cast_target_to_abi_params(cast: &CastTarget) -> SmallVec<[(Size, AbiParam); 2
7171
let args = cast
7272
.prefix
7373
.iter()
74-
.flatten()
7574
.map(|&reg| reg_to_abi_param(reg))
7675
.chain((0..rest_count).map(|_| reg_to_abi_param(cast.rest.unit)));
7776

0 commit comments

Comments
 (0)