Skip to content

Commit

Permalink
clippy level up
Browse files Browse the repository at this point in the history
  • Loading branch information
digama0 committed Nov 19, 2024
1 parent c9f407a commit 2823e7a
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion mm0-rs/components/mm0_util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ impl FileRef {
/// Returns true if this file has the provided extension.
#[must_use]
pub fn has_extension(&self, ext: &str) -> bool {
self.path().extension().map_or(false, |s| s == ext)
self.path().extension().is_some_and(|s| s == ext)
}
}
impl PartialEq for FileRef {
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/components/mm1_parser/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ impl<'a> Parser<'a> {
let start = self.idx;
loop {
self.idx += 1;
if !self.cur_opt().map_or(false, ident_rest) {
if !self.cur_opt().is_some_and(ident_rest) {
let sp = (start..self.idx).into();
if self.restart_pos.is_none() && CommandKeyword::parse(self.span(sp)).is_some() {
self.restart_pos = Some(start);
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/components/mmcc/src/infer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2536,7 +2536,7 @@ impl<'a, 'n> InferCtx<'a, 'n> {
self.try_check_pure_expr(sp, then, tgt) &&
self.try_check_pure_expr(sp, els, tgt),
// TODO: more heuristics?
_ => self.expr_type(sp, e).map_or(false, |ty| self.relate_whnf_ty(
_ => self.expr_type(sp, e).is_some_and(|ty| self.relate_whnf_ty(
ty.into(), tgt.into(), Relation::Subtype).is_ok()),
}
}
Expand Down
4 changes: 2 additions & 2 deletions mm0-rs/components/mmcc/src/mir_opt/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ impl Cfg {
let mut split = false;
let mut copy = false;
for &x in &allocs[a].vars {
if last_use.get(&x).map_or(false, |&j| j > i) {
if last_use.get(&x).is_some_and(|&j| j > i) {
if x == r.from { copy = true } else { split = true }
}
}
Expand Down Expand Up @@ -360,7 +360,7 @@ impl Cfg {
}
} else {
tgt = allocs.push(v, || meta(ty));
live.retain(|u, _| last_use.get(u).map_or(false, |&j| j > i) && {
live.retain(|u, _| last_use.get(u).is_some_and(|&j| j > i) && {
// interference.insert(a, allocs.vars[u]);
true
});
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/components/mmcc/src/regalloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ impl PCodeBuilder {
ar: &ApplyRegalloc,
pt: ProgPoint
) {
while edits.peek().map_or(false, |p| p.0 == pt) {
while edits.peek().is_some_and(|p| p.0 == pt) {
if let Some((_, Edit::Move { from, to, .. })) = edits.next() {
match (from.as_reg().map(PReg), to.as_reg().map(PReg)) {
(Some(src), Some(dst)) => { self.push(PInst::MovRR { sz: Size::S64, dst, src }); }
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/components/mmcc/src/types/classify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,7 +551,7 @@ mk_fold! { <'a>
}

fn before_epilogue, after_epilogue, do_epilogue(self, it) {
while self.do_inst(it).map_or(false, |inst| !matches!(inst.inst, PInst::Ret)) {}
while self.do_inst(it).is_some_and(|inst| !matches!(inst.inst, PInst::Ret)) {}
}

fn before_call_arg, after_call_arg, do_call_arg(self, it,
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/src/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ impl Args {
if let Some(out) = self.output {
use {fs::File, io::BufWriter};
let w = BufWriter::new(File::create(&out)?);
if out.rsplit('.').next().map_or(false, |ext| ext.eq_ignore_ascii_case("mmu")) {
if out.rsplit('.').next().is_some_and(|ext| ext.eq_ignore_ascii_case("mmu")) {
env.export_mmu(w)?;
} else {
let mut report = |lvl: ErrorLevel, err: &str| {
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/src/elab/frozen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,7 @@ impl FrozenUncons<'_> {
match self {
FrozenUncons::New(e) => e.exactly(n),
FrozenUncons::List(es) => es.len() == n,
FrozenUncons::DottedList(es, r) => n.checked_sub(es.len()).map_or(false, |i| r.exactly(i)),
FrozenUncons::DottedList(es, r) => n.checked_sub(es.len()).is_some_and(|i| r.exactly(i)),
}
}

Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/src/elab/lisp/eval.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ impl<'a> Evaluator<'a> {

fn heartbeat(&self) -> Result<()> {
// self.iters = self.iters.wrapping_add(1);
if self.cur_timeout.map_or(false, |t| t < Instant::now()) {
if self.cur_timeout.is_some_and(|t| t < Instant::now()) {
return Err(self.err(None, "timeout"))
}
if self.cancel.load(Ordering::Relaxed) {
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/src/elab/local_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@ impl Elaborator {
let nh = NodeHasher::new(&self.lc, self.format_env(), span.clone());
let mut is = Vec::new();
for &(bi, a, ref e) in &e_hyps {
if a.map_or(false, |a| self.lc.vars.contains_key(&a)) {
if a.is_some_and(|a| self.lc.vars.contains_key(&a)) {
return Err(ElabError::new_e(bi.span, "hypothesis shadows local variable"))
}
is.push((a, de.dedup(&nh, ProofKind::Expr, e)?))
Expand Down
2 changes: 1 addition & 1 deletion mm0-rs/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1839,7 +1839,7 @@ impl Server {
}
} else {
let mut caps = caps.ulock();
if caps.reg_id.as_ref().map_or(false, |rid| rid == &resp.id) {
if caps.reg_id.as_ref() == Some(&resp.id) {
caps.finish_register(&resp);
} else {
log!("response to unknown request {}", resp.id)
Expand Down

0 comments on commit 2823e7a

Please sign in to comment.