Skip to content

Commit

Permalink
chore: make clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Chronostasys committed Nov 22, 2023
1 parent 2714577 commit eeb25b6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 39 deletions.
2 changes: 1 addition & 1 deletion immix/benches/immix_bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ fn test_complecated_multiple_thread_gc(num_iter: usize, threads: usize) -> Durat
for h in handles {
times.push(h.join().unwrap());
}
times.sort_by(|k1, k2| (k1).cmp(k2));
times.sort();
times.pop().unwrap()
}

Expand Down
4 changes: 2 additions & 2 deletions immix/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ fn main() {
// assert!(flag.starts_with("-l"), "{}",flag);
if flag.ends_with(".tbd") && flag.starts_with("-llib") {
&flag[5..flag.len() - 4]
} else if flag.starts_with("-l") {
&flag[2..]
} else if let Some(postfix) = flag.strip_prefix("-l") {
postfix
} else {
flag
}
Expand Down
4 changes: 2 additions & 2 deletions immix/src/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,7 +585,7 @@ mod tests {
let l = block.get_nth_line_header(6).get_obj_type();
assert_eq!(l, crate::block::ObjectType::Complex);
assert_eq!(start, 6);
assert_eq!(newcursor, false);
assert!(!newcursor);
assert_eq!(block.cursor, 4);
// assert_eq!(block.limit, 1);
let (start, newcursor) = block
Expand All @@ -606,7 +606,7 @@ mod tests {
// ......
// | 255 | 已使用
assert_eq!(start, 4);
assert_eq!(newcursor, false);
assert!(!newcursor);
// assert_eq!(block.first_hole_line_idx, 255); 这个时候没hole了,此值无意义,len为0
// assert_eq!(block.limit, 0);

Expand Down
2 changes: 1 addition & 1 deletion src/ast/node/function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ impl Node for ClosureNode {
} else if let Some(id) = v.id {
let vv = ctx.unify_table.borrow_mut().probe(id);
let tp = vv.get_type(&mut ctx.unify_table.borrow_mut());
if &*tp.borrow() == &PLType::Unknown {
if *tp.borrow() == PLType::Unknown {
v.range()
.new_err(ErrorCode::CLOSURE_PARAM_TYPE_UNKNOWN)
.add_help("try manually specify the parameter type of the closure")
Expand Down
54 changes: 21 additions & 33 deletions src/inference/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,14 @@ impl UnifyValue for TyInfer {
// if there's no error, then set unknown to the real type
if value1 == value2 {
Ok(value1.clone())
} else if matches!(value1, TyInfer::Term(ty) if &*get_type_deep(ty.clone()).borrow()== &PLType::Unknown)
} else if matches!(value1, TyInfer::Term(ty) if *get_type_deep(ty.clone()).borrow()== PLType::Unknown)
{
Ok(value2.clone())
} else if matches!(value2, TyInfer::Term(ty) if &*get_type_deep(ty.clone()).borrow()== &PLType::Unknown)
} else if matches!(value2, TyInfer::Term(ty) if *get_type_deep(ty.clone()).borrow()== PLType::Unknown)
|| matches!(value2, TyInfer::Closure(_))
|| matches!(value1, TyInfer::Closure(_))
{
Ok(value1.clone())
} else if matches!(value2, TyInfer::Closure(_)) || matches!(value1, TyInfer::Closure(_)) {
Ok(value1.clone())
} else {
Ok(TyInfer::Err)
}
Expand Down Expand Up @@ -212,15 +212,13 @@ impl<'ctx> InferenceCtx<'ctx> {
match (v_1, v_2) {
(TyInfer::Closure(c1), TyInfer::Closure(c2)) => {
if c1.0.len() == c2.0.len() {
let mut i = 0;
for arg in &c1.0 {
for (i, arg) in c1.0.iter().enumerate() {
self.unify_two_symbol(
SymbolType::Var(*arg),
SymbolType::Var(c2.0[i]),
ctx,
builder,
);
i += 1;
}
}

Check warning on line 223 in src/inference/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/inference/mod.rs#L223

Added line #L223 was not covered by tests
self.unify_two_symbol(
Expand Down Expand Up @@ -262,18 +260,15 @@ impl<'ctx> InferenceCtx<'ctx> {
match (ty, &*tp.borrow()) {
(TyInfer::Closure(c1), PLType::Closure(c2)) => {
if c1.0.len() == c2.arg_types.len() {
let mut i = 0;
for arg in &c1.0 {
for (i, arg) in c1.0.iter().enumerate() {
self.unify_var_tp(*arg, c2.arg_types[i].clone(), ctx, builder);
i += 1;
}
}

Check warning on line 266 in src/inference/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/inference/mod.rs#L266

Added line #L266 was not covered by tests
self.unify_var_tp(c1.1, c2.ret_type.clone(), ctx, builder);
}
(TyInfer::Closure(c1), PLType::Fn(c2)) => {
if c1.0.len() == c2.fntype.param_pltypes.len() {
let mut i = 0;
for arg in &c1.0 {
for (i, arg) in c1.0.iter().enumerate() {
self.unify_var_tp(
*arg,
c2.fntype.param_pltypes[i]
Expand All @@ -282,7 +277,6 @@ impl<'ctx> InferenceCtx<'ctx> {
ctx,
builder,
);
i += 1;
}
}
self.unify_var_tp(
Expand Down Expand Up @@ -557,24 +551,23 @@ impl<'ctx> InferenceCtx<'ctx> {
if c.arg_types.len() != argtys.len() {
return unknown();

Check warning on line 552 in src/inference/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/inference/mod.rs#L552

Added line #L552 was not covered by tests
}
let mut i = 0;
for arg in &c.arg_types {

for (i, arg) in c.arg_types.iter().enumerate() {
self.unify_two_symbol(
argtys[i].clone(),
SymbolType::PLType(arg.clone()),
ctx,
builder,
);
i += 1;
}
return SymbolType::PLType(c.ret_type.clone());
}
PLType::Fn(f) => {
if f.fntype.param_pltypes.len() != argtys.len() {
return unknown();
}

Check warning on line 568 in src/inference/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/inference/mod.rs#L565-L568

Added lines #L565 - L568 were not covered by tests
let mut i = 0;
for arg in &f.fntype.param_pltypes {

for (i, arg) in f.fntype.param_pltypes.iter().enumerate() {
self.unify_two_symbol(
argtys[i].clone(),
SymbolType::PLType(
Expand All @@ -584,7 +577,6 @@ impl<'ctx> InferenceCtx<'ctx> {
ctx,
builder,
);
i += 1;
}
return SymbolType::PLType(
f.fntype
Expand Down Expand Up @@ -613,10 +605,8 @@ impl<'ctx> InferenceCtx<'ctx> {
if args.len() != argtys.len() {
return unknown();

Check warning on line 606 in src/inference/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/inference/mod.rs#L606

Added line #L606 was not covered by tests
}
let mut i = 0;
for arg in args {
self.unify(arg, argtys[i].clone(), ctx, builder);
i += 1;
for (i, arg) in args.iter().enumerate() {
self.unify(*arg, argtys[i].clone(), ctx, builder);
}
return SymbolType::Var(ret);
}
Expand All @@ -627,8 +617,7 @@ impl<'ctx> InferenceCtx<'ctx> {
if f.fntype.param_pltypes.len() != argtys.len() {
return unknown();
}
let mut i = 0;
for arg in &f.fntype.param_pltypes {
for (i, arg) in f.fntype.param_pltypes.iter().enumerate() {
self.unify_two_symbol(
argtys[i].clone(),
SymbolType::PLType(
Expand All @@ -639,7 +628,6 @@ impl<'ctx> InferenceCtx<'ctx> {
ctx,
builder,
);
i += 1;
}
return SymbolType::PLType(
f.fntype
Expand All @@ -652,15 +640,13 @@ impl<'ctx> InferenceCtx<'ctx> {
if cl.arg_types.len() != argtys.len() {
return unknown();

Check warning on line 641 in src/inference/mod.rs

View check run for this annotation

Codecov / codecov/patch

src/inference/mod.rs#L641

Added line #L641 was not covered by tests
}
let mut i = 0;
for arg in &cl.arg_types {
for (i, arg) in cl.arg_types.iter().enumerate() {
self.unify_two_symbol(
argtys[i].clone(),
SymbolType::PLType(arg.clone()),
ctx,
builder,
);
i += 1;
}
return SymbolType::PLType(cl.ret_type.clone());
}
Expand Down Expand Up @@ -690,8 +676,10 @@ impl<'ctx> InferenceCtx<'ctx> {
}
NodeEnum::Ret(r) => {
let ret = self.get_symbol("@ret");
if r.yiel.is_none() && ret.is_some() {
let ret = ret.unwrap();
if r.yiel.is_some() {
return unknown();
}
if let Some(ret) = ret {
if let Some(r) = &mut r.value {
let ty = self.inference(&mut *r, ctx, builder);
self.unify(ret, ty, ctx, builder);
Expand Down Expand Up @@ -794,7 +782,7 @@ impl<'ctx> InferenceCtx<'ctx> {
match k {
TyInfer::Term(t) => {
if p.op == PointerOpEnum::Addr {
if &*t.borrow() != &PLType::Unknown {
if *t.borrow() != PLType::Unknown {
return SymbolType::PLType(new_arc_refcell(
PLType::Pointer(t),
));
Expand All @@ -813,7 +801,7 @@ impl<'ctx> InferenceCtx<'ctx> {
}
SymbolType::PLType(t) => {
if p.op == PointerOpEnum::Addr {
if &*t.borrow() != &PLType::Unknown {
if *t.borrow() != PLType::Unknown {
return SymbolType::PLType(new_arc_refcell(PLType::Pointer(t)));
}
} else if p.op == PointerOpEnum::Deref {
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#![allow(suspicious_double_ref_op)]
#![allow(clippy::derive_ord_xor_partial_ord)]
#![allow(clippy::missing_safety_doc)]
#![allow(clippy::single_match)]

mod jar;
pub use jar::*;
Expand Down

0 comments on commit eeb25b6

Please sign in to comment.