From dd29a844da733cdbf7c849641a07e111ecbed8a4 Mon Sep 17 00:00:00 2001 From: Krzysztof Lis Date: Mon, 1 Jul 2024 13:44:03 +0200 Subject: [PATCH] fix(tagged): warnings in release build --- crates/tagged/src/lib.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/crates/tagged/src/lib.rs b/crates/tagged/src/lib.rs index f4fe3ba5d6..0fea449a0c 100644 --- a/crates/tagged/src/lib.rs +++ b/crates/tagged/src/lib.rs @@ -3,6 +3,7 @@ //! implementation, which is `[cfg(debug_assertions)]`. As an additional safety //! measure, the [`tagged::init()`](crate::init()) function must be called //! before using the `tagged::Tagged` type. +#![allow(dead_code)] use std::any::{Any, TypeId}; use std::collections::HashMap; use std::fmt::{Debug, Formatter}; @@ -58,16 +59,16 @@ impl Tagged { /// /// Use only in Debug builds after calling [`tagged::init`](`crate::init`). /// Otherwise this function always returns `None`. - pub fn get T>(tag: U, ctor: C) -> Option { + pub fn get T>(_tag: U, _ctor: C) -> Option { #[cfg(debug_assertions)] { let luts = lut(); luts.map(|mut luts| { let lut = luts.entry(TypeId::of::()).or_default(); - let tag = tag.to_string(); + let tag = _tag.to_string(); let data = lut .entry(tag.clone()) - .or_insert_with(|| Box::new(ctor())) + .or_insert_with(|| Box::new(_ctor())) .downcast_ref::() .unwrap() .clone(); @@ -86,8 +87,8 @@ impl + 'static> Tagged { /// /// Use only in Debug builds after calling [`tagged::init`](`crate::init`). /// Otherwise this function always returns `None`. - pub fn get_fake(tag: U) -> Option { - Self::get(tag, || Faker.fake()) + pub fn get_fake(_tag: U) -> Option { + Self::get(_tag, || Faker.fake()) } } @@ -99,7 +100,7 @@ impl Tagged { /// /// Use only in Debug builds after calling [`tagged::init`](`crate::init`). /// Otherwise this function will error. - pub fn from_data(data: &T) -> Result { + pub fn from_data(_data: &T) -> Result { #[cfg(debug_assertions)] { let luts = lut().ok_or(TypeNotFound)?; @@ -111,13 +112,13 @@ impl Tagged { .iter() .find_map(|(k, v)| { v.downcast_ref::() - .and_then(|u| (u == data).then_some(k.clone())) + .and_then(|u| (u == _data).then_some(k.clone())) }) .unwrap_or("value not found".into()); Ok(Self { tag, - data: data.clone(), + data: _data.clone(), }) } None => Err(TypeNotFound),