From: Ian Jackson Date: Thu, 31 Mar 2022 19:39:47 +0000 (+0100) Subject: clippy: Miscellaneous minor changes, and allow lints X-Git-Tag: otter-1.0.0~27 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ed697564cff32c02783a1a9383f5f7ccba6b28d8;p=otter.git clippy: Miscellaneous minor changes, and allow lints Signed-off-by: Ian Jackson --- diff --git a/apitest/at-otter.rs b/apitest/at-otter.rs index 37299795..dbed7976 100644 --- a/apitest/at-otter.rs +++ b/apitest/at-otter.rs @@ -198,7 +198,7 @@ impl Ctx { #[throws(Explode)] fn ssh_remote(&mut self) { let ds = self.ds().also(&[ - ("config", PathResolveContext::default().resolve(&CONFIG)), + ("config", PathResolveContext::default().resolve(CONFIG)), ]); let mut command = ds.gss( "--ssh-command=@src@/apitest/mock-ssh \ diff --git a/apitest/atmain.rs b/apitest/atmain.rs index 7b73a08b..ad9cbb18 100644 --- a/apitest/atmain.rs +++ b/apitest/atmain.rs @@ -360,7 +360,7 @@ impl Session { |_session, gen | (gen == exp).as_option(), | session, gen, k, v| { if let Some(pieces) = pieces.as_mut() { - update_update_pieces(&session.nick, pieces, k, v); + update_update_pieces(session.nick, pieces, k, v); } f(session,gen,k,v); None diff --git a/cli/adhoc.rs b/cli/adhoc.rs index 38e7e998..cc5e44f9 100644 --- a/cli/adhoc.rs +++ b/cli/adhoc.rs @@ -59,7 +59,7 @@ mod command_adhoc { cmds: Vec, } - fn subargs<'ap,'a:'ap,'m:'ap>( + fn subargs<'ap,'a:'ap>( sa: &'a mut Args, ahf: AdhocFormat, ) -> ArgumentParser<'ap> { @@ -108,7 +108,7 @@ mod alter_game_adhoc { insns: Vec, } - fn subargs<'ap,'a:'ap,'m:'ap>( + fn subargs<'ap,'a:'ap>( sa: &'a mut Args, ahf: AdhocFormat, ) -> ArgumentParser<'ap> { diff --git a/cli/forssh.rs b/cli/forssh.rs index e19266b7..1f1494f7 100644 --- a/cli/forssh.rs +++ b/cli/forssh.rs @@ -150,7 +150,7 @@ mod set_ssh_keys { for (l, lno) in akf.lines().zip(1..) { let l = l.context("read KEYS-FILE")?; let l = l.trim(); - if l.starts_with("#") || l == "" { continue } + if l.starts_with('#') || l == "" { continue } let l = AuthkeysLine(l.to_owned()); let (pubdata, _comment) = l.parse() .with_context(|| format!("parse KEYS-FILE line {}", lno))?; diff --git a/cli/otter.rs b/cli/otter.rs index fe0bef98..12cabe84 100644 --- a/cli/otter.rs +++ b/cli/otter.rs @@ -304,8 +304,7 @@ fn main() { })?; let sc = inventory::iter::.into_iter() - .filter(|Subcommand{verb:found,..}| found == &subcommand) - .next() + .find(|Subcommand{verb:found,..}| found == &subcommand) .unwrap_or_else(||{ eprintln!("subcommand `{}' not recognised", &subcommand); exit(EXIT_USAGE); diff --git a/cli/uselibs.rs b/cli/uselibs.rs index c511d1b4..351f92d2 100644 --- a/cli/uselibs.rs +++ b/cli/uselibs.rs @@ -28,7 +28,7 @@ impl LibGlobArgs { self.lib.clone() } fn pat(&self) -> String { - self.pat.as_ref().map(Deref::deref) + self.pat.as_deref() .unwrap_or("*") .into() } @@ -204,7 +204,7 @@ mod library_add { /// If returns None, has already maybe tried to take some space #[throws(AE)] fn place(&mut self, bbox: &Rect, - pieces: &Vec, ma: &MainOpts) + pieces: &[MgmtGamePieceInfo], ma: &MainOpts) -> Option { let PosC{ coords: [w,h] } = (bbox.br() - bbox.tl())?; diff --git a/clippy-options b/clippy-options index b4cfc50f..34a9920c 100644 --- a/clippy-options +++ b/clippy-options @@ -37,3 +37,5 @@ -A clippy::vec_init_then_push -A clippy::collapsible_if -A clippy::iter_nth_zero +-A clippy::match_single_binding +-A clippy::needless_update diff --git a/jstest/jst-lower.rs b/jstest/jst-lower.rs index b44d611e..c03ae52a 100644 --- a/jstest/jst-lower.rs +++ b/jstest/jst-lower.rs @@ -362,7 +362,6 @@ impl TestsAccumulator { let pieces: IndexMap = pieces.into_iter().map( |StartPieceSpec { id, pinned, moveable, zupd }| { let zupd_d = (&zupd).into(); - let id = id.try_into().unwrap(); let zlevel = zupd.next(&mut zlast, &mut zlastg); (id, StartPiece { pinned, moveable, zlevel, zupd: zupd_d }) }