Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
pufferfish101007 committed Mar 16, 2024
1 parent fe36391 commit 8c7f02e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 29 deletions.
39 changes: 14 additions & 25 deletions src/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,16 +370,15 @@ impl TypeStack {
}
}

#[allow(clippy::len_without_is_empty)]
pub trait TypeStackImpl {
fn get(&self, i: usize) -> Rc<RefCell<Option<TypeStack>>>;
fn len(&self) -> usize;
}

impl TypeStackImpl for Rc<RefCell<Option<TypeStack>>> {
fn get(&self, i: usize) -> Rc<RefCell<Option<TypeStack>>> {
if self.borrow().is_none() {
Rc::clone(self)
} else if i == 0 {
if i == 0 || self.borrow().is_none() {
Rc::clone(self)
} else {
self.borrow().clone().unwrap().0.get(i - 1)
Expand Down Expand Up @@ -532,10 +531,9 @@ impl InputType {
}

pub fn least_restrictive_concrete_type(&self) -> InputType {
use InputType::*;
match self.base_type() {
Union(a, _) => a.least_restrictive_concrete_type(),
a @ _ => a.clone(),
InputType::Union(a, _) => a.least_restrictive_concrete_type(),
other => other.clone(),
}
}

Expand All @@ -550,8 +548,6 @@ impl InputType {
}
}

type OutputType = Option<InputType>;

impl IrOpcode {
pub fn does_request_redraw(&self) -> bool {
use IrOpcode::*;
Expand Down Expand Up @@ -1627,18 +1623,15 @@ impl IrBlockVec for Vec<IrBlock> {
let cast_stack = self.get_type_stack(Some(cast_pos));
let cast_block = IrBlock::new_with_stack_no_cast(
IrOpcode::hq_cast(
{
let from = cast_stack
.borrow()
.clone()
.ok_or(make_hq_bug!(
"tried to cast to {:?} from empty type stack at {:?}",
cast_type.clone(),
op
))?
.1;
from
},
cast_stack
.borrow()
.clone()
.ok_or(make_hq_bug!(
"tried to cast to {:?} from empty type stack at {:?}",
cast_type.clone(),
op
))?
.1,
cast_type.clone(),
),
cast_stack,

Check failure on line 1637 in src/ir.rs

View workflow job for this annotation

GitHub Actions / Lint (clippy)

cannot move out of `cast_stack` because it is borrowed

Check failure on line 1637 in src/ir.rs

View workflow job for this annotation

GitHub Actions / Build check

cannot move out of `cast_stack` because it is borrowed
Expand Down Expand Up @@ -1698,11 +1691,7 @@ pub fn step_from_top_block<'a>(
{
next_id = last_nexts.pop();
} else {
next_id = next_block
.block_info()
.ok_or(make_hq_bug!(""))?
.next
.clone();
next_id.clone_from(next_block.block_info().ok_or(make_hq_bug!(""))?.next);

Check failure on line 1694 in src/ir.rs

View workflow job for this annotation

GitHub Actions / Lint (clippy)

mismatched types

Check failure on line 1694 in src/ir.rs

View workflow job for this annotation

GitHub Actions / Build check

mismatched types
}
if ops.is_empty() {
hq_bug!("assertion failed: !ops.is_empty()")
Expand Down
5 changes: 1 addition & 4 deletions src/targets/wasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1394,10 +1394,7 @@ impl TryFrom<IrProject> for WasmProject {
[ValType::I64],
);
types.function(
[
ValType::F64,
ValType::Ref(RefType::EXTERNREF),
],
[ValType::F64, ValType::Ref(RefType::EXTERNREF)],
[ValType::Ref(RefType::EXTERNREF)],
);

Expand Down

0 comments on commit 8c7f02e

Please sign in to comment.