Skip to content

DesignCraft: An open-source page and layout design editor written by scratch in pure Rust

chore: drop redundant 'static lifetimes in statics and consts (Sonar S8863) (#1713)

Dylan M. Taylorbfd95b258b0e
diff --git a/crates/doc/src/attrs.rs b/crates/doc/src/attrs.rs
index 077637672..7c57736ef 100644
--- a/crates/doc/src/attrs.rs
+++ b/crates/doc/src/attrs.rs
@@ -371,7 +371,7 @@ fn locale_code(words: &[&str]) -> Option<String> {
/// from documents, so at most [`MAX_TAGS`] are kept; past that a new tag is unknown (`None`).
fn intern_tag(tag: String) -> Option<&'static str> {
const MAX_TAGS: usize = 512;
- static TAGS: std::sync::Mutex<Vec<&'static str>> = std::sync::Mutex::new(Vec::new());
+ static TAGS: std::sync::Mutex<Vec<&str>> = std::sync::Mutex::new(Vec::new());
let mut tags = TAGS.lock().unwrap_or_else(std::sync::PoisonError::into_inner);
if let Some(t) = tags.iter().find(|t| **t == tag) {
return Some(t);
diff --git a/crates/fonts/src/fontdb.rs b/crates/fonts/src/fontdb.rs
index ef5314b32..0c3d229c3 100644
--- a/crates/fonts/src/fontdb.rs
+++ b/crates/fonts/src/fontdb.rs
@@ -148,7 +148,7 @@ pub struct FaceRef(&'static FontFace);
impl FaceRef {
/// The handle for a loaded face (memoised per face).
pub fn of(face: &Arc<FontFace>) -> FaceRef {
- static LEAKED: RwLock<Vec<Option<&'static FontFace>>> = RwLock::new(Vec::new());
+ static LEAKED: RwLock<Vec<Option<&FontFace>>> = RwLock::new(Vec::new());
let id = face.id as usize;
if let Some(Some(f)) = LEAKED.read().unwrap_or_else(PoisonError::into_inner).get(id) {
return FaceRef(f);
@@ -579,7 +579,7 @@ fn script_chain(c: char) -> Option<&'static [&'static str]> {
/// The Japanese fallback chain: the craft-fonts Japanese faces' families in document order
/// (Mincho first; none without craft-fonts), then [`JAPANESE_FALLBACKS`].
fn japanese_chain() -> &'static [&'static str] {
- static CHAIN: std::sync::OnceLock<Vec<&'static str>> = std::sync::OnceLock::new();
+ static CHAIN: std::sync::OnceLock<Vec<&str>> = std::sync::OnceLock::new();
CHAIN.get_or_init(|| {
let mut chain: Vec<&'static str> = Vec::new();
for f in crate::japanese_document_fonts() {
diff --git a/crates/images/src/lib.rs b/crates/images/src/lib.rs
index 1723145ea..3a8facf08 100644
--- a/crates/images/src/lib.rs
+++ b/crates/images/src/lib.rs
@@ -738,8 +738,8 @@ mod tests {
impl<const BITS: u16> tiff::encoder::colortype::ColorType for Palette<BITS> {
type Inner = u8;
const TIFF_VALUE: tiff::tags::PhotometricInterpretation = tiff::tags::PhotometricInterpretation::RGBPalette;
- const BITS_PER_SAMPLE: &'static [u16] = &[BITS];
- const SAMPLE_FORMAT: &'static [tiff::tags::SampleFormat] = &[tiff::tags::SampleFormat::Uint];
+ const BITS_PER_SAMPLE: &[u16] = &[BITS];
+ const SAMPLE_FORMAT: &[tiff::tags::SampleFormat] = &[tiff::tags::SampleFormat::Uint];
fn horizontal_predict(row: &[u8], result: &mut Vec<u8>) {
result.extend_from_slice(row);
}
diff --git a/crates/ui-egui/src/i18n.rs b/crates/ui-egui/src/i18n.rs
index be5f43c97..bdca83589 100644
--- a/crates/ui-egui/src/i18n.rs
+++ b/crates/ui-egui/src/i18n.rs
@@ -4465,18 +4465,18 @@ pub fn tr<'a>(lang: &str, s: &'a str) -> &'a str {
}
fn lookup<'a>(lang: &str, s: &'a str) -> &'a str {
- static GERMAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static JAPANESE: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static TRANSLATIONS: OnceLock<HashMap<&'static str, [&'static str; 5]>> = OnceLock::new();
- static ARABIC: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static UKRAINIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static PORTUGUESE_BR: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static ITALIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static POLISH: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static RUSSIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static CZECH: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static FRENCH: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
- static GEORGIAN: OnceLock<HashMap<&'static str, &'static str>> = OnceLock::new();
+ static GERMAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static JAPANESE: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static TRANSLATIONS: OnceLock<HashMap<&str, [&str; 5]>> = OnceLock::new();
+ static ARABIC: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static UKRAINIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static PORTUGUESE_BR: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static ITALIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static POLISH: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static RUSSIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static CZECH: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static FRENCH: OnceLock<HashMap<&str, &str>> = OnceLock::new();
+ static GEORGIAN: OnceLock<HashMap<&str, &str>> = OnceLock::new();
if lang == "ar" {
return ARABIC.get_or_init(|| ar::TABLE.iter().copied().collect()).get(s).copied().unwrap_or(s);
}