Skip to content

Commit

Permalink
fmt and clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
xunilrj committed Jul 22, 2024
1 parent 912e025 commit c4f0a91
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sway-core/src/ir_generation/const_eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1311,8 +1311,8 @@ fn const_eval_intrinsic(

match &args[0].value {
ConstantValue::Array(v) => {
let elem_type = v[0].ty.clone();
let slice = (&v[start..end]).iter().cloned().collect::<Vec<_>>();
let elem_type = v[0].ty;
let slice = v[start..end].to_vec();
Ok(Some(Constant {
ty: Type::get_typed_slice(lookup.context, elem_type),
value: ConstantValue::Slice(slice),
Expand All @@ -1335,7 +1335,7 @@ fn const_eval_intrinsic(
ConstantValue::Slice(s) => {
let v = s[idx].clone();
Ok(Some(Constant {
ty: Type::new_ptr(lookup.context, v.ty.clone()),
ty: Type::new_ptr(lookup.context, v.ty),
value: ConstantValue::Reference(Box::new(v)),
}))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,11 @@ fn main() {
assert(4, *__slice_elem(s, 3));
assert(5, *__slice_elem(s, 4));

let s = __slice(a, 1, 4);
assert(2, *__slice_elem(s, 0));
assert(3, *__slice_elem(s, 1));
assert(4, *__slice_elem(s, 2));

const ARRAY: [u64; 5] = [1, 2, 3, 4, 5];
const SLICE: &__slice[u64] = __slice(ARRAY, 0, 5);
const ELEM: u64 = *__slice_elem(SLICE, 0);
Expand Down

0 comments on commit c4f0a91

Please # to comment.