From 958288b736ccee7872d5f9bebf184543319d385f Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Mon, 16 May 2022 02:36:32 +0100 Subject: [PATCH] clippy: Misc minor improvements Signed-off-by: Ian Jackson --- clippy-options | 1 + daemon/cmdlistener.rs | 2 +- src/bin/otterlib.rs | 2 +- src/fastsplit.rs | 1 + src/shapelib.rs | 18 +++++++++--------- 5 files changed, 13 insertions(+), 11 deletions(-) diff --git a/clippy-options b/clippy-options index 87cccb59..99dd652e 100644 --- a/clippy-options +++ b/clippy-options @@ -45,3 +45,4 @@ -A clippy::needless_match -A clippy::from_over_into # buggy in 1.61.0-nightly (1bfe40d11 2022-03-18) -A clippy::await_holding_lock # moans about synch mutex in async +-A clippy::neg_cmp_op_on_partial_ord diff --git a/daemon/cmdlistener.rs b/daemon/cmdlistener.rs index 5c651cd2..fd853d1a 100644 --- a/daemon/cmdlistener.rs +++ b/daemon/cmdlistener.rs @@ -1023,7 +1023,7 @@ fn execute_game_insn<'cs, 'igr, 'ig: 'igr>( |ioccults, goccults, ipc, gpc| { if let (Some(ipc), Some(gpc)) = (ipc, gpc) { let pri = PieceRenderInstructions::new_visible(default()); - pri.describe(ioccults,goccults, gpc, &ipc) + pri.describe(ioccults,goccults, gpc, ipc) } else { "".to_html() } diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index ef66556b..8a0769cb 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -217,7 +217,7 @@ fn preview(opts: &Opts, items: Vec) { &viewport, wh[0], wh[1]); let mut html = Html::lit("").into(); gpc.face = face.into(); - p.svg_piece(&mut html, &gpc, &GameState::dummy(), default())?; + p.svg_piece(&mut html, gpc, &GameState::dummy(), default())?; println!("{}", html); if inseveral == 1 { let dasharray = player_num_dasharray(1.try_into().unwrap()); diff --git a/src/fastsplit.rs b/src/fastsplit.rs index cfe90c00..472f9340 100644 --- a/src/fastsplit.rs +++ b/src/fastsplit.rs @@ -169,6 +169,7 @@ impl InstanceGuard<'_> { pub fn fastsplit_delete(&mut self, show: ShowUnocculted, piece: PieceId, + #[allow(clippy::ptr_arg)] _proof_that_caller_handles_logging: &Vec) -> (PieceUpdateOp<(),()>, UnpreparedUpdates) { diff --git a/src/shapelib.rs b/src/shapelib.rs index a5ae6ba5..43150def 100644 --- a/src/shapelib.rs +++ b/src/shapelib.rs @@ -751,7 +751,7 @@ impl GroupData { let osize = { let (osize, oscale) = self.d.outline.size_scale(); - let osize = resolve_square_size(&osize)?; + let osize = resolve_square_size(osize)?; match (osize, oscale) { (Some(osize), None ) => osize, (None, Some(&oscale)) => (size * oscale)?, @@ -766,7 +766,7 @@ impl GroupData { } else { let xform = FaceTransform::from_group_mf1(self)?; - let outline = self.d.outline.shape().load_mf1(&self)?; + let outline = self.d.outline.shape().load_mf1(self)?; (xform, outline) } } @@ -998,7 +998,7 @@ pub fn load_catalogue(libname: &str, src: &mut dyn LibrarySource) // We do this here rather than in the files loop because // 1. we want to check it even if there are no files specified // 2. this is OK because the group doesn't change from here on - let shape_calculable = group.check_shape()?.into(); + let shape_calculable = group.check_shape()?; if [ group.d.flip, @@ -1131,11 +1131,11 @@ impl<'i> Substituting<'i> { } let needle: Cow = (move || Some({ if let Some(rhs) = needle.strip_prefix("${") { - let token = rhs.strip_suffix("}")?; - if self.do_dollars() { needle.into() } + let token = rhs.strip_suffix('}')?; + if self.do_dollars() { needle } else { format!("_{}", token).into() } - } else if let Some(token) = needle.strip_prefix("_") { - if ! self.do_dollars() { needle.into() } + } else if let Some(token) = needle.strip_prefix('_') { + if ! self.do_dollars() { needle } else { format!("${{{}}}", token).into() } } else { return None @@ -1352,7 +1352,7 @@ fn process_files_entry( PerhapsSubst::Y(s) => s, } } #[throws(SubstError)] - pub fn is_y( + pub fn into_of_y( self, ) -> Substituting<'i> { match self { PerhapsSubst::Y(s) => s, @@ -1450,7 +1450,7 @@ fn process_files_entry( spec = substn(spec, format!("${{{}}}", k), v)?; } let spec = substn(spec, "${image}", &image_table)?; - let spec = c_colour_all(spec.into())?.is_y()?; + let spec = c_colour_all(spec.into())?.into_of_y()?; let spec = spec.finish()?; trace!("magic item {}\n\n{}\n", &item_name, &spec); -- 2.30.2