From 865b46731400646d91f8535ba879a6374fe52685 Mon Sep 17 00:00:00 2001 From: "L. E. Segovia" Date: Thu, 15 Feb 2024 19:17:28 -0300 Subject: [PATCH] Fix and work around excessively strict dead_code lint in Rust 1.78 nightly See https://github.com/rust-lang/rust/issues/120770 Part-of: --- rsvg/src/float_eq_cairo.rs | 1 + rsvg_convert/src/main.rs | 27 ------------------- rsvg_convert/tests/internal_predicates/svg.rs | 4 --- 3 files changed, 1 insertion(+), 31 deletions(-) diff --git a/rsvg/src/float_eq_cairo.rs b/rsvg/src/float_eq_cairo.rs index 0845ec748..ff295acbc 100644 --- a/rsvg/src/float_eq_cairo.rs +++ b/rsvg/src/float_eq_cairo.rs @@ -29,6 +29,7 @@ fn cairo_fixed_from_double(d: f64) -> i32 { /// the integral part, and 8 bits for the fractional part. That is, /// the smallest fraction they can represent is 1/256. pub trait FixedEqCairo { + #[allow(dead_code)] // https://github.com/rust-lang/rust/issues/120770 fn fixed_eq_cairo(&self, other: &Self) -> bool; } diff --git a/rsvg_convert/src/main.rs b/rsvg_convert/src/main.rs index 23fde31b5..ca358cbd4 100644 --- a/rsvg_convert/src/main.rs +++ b/rsvg_convert/src/main.rs @@ -1232,33 +1232,6 @@ fn parse_zoom_factor(v: &str) -> Result { } } -trait NotFound { - type Ok; - type Error; - - fn or_none(self) -> Result, Self::Error>; -} - -impl NotFound for Result { - type Ok = T; - type Error = clap::Error; - - /// Maps the Result to an Option, translating the ArgumentNotFound error to - /// Ok(None), while mapping other kinds of errors to Err(e). - /// - /// This allows to get proper error reporting for invalid values on optional - /// arguments. - fn or_none(self) -> Result, clap::Error> { - self.map_or_else( - |e| match e.kind() { - clap::error::ErrorKind::UnknownArgument => Ok(None), - _ => Err(e), - }, - |v| Ok(Some(v)), - ) - } -} - fn parse_background_color(s: &str) -> Result, String> { match s { "none" | "None" => Ok(None), diff --git a/rsvg_convert/tests/internal_predicates/svg.rs b/rsvg_convert/tests/internal_predicates/svg.rs index c339365f8..e9a68434c 100644 --- a/rsvg_convert/tests/internal_predicates/svg.rs +++ b/rsvg_convert/tests/internal_predicates/svg.rs @@ -105,10 +105,6 @@ impl cmp::PartialEq for Dimensions { impl cmp::Eq for Dimensions {} -trait Details { - fn get_size(&self) -> Option; -} - impl DetailPredicate { fn eval_doc(&self, handle: &SvgHandle) -> bool { match &self.d {